Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add oid as subject source for microsoft #4171

Merged
merged 5 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .schemastore/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@
"title": "Microsoft subject source",
"description": "Controls which source the subject identifier is taken from by microsoft provider. If set to `userinfo` (the default) then the identifier is taken from the `sub` field of OIDC ID token or data received from `/userinfo` standard OIDC endpoint. If set to `me` then the `id` field of data structure received from `https://graph.microsoft.com/v1.0/me` is taken as an identifier.",
"type": "string",
"enum": ["userinfo", "me"],
"enum": ["userinfo", "me", "oid"],
"default": "userinfo",
"examples": ["userinfo"]
},
Expand Down
2 changes: 1 addition & 1 deletion embedx/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@
"title": "Microsoft subject source",
"description": "Controls which source the subject identifier is taken from by microsoft provider. If set to `userinfo` (the default) then the identifier is taken from the `sub` field of OIDC ID token or data received from `/userinfo` standard OIDC endpoint. If set to `me` then the `id` field of data structure received from `https://graph.microsoft.com/v1.0/me` is taken as an identifier.",
"type": "string",
"enum": ["userinfo", "me"],
"enum": ["userinfo", "me", "oid"],
"default": "userinfo",
"examples": ["userinfo"]
},
Expand Down
1 change: 1 addition & 0 deletions selfservice/strategy/oidc/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ type NonceValidationSkipper interface {
type Claims struct {
Issuer string `json:"iss,omitempty"`
Subject string `json:"sub,omitempty"`
Object string `json:"oid,omitempty"`
Name string `json:"name,omitempty"`
GivenName string `json:"given_name,omitempty"`
FamilyName string `json:"family_name,omitempty"`
Expand Down
4 changes: 4 additions & 0 deletions selfservice/strategy/oidc/provider_microsoft.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ func (m *ProviderMicrosoft) updateSubject(ctx context.Context, claims *Claims, e
claims.Subject = user.ID
}

if m.config.SubjectSource == "oid" {
claims.Subject = claims.Object
}

return claims, nil
}

Expand Down
Loading