Documentation ¶
Index ¶
Constants ¶
const ClaimsAttribute = "JWTClaims"
ClaimsAttribute is the key for JWT claims stored in the request
Variables ¶
This section is empty.
Functions ¶
func RetrieveJWTClaims ¶
func RetrieveJWTClaims(request *restful.Request) *iam.JWTClaims
RetrieveJWTClaims is a convenience function to retrieve JWT claims from restful.Request. Warning: the claims can be nil if the request wasn't filtered through Auth()
Types ¶
type Filter ¶
type Filter struct {
// contains filtered or unexported fields
}
Filter handles auth using filter
func (*Filter) Auth ¶
func (filter *Filter) Auth(opts ...FilterOption) restful.FilterFunction
Auth returns a filter that filters request with valid access token in auth header The token's claims will be passed in the request.attributes["JWTClaims"] = *iam.JWTClaims{} This filter is expandable through FilterOption parameter Example: iam.Auth(
WithValidUser(), WithPermission("ADMIN"),
)
type FilterOption ¶
type FilterOption func(req *restful.Request, iamClient iam.Client, claims *iam.JWTClaims) error
FilterOption extends the basic auth filter functionality
func WithPermission ¶
func WithPermission(permission *iam.Permission) FilterOption
WithPermission filters request with valid permission only
func WithRole ¶
func WithRole(role string) FilterOption
WithRole filters request with valid role only
func WithValidUser ¶
func WithValidUser() FilterOption
WithValidUser filters request with valid user only
func WithVerifiedEmail ¶
func WithVerifiedEmail() FilterOption
WithVerifiedEmail filters request from a user with verified email address only