Skip to content

Commit

Permalink
fix: fix AAD single-tenant mode bug
Browse files Browse the repository at this point in the history
  • Loading branch information
nomeguy committed Mar 31, 2023
1 parent 8d1ae4e commit 8eb68ba
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions idp/goth.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ type GothIdProvider struct {
Session goth.Session
}

func NewGothIdProvider(providerType string, clientId string, clientSecret string, redirectUrl string) *GothIdProvider {
func NewGothIdProvider(providerType string, clientId string, clientSecret string, redirectUrl string, hostUrl string) *GothIdProvider {
var idp GothIdProvider
switch providerType {
case "Amazon":
Expand All @@ -102,8 +102,13 @@ func NewGothIdProvider(providerType string, clientId string, clientSecret string
Session: &apple.Session{},
}
case "AzureAD":
domain := "common"
if hostUrl != "" {
domain = hostUrl
}

idp = GothIdProvider{
Provider: azureadv2.New(clientId, clientSecret, redirectUrl, azureadv2.ProviderOptions{Tenant: "common"}),
Provider: azureadv2.New(clientId, clientSecret, redirectUrl, azureadv2.ProviderOptions{Tenant: azureadv2.TenantType(domain)}),
Session: &azureadv2.Session{},
}
case "Auth0":
Expand Down
2 changes: 1 addition & 1 deletion idp/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func GetIdProvider(typ string, subType string, clientId string, clientSecret str
} else if typ == "Douyin" {
return NewDouyinIdProvider(clientId, clientSecret, redirectUrl)
} else if isGothSupport(typ) {
return NewGothIdProvider(typ, clientId, clientSecret, redirectUrl)
return NewGothIdProvider(typ, clientId, clientSecret, redirectUrl, hostUrl)
} else if typ == "Bilibili" {
return NewBilibiliIdProvider(clientId, clientSecret, redirectUrl)
}
Expand Down

0 comments on commit 8eb68ba

Please sign in to comment.