mirror of
https://github.com/pocket-id/pocket-id.git
synced 2026-10-10 19:59:04 +02:00
refactor: authorize API routes with per-endpoint scopes (#1823)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
This commit is contained in:
co-authored by
copilot-swe-agent[bot]
parent
1bd6f006c8
commit
0ec6bfa191
@@ -15,6 +15,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/pocket-id/pocket-id/backend/internal/authz"
|
||||
"github.com/pocket-id/pocket-id/backend/internal/model"
|
||||
datatype "github.com/pocket-id/pocket-id/backend/internal/model/types"
|
||||
testutils "github.com/pocket-id/pocket-id/backend/internal/utils/testing"
|
||||
@@ -167,8 +168,12 @@ func testAuthorizationHandlerPAR(t *testing.T, clientType string, tt authorizati
|
||||
rec := httptest.NewRecorder()
|
||||
router := gin.New()
|
||||
router.Handle(tt.method, "/authorize", func(c *gin.Context) {
|
||||
c.Set("userID", userID)
|
||||
c.Set("authenticationTime", time.Now().UTC().Add(-time.Minute))
|
||||
authz.SetPrincipal(c, &authz.Principal{
|
||||
Kind: authz.KindSession,
|
||||
UserID: userID,
|
||||
Scopes: authz.UserScopes(false, authz.KindSession),
|
||||
AuthenticationTime: time.Now().UTC().Add(-time.Minute),
|
||||
})
|
||||
handler.authorize(c)
|
||||
})
|
||||
router.ServeHTTP(rec, req)
|
||||
|
||||
Reference in New Issue
Block a user