Reuse user from session when issuing oa2 token
This way we keep user's roles in case the list was modified by external-auth-provider role security
This commit is contained in:
parent
07440a49df
commit
b22a4f8ea7
@ -13,6 +13,7 @@ import (
|
||||
|
||||
"github.com/lestrrat-go/jwx/jwa"
|
||||
"github.com/lestrrat-go/jwx/jwk"
|
||||
"github.com/spf13/cast"
|
||||
|
||||
"github.com/go-chi/jwtauth"
|
||||
oauth2errors "github.com/go-oauth2/oauth2/v4/errors"
|
||||
@ -381,7 +382,9 @@ func (h AuthHandlers) handleTokenRequest(req *request.AuthReq, client *types.Aut
|
||||
userID = userID[:i]
|
||||
}
|
||||
|
||||
if user, err = h.UserService.FindByAny(suCtx, userID); err != nil {
|
||||
if req.AuthUser != nil && req.AuthUser.User != nil && req.AuthUser.User.ID == cast.ToUint64(userID) {
|
||||
user = req.AuthUser.User
|
||||
} else if user, err = h.UserService.FindByAny(suCtx, userID); err != nil {
|
||||
return h.tokenError(w, fmt.Errorf("could not generate token: %v", err))
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user