Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetSubjectFromToken ¶
GetSubjectFromToken Get Sub(User) from context with Jwt default token using jwt.MapClaims. if not found, return nil and false. key is the key of context which store the jwt token.
func SetUserContextKey ¶
func SetUserContextKey(name string)
SetUserContextKey Set the key of context which store the user.
Types ¶
type GenericIdentity ¶
type GenericIdentity struct {
// contains filtered or unexported fields
}
GenericIdentity Represents a generic user.
func GenericIdentityFromContext ¶
func GenericIdentityFromContext(ctx context.Context) *GenericIdentity
GenericIdentityFromContext get the user from context
func (*GenericIdentity) Claims ¶
func (i *GenericIdentity) Claims() jwt.MapClaims
func (*GenericIdentity) Name ¶
func (i *GenericIdentity) Name() string
type GenericPrincipal ¶
type GenericPrincipal struct {
GenericIdentity *GenericIdentity
}
GenericPrincipal Represents a generic principal.
func GenericPrincipalFromContext ¶
func GenericPrincipalFromContext(ctx context.Context) *GenericPrincipal
GenericPrincipalFromContext get the user from context
func NewGenericPrincipalByClaims ¶
func NewGenericPrincipalByClaims(claims jwt.MapClaims) *GenericPrincipal
NewGenericPrincipalByClaims return GenericPrincipal
func (*GenericPrincipal) Identity ¶
func (p *GenericPrincipal) Identity() Identity
type Identity ¶
type Identity interface { Name() string Claims() jwt.MapClaims }
Identity defines the basic functionality of an identity object.
An identity object represents the user on whose behalf the code is running
type PermissionItem ¶
type PermissionItem struct { // AppCode is the application code which the action belongs to. AppCode string // Action name Action string // Operator name Operator string }
PermissionItem is for describing a permission.
type Principal ¶
type Principal interface {
Identity() Identity
}
Principal Defines the basic functionality of a principal object.
A principal object represents the security context of the user on whose behalf the code is running, including that user's identity (IIdentity) and any roles to which they belong.