Documentation ¶
Index ¶
- Constants
- Variables
- func FromContext(ctx context.Context) (*userinfo.UserInfo, bool)
- func GetTokenFromGRPCContext(ctx context.Context) (string, error)
- func GetUserInfoFromContext(ctx context.Context) (*userinfo.UserInfo, bool)
- func MustGetUserInfoFromContext(ctx context.Context) *userinfo.UserInfo
- func SetTokenClaimsTimes(claims *CitizenInfoClaims)
- type CitizenInfoClaims
- type GRPCAuth
- type GRPCPerm
- type TokenMgr
Constants ¶
View Source
const ( AuthAccIDCtxTag = "auth.accid" AuthActiveCharIDCtxTag = "auth.chrid" AuthSubCtxTag = "auth.sub" AuthActiveCharJobCtxTag = "auth.chrjob" )
View Source
const ( PermCanBeSuper = "CanBeSuper" PermCanBeSuperKey = "canbesuper" PermSuperUser = "SuperUser" PermSuperUserKey = "superuser" PermAny = "Any" )
View Source
const ( TokenExpireTime = 96 * time.Hour TokenRenewalTime = 48 * time.Hour TokenMaxRenews = 5 )
Variables ¶
View Source
var ( ErrNoToken = status.Errorf(codes.Unauthenticated, "errors.pkg-auth.ErrNoToken") ErrInvalidToken = status.Error(codes.Unauthenticated, "errors.pkg-auth.ErrInvalidToken") ErrCheckToken = status.Error(codes.Unauthenticated, "errors.pkg-auth.ErrCheckToken") ErrUserNoPerms = status.Error(codes.PermissionDenied, "errors.pkg-auth.ErrUserNoPerms") ErrNoUserInfo = status.Error(codes.Unauthenticated, "errors.pkg-auth.ErrNoUserInfo") ErrPermissionDenied = status.Errorf(codes.PermissionDenied, "errors.pkg-auth.ErrPermissionDenied") )
View Source
var AuthModule = fx.Module("grpc_auth", fx.Provide( NewGRPCAuth, ), )
View Source
var PermsModule = fx.Module("grpc_perms", fx.Provide( NewGRPCPerms, ), )
View Source
var TokenMgrModule = fx.Module("tokenMgr", fx.Provide( NewTokenMgrFromConfig, ), )
Functions ¶
func GetUserInfoFromContext ¶
func SetTokenClaimsTimes ¶
func SetTokenClaimsTimes(claims *CitizenInfoClaims)
Types ¶
type CitizenInfoClaims ¶
type CitizenInfoClaims struct { AccID uint64 `json:"accid"` Username string `json:"usr"` CharID int32 `json:"chrid"` RenewedCount int32 `json:"renwc"` jwt.RegisteredClaims }
func BuildTokenClaimsFromAccount ¶
func BuildTokenClaimsFromAccount(account *model.FivenetAccounts, activeChar *users.User) *CitizenInfoClaims
type GRPCAuth ¶
type GRPCAuth struct {
// contains filtered or unexported fields
}
func NewGRPCAuth ¶
func NewGRPCAuth(ui userinfo.UserInfoRetriever, tm *TokenMgr) *GRPCAuth
func (*GRPCAuth) GRPCAuthFunc ¶
type GRPCPerm ¶
type GRPCPerm struct {
// contains filtered or unexported fields
}
func NewGRPCPerms ¶
func NewGRPCPerms(p perms.Permissions) *GRPCPerm
func (*GRPCPerm) GRPCPermissionStreamFunc ¶
func (*GRPCPerm) GRPCPermissionUnaryFunc ¶
type TokenMgr ¶
type TokenMgr struct {
// contains filtered or unexported fields
}
func NewTokenMgr ¶
func NewTokenMgrFromConfig ¶ added in v0.8.0
func (*TokenMgr) NewWithClaims ¶
func (t *TokenMgr) NewWithClaims(claims *CitizenInfoClaims) (string, error)
func (*TokenMgr) ParseWithClaims ¶
func (t *TokenMgr) ParseWithClaims(tokenString string) (*CitizenInfoClaims, error)
Click to show internal directories.
Click to hide internal directories.