Documentation ¶
Index ¶
- Constants
- func GrantCheckFilter(auth IAuthorization) plugin.Handler
- func IdentificationFilter(auth IAuthorization) plugin.Handler
- func In(list []string, item string) bool
- func NamespaceFilter(auth IAuthorization) plugin.Handler
- func NewGateway(datasource k8s.Interface) self.Interface
- func NewMicroGateway(handler http.Handler, authorization IAuthorization) error
- func PermissionFilter(auth IAuthorization) plugin.Handler
- func ServerFilter(self http.Handler) plugin.Handler
- func SkipFilter(auth IAuthorization) plugin.Handler
- func ValidateTokenFilter(auth IAuthorization) plugin.Handler
- type Authorization
- func (auth *Authorization) AllowNamespaces(username string, isAdmin, isTenantOwner, isDepartmentOwner bool) ([]string, error)
- func (auth *Authorization) CheckNamespace(userName, namespace string, isAdmin, isTenantOwner, isDepartmentOwner bool) (bool, error)
- func (auth *Authorization) CheckPermission(userName string, uri *uri.URI) (bool, error)
- func (auth *Authorization) IsAdmin(userName string) (bool, error)
- func (auth *Authorization) IsDepartmentOwner(userName string) (bool, error)
- func (auth *Authorization) IsNeedSkip(method, path string) (bool, error)
- func (auth *Authorization) IsTenantOwner(userName string) (bool, error)
- func (auth *Authorization) IsWithGranted(userName string) (bool, error)
- func (auth *Authorization) ValidateToken(token string) (*CustomClaims, error)
- type CustomClaims
- type Gateway
- type IAuthorization
- type Identification
- type Token
Constants ¶
View Source
const ( IsSkip = "isSkip" AuthorizationUserName = "userName" UserIdentification = "userIdentification" ForbiddenMessage = "not allow to access" )
Variables ¶
This section is empty.
Functions ¶
func GrantCheckFilter ¶
func GrantCheckFilter(auth IAuthorization) plugin.Handler
func IdentificationFilter ¶
func IdentificationFilter(auth IAuthorization) plugin.Handler
func NamespaceFilter ¶
func NamespaceFilter(auth IAuthorization) plugin.Handler
func NewMicroGateway ¶
func NewMicroGateway(handler http.Handler, authorization IAuthorization) error
func PermissionFilter ¶
func PermissionFilter(auth IAuthorization) plugin.Handler
func SkipFilter ¶
func SkipFilter(auth IAuthorization) plugin.Handler
func ValidateTokenFilter ¶
func ValidateTokenFilter(auth IAuthorization) plugin.Handler
Types ¶
type Authorization ¶
type Authorization struct {
// contains filtered or unexported fields
}
func NewAuthorization ¶
func NewAuthorization(svcInterface service.Interface) *Authorization
func (*Authorization) AllowNamespaces ¶
func (auth *Authorization) AllowNamespaces(username string, isAdmin, isTenantOwner, isDepartmentOwner bool) ([]string, error)
func (*Authorization) CheckNamespace ¶
func (auth *Authorization) CheckNamespace(userName, namespace string, isAdmin, isTenantOwner, isDepartmentOwner bool) (bool, error)
check whether a user allow access specified namespace
func (*Authorization) CheckPermission ¶
check whether a user has specified uri permission
func (*Authorization) IsAdmin ¶
func (auth *Authorization) IsAdmin(userName string) (bool, error)
check whether a user is an admin
func (*Authorization) IsDepartmentOwner ¶
func (auth *Authorization) IsDepartmentOwner(userName string) (bool, error)
check whether a user is a department owner
func (*Authorization) IsNeedSkip ¶
func (auth *Authorization) IsNeedSkip(method, path string) (bool, error)
func (*Authorization) IsTenantOwner ¶
func (auth *Authorization) IsTenantOwner(userName string) (bool, error)
check whether a user is a tenant owner
func (*Authorization) IsWithGranted ¶
func (auth *Authorization) IsWithGranted(userName string) (bool, error)
check whether a user is with granted
func (*Authorization) ValidateToken ¶
func (auth *Authorization) ValidateToken(token string) (*CustomClaims, error)
type CustomClaims ¶
type CustomClaims struct { UserName string `json:"user_name"` jwt.StandardClaims }
CustomClaims
type IAuthorization ¶
type IAuthorization interface { IsNeedSkip(method, path string) (bool, error) ValidateToken(token string) (*CustomClaims, error) IsAdmin(userName string) (bool, error) IsTenantOwner(userName string) (bool, error) IsDepartmentOwner(userName string) (bool, error) IsWithGranted(userName string) (bool, error) CheckPermission(userName string, op *uri.URI) (bool, error) CheckNamespace(userName, namespace string, isAdmin, isTenantOwner, isDepartmentOwner bool) (bool, error) }
type Identification ¶
type Identification string
const ( Admin Identification = "admin" TenantOwner Identification = "tenantOwner" DepartmentOwner Identification = "tenantOwner" OrdinaryUser Identification = "ordinaryUser" )
Click to show internal directories.
Click to hide internal directories.