Documentation ¶
Overview ¶
Package rbacframe help other component which want to use servicecomb rbac system
Index ¶
- Constants
- Variables
- func Add2WhiteAPIList(path ...string)
- func Authenticate(tokenStr string, pub *rsa.PublicKey) (interface{}, error)
- func FromContext(ctx context.Context) interface{}
- func GetResource(api string) string
- func MapResource(api, resource string)
- func MustAuth(pattern string) bool
- func NewContext(ctx context.Context, claims interface{}) context.Context
- func RoleFromContext(ctx context.Context) (string, error)
- type Account
- type AccountResponse
- type Permission
- type Role
- type Token
Constants ¶
View Source
const ( ClaimsUser = "account" ClaimsRole = "role" )
View Source
const (
RoleAdmin = "admin"
)
Variables ¶
View Source
var ( ErrInvalidHeader = errors.New("invalid auth header") ErrNoHeader = errors.New("should provide Authorization header") ErrInvalidCtx = errors.New("invalid context") ErrConvertErr = errors.New(MsgConvertErr) MsgConvertErr = "type convert error" )
Functions ¶
func Add2WhiteAPIList ¶
func Add2WhiteAPIList(path ...string)
func Authenticate ¶
Authenticate parse a token to claims
func FromContext ¶
FromContext returns the account value stored in ctx, if any.
func GetResource ¶
func MapResource ¶
func MapResource(api, resource string)
MapResource save the mapping from api to resource
func NewContext ¶
NewContext returns a new Context that carries value claims.
Types ¶
type Account ¶
type Account struct { ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` Password string `json:"password,omitempty"` Role string `json:"role,omitempty"` TokenExpirationTime string `json:"tokenExpirationTime,omitempty"` CurrentPassword string `json:"currentPassword,omitempty"` Status string `json:"status,omitempty"` }
type AccountResponse ¶
type Permission ¶
type Role ¶
type Role struct { Project []string Permissions map[string]*Permission }
Click to show internal directories.
Click to hide internal directories.