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 @@

Unauthorised user


-

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.



Log in as different user
diff --git a/makefile b/makefile index 6b89bea..98d8a33 100644 --- a/makefile +++ b/makefile @@ -1,5 +1,6 @@ GOPACKAGE=github.com/forceu/gokapi BUILD_FLAGS=-ldflags="-s -w -X '$(GOPACKAGE)/internal/environment.Builder=Make Script' -X '$(GOPACKAGE)/internal/environment.BuildTime=$(shell date)'" +BUILD_FLAGS_DEBUG=-ldflags="-X '$(GOPACKAGE)/internal/environment.Builder=Make Script' -X '$(GOPACKAGE)/internal/environment.BuildTime=$(shell date)'" DOCKER_IMAGE_NAME=gokapi CONTAINER_TOOL ?= docker @@ -16,6 +17,14 @@ build : go generate ./... CGO_ENABLED=0 go build $(BUILD_FLAGS) -o ./gokapi $(GOPACKAGE)/cmd/gokapi +.PHONY: build-debug +# Build Gokapi binary +build-debug : + @echo "Building binary with debug info..." + @echo + go generate ./... + CGO_ENABLED=0 go build $(BUILD_FLAGS_DEBUG) -o ./gokapi $(GOPACKAGE)/cmd/gokapi + .PHONY: coverage coverage: @echo Generating coverage