Documentation ¶
Index ¶
- Constants
- Variables
- func CredentialsToID(c *proto.Credentials) *string
- func ErrorToValidation(err error, status *uint32) *proto.Validation
- func GetPermissionsHash(p Permission) string
- func GetPermissionsList(super bool) map[string]Permission
- func Invalid(msg string, status *uint32) *proto.Validation
- func IsAuthMethodSupported(s string) bool
- func Valid(msg string, status *uint32) *proto.Validation
- type AuthClient
- type AuthServer
- func (s *AuthServer) IsSuper(ctx context.Context, in *proto.Credentials) (v *proto.Validation, err error)
- func (s *AuthServer) LogIn(ctx context.Context, in *proto.AskPermissions) (*proto.TokenValidation, error)
- func (s *AuthServer) LogOut(ctx context.Context, in *proto.Token) (*proto.Validation, error)
- func (s *AuthServer) SignIn(ctx context.Context, in *proto.Credentials) (*proto.Validation, error)
- func (s *AuthServer) SignOut(ctx context.Context, in *proto.Token) (*proto.Validation, error)
- func (s *AuthServer) Validate(ctx context.Context, in *proto.Token) (*proto.Validation, error)
- type AuthType
- type Auther
- type Claims
- type NoPermissionsError
- type Payload
- type Permission
- type Token
- type Tokener
Constants ¶
View Source
const ( NIL Permission = 0 SIGN_OUT = 1 << iota GRANT_SUPER = 1 << iota REVOKE_SUPER = 1 << iota NEEDLE_FOR_NEXT_PERMISSION = iota BASIC_EMAIL AuthType = iota - NEEDLE_FOR_NEXT_PERMISSION )
Variables ¶
View Source
var Permissions = map[string]Permission{ "create_bloq": CREATE_BLOQ, "update_bloq": UPDATE_BLOQ, "delete_bloq": DELETE_BLOQ, "create_offer": CREATE_OFFER, "update_offer": UPDATE_OFFER, "delete_offer": DELETE_OFFER, "create_order": CREATE_ORDER, "delete_order": DELETE_ORDER, "create_profile": CREATE_PROFILE, "read_profile": CREATE_PROFILE, "update_profile": UPDATE_PROFILE, "delete_profile": DELETE_PROFILE, "default": DEFAULT_PERMISSIONS, }
View Source
var SuperPermissions = map[string]Permission{ "create_preference": CREATE_PREFERENCE, "update_preference": UPDATE_PREFERENCE, "delete_preference": DELETE_PREFERENCE, }
Functions ¶
func CredentialsToID ¶
func CredentialsToID(c *proto.Credentials) *string
func ErrorToValidation ¶
func ErrorToValidation(err error, status *uint32) *proto.Validation
func GetPermissionsHash ¶
func GetPermissionsHash(p Permission) string
func GetPermissionsList ¶
func GetPermissionsList(super bool) map[string]Permission
func IsAuthMethodSupported ¶
Types ¶
type AuthClient ¶
type AuthClient struct { }
func (*AuthClient) Validate ¶
func (s *AuthClient) Validate(ctx context.Context, in *proto.Token) (*proto.Validation, error)
type AuthServer ¶
type AuthServer struct { proto.UnimplementedAuthServer // contains filtered or unexported fields }
func NewAuthServer ¶
func NewAuthServer(a Auther, t Tokener) *AuthServer
func (*AuthServer) IsSuper ¶
func (s *AuthServer) IsSuper(ctx context.Context, in *proto.Credentials) (v *proto.Validation, err error)
func (*AuthServer) LogIn ¶
func (s *AuthServer) LogIn(ctx context.Context, in *proto.AskPermissions) (*proto.TokenValidation, error)
func (*AuthServer) LogOut ¶
func (s *AuthServer) LogOut(ctx context.Context, in *proto.Token) (*proto.Validation, error)
func (*AuthServer) SignIn ¶
func (s *AuthServer) SignIn(ctx context.Context, in *proto.Credentials) (*proto.Validation, error)
func (*AuthServer) SignOut ¶
func (s *AuthServer) SignOut(ctx context.Context, in *proto.Token) (*proto.Validation, error)
func (*AuthServer) Validate ¶
func (s *AuthServer) Validate(ctx context.Context, in *proto.Token) (*proto.Validation, error)
type Auther ¶
type Auther interface { SignInBasic(context.Context, *proto.Credentials_Basic) error SignOutBasic(context.Context, *proto.Credentials_Basic) error CheckAccessBasic(context.Context, *proto.Credentials_Basic) error IsSuperBasic(context.Context, *proto.Credentials_Basic) (bool, error) GrantSuper(context.Context, *proto.Credentials) error RevokeSuper(context.Context, *proto.Credentials) error }
type NoPermissionsError ¶
type NoPermissionsError struct {
Permission Permission
}
func (NoPermissionsError) Error ¶
func (err NoPermissionsError) Error() string
type Payload ¶
type Payload struct { Client string `json:"client"` Permissions Permission `json:"permissions"` Super bool `json:"is_super"` Type AuthType `json:"type"` }
type Permission ¶
type Permission uint64
const ( CREATE_PREFERENCE Permission = 1 << (NEEDLE_FOR_NEXT_PERMISSION + iota) UPDATE_PREFERENCE DELETE_PREFERENCE CREATE_PROFILE READ_PROFILE UPDATE_PROFILE DELETE_PROFILE CREATE_BLOQ UPDATE_BLOQ DELETE_BLOQ CREATE_OFFER UPDATE_OFFER DELETE_OFFER CREATE_ORDER DELETE_ORDER PREFERENCE_MANAGER = CREATE_PREFERENCE | UPDATE_PREFERENCE | DELETE_PREFERENCE DEFAULT_PERMISSIONS = CREATE_PROFILE | READ_PROFILE | CREATE_BLOQ | UPDATE_BLOQ | CREATE_OFFER | CREATE_ORDER | DELETE_ORDER )
Click to show internal directories.
Click to hide internal directories.