Documentation
¶
Index ¶
- Constants
- func AuthHttpRequest(req *http.Request, needAdmin bool) error
- func AuthMiddleware(needAdmin bool) mux.MiddlewareFunc
- func DIMiddleware(authorize Authorize) mux.MiddlewareFunc
- func ToContext(ctx context.Context, claim *Claims) context.Context
- type Authorize
- type Claims
- type Ldap
- type LdapConfigs
- type Static
- type StaticConfigs
Constants ¶
View Source
const ( Name = "authorize" CurrentClaims = "claims" )
Variables ¶
This section is empty.
Functions ¶
func AuthMiddleware ¶
func AuthMiddleware(needAdmin bool) mux.MiddlewareFunc
func DIMiddleware ¶
func DIMiddleware(authorize Authorize) mux.MiddlewareFunc
Types ¶
type Authorize ¶
type Authorize interface {
Authorize(auth authenticate.Authenticate, needAdmin bool) (*Claims, error)
}
type Claims ¶
type Claims struct {
UserID string `json:"user_id" map:"id"`
UnitID string `json:"unit_id"`
Username string `json:"username"`
Name string `json:"name"`
Surname string `json:"surname"`
Email string `json:"email"`
Mobile string `json:"mobile"`
}
func FromContext ¶
type Ldap ¶
type Ldap struct {
LdapConfigs
Client *ldapext.Client
}
func NewLdap ¶
func NewLdap(configs LdapConfigs) (*Ldap, error)
func (Ldap) Authorize ¶
func (a Ldap) Authorize(auth authenticate.Authenticate, needAdmin bool) (*Claims, error)
type LdapConfigs ¶
type Static ¶
type Static struct {
StaticConfigs
}
func NewStatic
deprecated
func NewStatic(configs StaticConfigs) *Static
Deprecated: This method will be removed soon, Use the NewLdap method instead
func (Static) Authorize ¶
func (a Static) Authorize(auth authenticate.Authenticate, needAdmin bool) (*Claims, error)
type StaticConfigs ¶
Click to show internal directories.
Click to hide internal directories.