template-monorepo/internal/model/permission/domain/entity/role_mapping.go

31 lines
1.0 KiB
Go
Raw Normal View History

package entity
import (
"gateway/internal/model/permission/domain/enum"
"go.mongodb.org/mongo-driver/v2/bson"
)
// RoleMapping links an external identity-provider group/role to an
// internal tenant Role. SyncFromX flows look up via
// (TenantID, ExternalSource, ExternalKey) to translate provider claims
// into Role assignments.
//
// InternalRoleKey is denormalized for audit/query convenience.
type RoleMapping struct {
ID bson.ObjectID `bson:"_id,omitempty"`
TenantID string `bson:"tenant_id"`
ExternalSource enum.RoleSource `bson:"external_source"`
ExternalKey string `bson:"external_key"`
InternalRoleID string `bson:"internal_role_id"`
InternalRoleKey string `bson:"internal_role_key"`
CreateAt int64 `bson:"create_at"`
UpdateAt int64 `bson:"update_at"`
}
// CollectionName returns the MongoDB collection for external→internal
// role mappings.
func (RoleMapping) CollectionName() string {
return "role_mappings"
}