diff options
Diffstat (limited to 'app/controllers/sessions/service.go')
| -rw-r--r-- | app/controllers/sessions/service.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/app/controllers/sessions/service.go b/app/controllers/sessions/service.go index 9e74bfb..79ffad6 100644 --- a/app/controllers/sessions/service.go +++ b/app/controllers/sessions/service.go @@ -2,9 +2,11 @@ package sessions import ( "context" + "encoding/base64" "errors" "net/http" "net/url" + "strings" "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/app/cfg" "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/oidc" @@ -60,6 +62,15 @@ func (svc *Service) Exchange(r *http.Request) (*oidc.Tokens, error) { return tokens, nil } +func (svc *Service) JWTBody(ctx context.Context, raw oidc.RawToken) ([]byte, error) { + sections := strings.SplitN(raw.String(), ".", 3) + if len(sections) != 3 { + return nil, errors.New("Invalid JWT") + } + + return base64.RawURLEncoding.DecodeString(sections[1]) +} + func (svc *Service) redirectURIFor(r *http.Request) string { if len(svc.cfg.Config.RedirectURL) > 0 { return svc.cfg.Config.RedirectURL |
