Skip to content

Commit

Permalink
Add id_token support to microsoft oidc provider.
Browse files Browse the repository at this point in the history
  • Loading branch information
jwmay2012 committed Aug 15, 2024
1 parent 68693a4 commit be931e3
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions selfservice/strategy/oidc/provider_microsoft.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package oidc
import (
"context"
"encoding/json"
"fmt"
"net/url"
"strings"

Expand All @@ -25,6 +26,7 @@ import (

type ProviderMicrosoft struct {
*ProviderGenericOIDC
JWKSUrl string
}

func NewProviderMicrosoft(
Expand All @@ -36,6 +38,7 @@ func NewProviderMicrosoft(
config: config,
reg: reg,
},
JWKSUrl: "https://login.microsoftonline.com/common/discovery/keys",
}
}

Expand Down Expand Up @@ -127,3 +130,9 @@ type microsoftUnverifiedClaims struct {
func (c *microsoftUnverifiedClaims) Valid() error {
return nil
}

func (p *ProviderMicrosoft) Verify(ctx context.Context, rawIDToken string) (*Claims, error) {
keySet := gooidc.NewRemoteKeySet(ctx, p.JWKSUrl)
ctx = gooidc.ClientContext(ctx, p.reg.HTTPClient(ctx).HTTPClient)
return verifyToken(ctx, keySet, p.config, rawIDToken, fmt.Sprintf("https://login.microsoftonline.com/%s/v2.0", p.config.Tenant))
}

0 comments on commit be931e3

Please sign in to comment.