fix(oauth): openid scope is not added by default / add scope name and list in dashboard (close #3274)

This commit is contained in:
Aaron Liu
2026-02-14 10:00:14 +08:00
parent a8a625e967
commit 2a59407916
2 changed files with 7 additions and 1 deletions

2
assets

Submodule assets updated: 5eff3fc6db...8e8a68141a

View File

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