Add Yao custom fields to ID token claims
- Enhanced the SignIDToken method to include additional Yao-specific fields such as tenant_id, team_id, is_owner, and team details in the token claims. - Improved the structure of claims to support team information, ensuring comprehensive metadata is included in the generated tokens.
This commit is contained in:
parent
1af0a20015
commit
0a353e6e41
1 changed files with 36 additions and 0 deletions
|
|
@ -566,6 +566,42 @@ func (s *Service) SignIDToken(clientID, scope string, expiresIn int, userdata *t
|
||||||
claims["updated_at"] = *userdata.UpdatedAt
|
claims["updated_at"] = *userdata.UpdatedAt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add Yao custom fields with namespace
|
||||||
|
if userdata.YaoTenantID != "" {
|
||||||
|
claims["yao:tenant_id"] = userdata.YaoTenantID
|
||||||
|
}
|
||||||
|
if userdata.YaoTeamID != "" {
|
||||||
|
claims["yao:team_id"] = userdata.YaoTeamID
|
||||||
|
}
|
||||||
|
if userdata.YaoIsOwner != nil {
|
||||||
|
claims["yao:is_owner"] = *userdata.YaoIsOwner
|
||||||
|
}
|
||||||
|
// Add Yao team info if present
|
||||||
|
if userdata.YaoTeam != nil {
|
||||||
|
teamMap := make(map[string]interface{})
|
||||||
|
if userdata.YaoTeam.TeamID != "" {
|
||||||
|
teamMap["team_id"] = userdata.YaoTeam.TeamID
|
||||||
|
}
|
||||||
|
if userdata.YaoTeam.Logo != "" {
|
||||||
|
teamMap["logo"] = userdata.YaoTeam.Logo
|
||||||
|
}
|
||||||
|
if userdata.YaoTeam.Name != "" {
|
||||||
|
teamMap["name"] = userdata.YaoTeam.Name
|
||||||
|
}
|
||||||
|
if userdata.YaoTeam.OwnerID != "" {
|
||||||
|
teamMap["owner_id"] = userdata.YaoTeam.OwnerID
|
||||||
|
}
|
||||||
|
if userdata.YaoTeam.Description != "" {
|
||||||
|
teamMap["description"] = userdata.YaoTeam.Description
|
||||||
|
}
|
||||||
|
if userdata.YaoTeam.UpdatedAt != nil {
|
||||||
|
teamMap["updated_at"] = *userdata.YaoTeam.UpdatedAt
|
||||||
|
}
|
||||||
|
if len(teamMap) > 0 {
|
||||||
|
claims["yao:team"] = teamMap
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Add scope if provided (useful for determining which claims to include)
|
// Add scope if provided (useful for determining which claims to include)
|
||||||
if scope != "" {
|
if scope != "" {
|
||||||
claims["scope"] = scope
|
claims["scope"] = scope
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue