Handle ValidateURL fallback for nil & empty struct cases

This commit is contained in:
Nick Meves 2020-12-22 21:34:15 -08:00
parent 816d9a4566
commit 4b28e6886c
No known key found for this signature in database
GPG Key ID: 93BA8A3CEDCDD1CF

View File

@ -64,12 +64,12 @@ func NewKeycloakProvider(p *ProviderData) *KeycloakProvider {
// email and groups.
func (p *KeycloakProvider) EnrichSession(ctx context.Context, s *sessions.SessionState) error {
// Fallback to ValidateURL if ProfileURL not set for legacy compatibility
userinfoURL := p.ValidateURL.String()
if p.ProfileURL != nil {
userinfoURL = p.ProfileURL.String()
profileURL := p.ValidateURL.String()
if p.ProfileURL.String() != "" {
profileURL = p.ProfileURL.String()
}
json, err := requests.New(userinfoURL).
json, err := requests.New(profileURL).
WithContext(ctx).
SetHeader("Authorization", "Bearer "+s.AccessToken).
Do().