Documentation ¶
Index ¶
- Constants
- func AddRole(userID string, roleID ...string) error
- func CheckDeviceToken(ctx context.Context, deviceToken string, tokenStr string) (context.Context, error)
- func GetAllRoles(ctx context.Context) []string
- func GetJwtToken(accountID, deviceID string, roles []string) (string, error)
- func GetUserID(ctx context.Context) string
- func HasRole(ctx context.Context, roles ...string) bool
- func RemoveRole(userID string, roleID ...string) error
- func SetAllDeviceRemoveFlag(accountID string)
- func SetDeviceRemoveFlag(accountID, deviceID string)
- func WrapAuth(c AuthConfig) func(next http.Handler) http.Handler
- type ACLM
- type AuthConfig
- type HasuraClaims
Constants ¶
View Source
const ( AM_SERVER aclmMode = "server" AM_CLIENT aclmMode = "client" )
View Source
const ( TokenExpiredDuration = time.Hour * 24 * 30 TokenDeviceKey = "dev" TokenHasuraKey = "https://hasura.io/jwt/claims" )
View Source
const ( QueueRoleAdd = "queue_role_add" QueueRoleRemove = "queue_role_remove" QueueTokenCheck = "queue_token_check" )
View Source
const ( RoleAdmin = "admin" RoleUser = "user" )
builtin roles
Variables ¶
This section is empty.
Functions ¶
func CheckDeviceToken ¶
func CheckDeviceToken(ctx context.Context, deviceToken string, tokenStr string) (context.Context, error)
CheckDeviceToken 检查设备token 如果token中包含设备ID,检查设备ID是否匹配
func GetAllRoles ¶
func HasRole ¶
HasRole check if the user has the roles Auto add admin role to check if the user is admin
func RemoveRole ¶
Types ¶
type AuthConfig ¶
type AuthConfig struct {
NoNeedAuth bool
}
type HasuraClaims ¶
Click to show internal directories.
Click to hide internal directories.