From ba25e69680f779f238c0fd247712571007d7fbf7 Mon Sep 17 00:00:00 2001 From: Maxim Lebedev Date: Sun, 6 Aug 2023 04:39:12 +0600 Subject: [PATCH] :bug: Parse 'scope[]' key from self-client request --- .../auth/delivery/http/auth_http_schema.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/internal/auth/delivery/http/auth_http_schema.go b/internal/auth/delivery/http/auth_http_schema.go index 426abde..07c4ae5 100644 --- a/internal/auth/delivery/http/auth_http_schema.go +++ b/internal/auth/delivery/http/auth_http_schema.go @@ -2,6 +2,7 @@ package http import ( "errors" + "fmt" "net/http" "strings" @@ -121,6 +122,21 @@ func (r *AuthAuthorizationRequest) bind(req *http.Request) error { r.ResponseType = domain.ResponseTypeCode } + if req.URL.Query().Has("scope[]") { + for _, k := range req.URL.Query()["scope[]"] { + scope, err := domain.ParseScope(k) + if err != nil { + return fmt.Errorf("cannot parse requested scope: %w", err) + } + + if r.Scope.Has(scope) { + continue + } + + r.Scope = append(r.Scope, scope) + } + } + return nil } @@ -139,7 +155,7 @@ func NewAuthVerifyRequest() *AuthVerifyRequest { } } -//nolint:funlen,cyclop +//nolint:cyclop func (r *AuthVerifyRequest) bind(req *http.Request) error { indieAuthError := new(domain.Error)