Skip to content

Commit

Permalink
cleanup names
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard87 committed Oct 9, 2024
1 parent d125ae7 commit 13ad01b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion api/middleware/auth/authentication.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func NewZerologAuthenticationDetailsMiddleware() negroni.HandlerFunc {

logContext := log.Ctx(ctx).With()
if user.IsAuthenticated() {
logContext = logContext.Str("azure_oid", user.Id())
logContext = logContext.Str("user_id", user.Id())
} else {
logContext = logContext.Bool("anonymous", true)
}
Expand Down
14 changes: 7 additions & 7 deletions api/utils/token/unchecked_principal.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,28 @@ func (p *unchechedClaimsPrincipal) IsAuthenticated() bool {
}
func (p *unchechedClaimsPrincipal) Id() string {
if p.azureClaims.ObjectId != "" {
return fmt.Sprintf("unverified: %s", p.azureClaims.ObjectId)
return fmt.Sprintf("oid:%s", p.azureClaims.ObjectId)
}

return fmt.Sprintf("unverified: %s (sub!)", p.claims.Subject)
return fmt.Sprintf("sub:%s", p.claims.Subject)
}

func (p *unchechedClaimsPrincipal) Name() string {
if p.azureClaims.Upn != "" {
return fmt.Sprintf("unverified: %s", p.azureClaims.Upn)
return p.azureClaims.Upn
}

if p.azureClaims.AppDisplayName != "" {
return fmt.Sprintf("unverified: %s", p.azureClaims.AppDisplayName)
return p.azureClaims.AppDisplayName
}

if p.azureClaims.AppId != "" {
return fmt.Sprintf("unverified: %s", p.azureClaims.AppId)
return p.azureClaims.AppId
}

if p.azureClaims.ObjectId != "" {
return fmt.Sprintf("unverified: %s", p.azureClaims.ObjectId)
return p.azureClaims.ObjectId
}

return fmt.Sprintf("unverified: %s", p.claims.Subject)
return p.claims.Subject
}

0 comments on commit 13ad01b

Please sign in to comment.