1
1
package auth
2
2
3
3
import (
4
- authorizer2 "github.com/TBXark/sphere/server/auth/authorizer"
4
+ "github.com/TBXark/sphere/server/auth/authorizer"
5
5
"github.com/gin-gonic/gin"
6
6
"net/http"
7
7
"strings"
@@ -15,7 +15,7 @@ type AccessControl interface {
15
15
IsAllowed (role , resource string ) bool
16
16
}
17
17
18
- func NewAuthMiddleware (prefix string , parser authorizer2 .Parser [authorizer2 .RBACClaims [int64 ]], abortOnError bool ) gin.HandlerFunc {
18
+ func NewAuthMiddleware (prefix string , parser authorizer .Parser [authorizer .RBACClaims [int64 ]], abortOnError bool ) gin.HandlerFunc {
19
19
abort := func (ctx * gin.Context ) {
20
20
if abortOnError {
21
21
ctx .AbortWithStatusJSON (http .StatusUnauthorized , gin.H {
@@ -41,9 +41,9 @@ func NewAuthMiddleware(prefix string, parser authorizer2.Parser[authorizer2.RBAC
41
41
return
42
42
}
43
43
44
- ctx .Set (authorizer2 .ContextKeyUID , claims .UID )
45
- ctx .Set (authorizer2 .ContextKeySubject , claims .Subject )
46
- ctx .Set (authorizer2 .ContextKeyRoles , claims .Roles )
44
+ ctx .Set (authorizer .ContextKeyUID , claims .UID )
45
+ ctx .Set (authorizer .ContextKeySubject , claims .Subject )
46
+ ctx .Set (authorizer .ContextKeyRoles , claims .Roles )
47
47
}
48
48
}
49
49
@@ -54,7 +54,7 @@ func NewPermissionMiddleware(resource string, acl AccessControl) gin.HandlerFunc
54
54
})
55
55
}
56
56
return func (ctx * gin.Context ) {
57
- rolesRaw , exist := ctx .Get (authorizer2 .ContextKeyRoles )
57
+ rolesRaw , exist := ctx .Get (authorizer .ContextKeyRoles )
58
58
if ! exist {
59
59
abort (ctx )
60
60
return
0 commit comments