mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-11 14:52:23 +00:00
add avatar URL
This commit is contained in:
@@ -126,6 +126,7 @@ func NewServer(
|
|||||||
fallbackLogger: fallbackLogger,
|
fallbackLogger: fallbackLogger,
|
||||||
hashAlg: crypto.NewBCrypt(10), // as we are only verifying in oidc, the cost is already part of the hash string and the config here is irrelevant.
|
hashAlg: crypto.NewBCrypt(10), // as we are only verifying in oidc, the cost is already part of the hash string and the config here is irrelevant.
|
||||||
signingKeyAlgorithm: config.SigningKeyAlgorithm,
|
signingKeyAlgorithm: config.SigningKeyAlgorithm,
|
||||||
|
assetAPIPrefix: assets.AssetAPI(externalSecure),
|
||||||
}
|
}
|
||||||
metricTypes := []metrics.MetricType{metrics.MetricTypeRequestCount, metrics.MetricTypeStatusCode, metrics.MetricTypeTotalCount}
|
metricTypes := []metrics.MetricType{metrics.MetricTypeRequestCount, metrics.MetricTypeStatusCode, metrics.MetricTypeTotalCount}
|
||||||
server.Handler = op.RegisterLegacyServer(server, op.WithHTTPMiddleware(
|
server.Handler = op.RegisterLegacyServer(server, op.WithHTTPMiddleware(
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ type Server struct {
|
|||||||
fallbackLogger *slog.Logger
|
fallbackLogger *slog.Logger
|
||||||
hashAlg crypto.HashAlgorithm
|
hashAlg crypto.HashAlgorithm
|
||||||
signingKeyAlgorithm string
|
signingKeyAlgorithm string
|
||||||
|
assetAPIPrefix func(ctx context.Context) string
|
||||||
}
|
}
|
||||||
|
|
||||||
func endpoints(endpointConfig *EndpointConfig) op.Endpoints {
|
func endpoints(endpointConfig *EndpointConfig) op.Endpoints {
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ func (s *Server) getUserInfoWithRoles(ctx context.Context, userID, projectID str
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
userInfo := userInfoToOIDC(userInfoResult.userInfo, scope)
|
userInfo := userInfoToOIDC(userInfoResult.userInfo, scope, s.assetAPIPrefix(ctx))
|
||||||
setUserInfoRoleClaims(userInfo, assertRolesResult.projectsRoles)
|
setUserInfoRoleClaims(userInfo, assertRolesResult.projectsRoles)
|
||||||
|
|
||||||
return userInfo, s.userinfoFlows(ctx, userInfoResult.userInfo, assertRolesResult.userGrants, userInfo)
|
return userInfo, s.userinfoFlows(ctx, userInfoResult.userInfo, assertRolesResult.userGrants, userInfo)
|
||||||
@@ -150,7 +150,7 @@ func (s *Server) assertRoles(ctx context.Context, userID, projectID string, scop
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func userInfoToOIDC(user *query.OIDCUserInfo, scope []string) *oidc.UserInfo {
|
func userInfoToOIDC(user *query.OIDCUserInfo, scope []string, assetPrefix string) *oidc.UserInfo {
|
||||||
out := new(oidc.UserInfo)
|
out := new(oidc.UserInfo)
|
||||||
for _, s := range scope {
|
for _, s := range scope {
|
||||||
switch s {
|
switch s {
|
||||||
@@ -159,7 +159,7 @@ func userInfoToOIDC(user *query.OIDCUserInfo, scope []string) *oidc.UserInfo {
|
|||||||
case oidc.ScopeEmail:
|
case oidc.ScopeEmail:
|
||||||
out.UserInfoEmail = userInfoEmailToOIDC(user.User)
|
out.UserInfoEmail = userInfoEmailToOIDC(user.User)
|
||||||
case oidc.ScopeProfile:
|
case oidc.ScopeProfile:
|
||||||
out.UserInfoProfile = userInfoProfileToOidc(user.User)
|
out.UserInfoProfile = userInfoProfileToOidc(user.User, assetPrefix)
|
||||||
case oidc.ScopePhone:
|
case oidc.ScopePhone:
|
||||||
out.UserInfoPhone = userInfoPhoneToOIDC(user.User)
|
out.UserInfoPhone = userInfoPhoneToOIDC(user.User)
|
||||||
case oidc.ScopeAddress:
|
case oidc.ScopeAddress:
|
||||||
@@ -192,14 +192,14 @@ func userInfoEmailToOIDC(user *query.User) oidc.UserInfoEmail {
|
|||||||
return oidc.UserInfoEmail{}
|
return oidc.UserInfoEmail{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func userInfoProfileToOidc(user *query.User) oidc.UserInfoProfile {
|
func userInfoProfileToOidc(user *query.User, assetPrefix string) oidc.UserInfoProfile {
|
||||||
if human := user.Human; human != nil {
|
if human := user.Human; human != nil {
|
||||||
return oidc.UserInfoProfile{
|
return oidc.UserInfoProfile{
|
||||||
Name: human.DisplayName,
|
Name: human.DisplayName,
|
||||||
GivenName: human.FirstName,
|
GivenName: human.FirstName,
|
||||||
FamilyName: human.LastName,
|
FamilyName: human.LastName,
|
||||||
Nickname: human.NickName,
|
Nickname: human.NickName,
|
||||||
// Picture: domain.AvatarURL(o.assetAPIPrefix(ctx), user.ResourceOwner, user.Human.AvatarKey),
|
Picture: domain.AvatarURL(assetPrefix, user.ResourceOwner, user.Human.AvatarKey),
|
||||||
Gender: getGender(human.Gender),
|
Gender: getGender(human.Gender),
|
||||||
Locale: oidc.NewLocale(human.PreferredLanguage),
|
Locale: oidc.NewLocale(human.PreferredLanguage),
|
||||||
UpdatedAt: oidc.FromTime(user.ChangeDate),
|
UpdatedAt: oidc.FromTime(user.ChangeDate),
|
||||||
|
|||||||
Reference in New Issue
Block a user