🐛 Parse 'scope[]' key from self-client request

This commit is contained in:
Maxim Lebedev 2023-08-06 04:39:12 +06:00
parent bf7b6df692
commit ba25e69680
Signed by: toby3d
GPG key ID: 1F14E25B7C119FC5

View file

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