summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-05-15 09:56:50 -0600
committermo khan <mo@mokhan.ca>2025-05-15 09:56:50 -0600
commitc70cbe07c002bc307b86ea0ae05f62418a651683 (patch)
treefd55d15b60935a601068dbfb44f1b34dfca52778 /app
parent405ff48e0e93a6998a8cee2560649bb834fe0389 (diff)
refactor: remove more types from oidc package
Diffstat (limited to 'app')
-rw-r--r--app/cfg/cfg.go2
-rw-r--r--app/middleware/init.go13
-rw-r--r--app/middleware/user.go2
-rw-r--r--app/middleware/user_test.go2
4 files changed, 14 insertions, 5 deletions
diff --git a/app/cfg/cfg.go b/app/cfg/cfg.go
index 1dffa16..e076932 100644
--- a/app/cfg/cfg.go
+++ b/app/cfg/cfg.go
@@ -1,10 +1,10 @@
package cfg
import (
+ "github.com/coreos/go-oidc/v3/oidc"
"github.com/xlgmokha/x/pkg/context"
"github.com/xlgmokha/x/pkg/env"
"gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/app/domain"
- "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/oidc"
)
var CurrentUser context.Key[*domain.User] = context.Key[*domain.User]("current_user")
diff --git a/app/middleware/init.go b/app/middleware/init.go
index f1a693d..874ca52 100644
--- a/app/middleware/init.go
+++ b/app/middleware/init.go
@@ -1,14 +1,23 @@
package middleware
import (
+ "github.com/coreos/go-oidc/v3/oidc"
"github.com/xlgmokha/x/pkg/mapper"
"gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/app/domain"
- "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/oidc"
)
+type CustomClaims struct {
+ Name string `json:"name"`
+ Nickname string `json:"nickname"`
+ Email string `json:"email"`
+ ProfileURL string `json:"profile"`
+ Picture string `json:"picture"`
+ Groups []string `json:"groups_direct"`
+}
+
func init() {
mapper.Register(func(idToken *oidc.IDToken) *domain.User {
- customClaims := &oidc.CustomClaims{}
+ customClaims := &CustomClaims{}
if err := idToken.Claims(customClaims); err != nil {
return &domain.User{ID: domain.ID(idToken.Subject)}
}
diff --git a/app/middleware/user.go b/app/middleware/user.go
index c0181f9..9a88f8e 100644
--- a/app/middleware/user.go
+++ b/app/middleware/user.go
@@ -3,11 +3,11 @@ package middleware
import (
"net/http"
+ "github.com/coreos/go-oidc/v3/oidc"
"github.com/xlgmokha/x/pkg/mapper"
"github.com/xlgmokha/x/pkg/x"
"gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/app/cfg"
"gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/app/domain"
- "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/oidc"
"gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/pls"
)
diff --git a/app/middleware/user_test.go b/app/middleware/user_test.go
index e6ba09d..aed3582 100644
--- a/app/middleware/user_test.go
+++ b/app/middleware/user_test.go
@@ -4,13 +4,13 @@ import (
"net/http"
"testing"
+ "github.com/coreos/go-oidc/v3/oidc"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/xlgmokha/x/pkg/test"
"gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/app/cfg"
"gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/app/db"
"gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/app/domain"
- "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/oidc"
"gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/pls"
)