diff --git a/internal/webserver/authentication/Authentication.go b/internal/webserver/authentication/Authentication.go index d3534f0..4191497 100644 --- a/internal/webserver/authentication/Authentication.go +++ b/internal/webserver/authentication/Authentication.go @@ -169,9 +169,16 @@ func extractOauthGroups(userInfo OAuthUserClaims, groupScope string) ([]string, return nil, fmt.Errorf("claim %s was not passed on", groupScope) } - // Convert the interface{} to a []interface{} and then to []string + // Convert the interface{} to a []string + if groupsInterface == nil { + return []string{}, nil + } + groupsCast, ok := groupsInterface.([]any) + if !ok { + return nil, fmt.Errorf("scope %s is not an array", groupScope) + } var groups []string - for _, group := range groupsInterface.([]interface{}) { + for _, group := range groupsCast { groups = append(groups, group.(string)) } diff --git a/internal/webserver/web/templates/html_error_auth.tmpl b/internal/webserver/web/templates/html_error_auth.tmpl index 5d4de4b..d5b97a6 100644 --- a/internal/webserver/web/templates/html_error_auth.tmpl +++ b/internal/webserver/web/templates/html_error_auth.tmpl @@ -7,7 +7,7 @@
Login with OAuth provider was sucessful, however this user is not authorised by Gokapi.
Login with OAuth provider was sucessful, however this user is not authorised to use Gokapi.