mirror of
https://github.com/cloudreve/cloudreve.git
synced 2026-03-02 22:47:01 +00:00
fix(oauth): openid scope is not added by default / add scope name and list in dashboard (close #3274)
This commit is contained in:
2
assets
2
assets
Submodule assets updated: 5eff3fc6db...8e8a68141a
@@ -16,6 +16,7 @@ import (
|
||||
"github.com/cloudreve/Cloudreve/v4/pkg/serializer"
|
||||
"github.com/cloudreve/Cloudreve/v4/pkg/util"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/samber/lo"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -90,6 +91,11 @@ func (s *GrantService) Get(c *gin.Context) (*GrantResponse, error) {
|
||||
return nil, serializer.NewError(serializer.CodeParamErr, "Invalid scope requested", nil)
|
||||
}
|
||||
|
||||
// Must have openid scope
|
||||
if !lo.Contains(requestedScopes, types.ScopeOpenID) {
|
||||
return nil, serializer.NewError(serializer.CodeParamErr, "openid scope required", nil)
|
||||
}
|
||||
|
||||
// 3. Create/update grant
|
||||
if err := oAuthClient.UpsertGrant(c, user.ID, app.ID, requestedScopes); err != nil {
|
||||
return nil, serializer.NewError(serializer.CodeDBError, "Failed to create grant", err)
|
||||
|
||||
Reference in New Issue
Block a user