Documentation ¶
Index ¶
- Variables
- func StoreAccountInContext(ctx context.Context, account *Account) context.Context
- type Account
- func (a *Account) AddRelationModel(relation *mapping.StructField, model mapping.Model) error
- func (a *Account) GetFieldValue(field *mapping.StructField) (interface{}, error)
- func (a *Account) GetFieldZeroValue(field *mapping.StructField) (interface{}, error)
- func (a *Account) GetFieldsAddress(field *mapping.StructField) (interface{}, error)
- func (a *Account) GetHashableFieldValue(field *mapping.StructField) (interface{}, error)
- func (a *Account) GetPrimaryKeyAddress() interface{}
- func (a *Account) GetPrimaryKeyHashableValue() interface{}
- func (a *Account) GetPrimaryKeyStringValue() (string, error)
- func (a *Account) GetPrimaryKeyValue() interface{}
- func (a *Account) GetPrimaryKeyZeroValue() interface{}
- func (a *Account) GetRelationLen(relation *mapping.StructField) (int, error)
- func (a *Account) GetRelationModelAt(relation *mapping.StructField, index int) (models mapping.Model, err error)
- func (a *Account) GetRelationModels(relation *mapping.StructField) (models []mapping.Model, err error)
- func (a *Account) InsertValidate() error
- func (a *Account) IsFieldZero(field *mapping.StructField) (bool, error)
- func (a *Account) IsPrimaryKeyZero() bool
- func (a *Account) NeuronCollectionName() string
- func (a *Account) ParseFieldsStringValue(field *mapping.StructField, value string) (interface{}, error)
- func (a *Account) SetFieldValue(field *mapping.StructField, value interface{}) (err error)
- func (a *Account) SetFieldZeroValue(field *mapping.StructField) error
- func (a *Account) SetFrom(model mapping.Model) error
- func (a *Account) SetPrimaryKeyStringValue(value string) error
- func (a *Account) SetPrimaryKeyValue(value interface{}) error
- func (a *Account) SetRelationModels(relation *mapping.StructField, models ...mapping.Model) error
- type AccountRoles
- func (a *AccountRoles) GetFieldValue(field *mapping.StructField) (interface{}, error)
- func (a *AccountRoles) GetFieldZeroValue(field *mapping.StructField) (interface{}, error)
- func (a *AccountRoles) GetFieldsAddress(field *mapping.StructField) (interface{}, error)
- func (a *AccountRoles) GetHashableFieldValue(field *mapping.StructField) (interface{}, error)
- func (a *AccountRoles) GetPrimaryKeyAddress() interface{}
- func (a *AccountRoles) GetPrimaryKeyHashableValue() interface{}
- func (a *AccountRoles) GetPrimaryKeyStringValue() (string, error)
- func (a *AccountRoles) GetPrimaryKeyValue() interface{}
- func (a *AccountRoles) GetPrimaryKeyZeroValue() interface{}
- func (a *AccountRoles) GetRelationModel(relation *mapping.StructField) (mapping.Model, error)
- func (a *AccountRoles) IsFieldZero(field *mapping.StructField) (bool, error)
- func (a *AccountRoles) IsPrimaryKeyZero() bool
- func (a *AccountRoles) NeuronCollectionName() string
- func (a *AccountRoles) ParseFieldsStringValue(field *mapping.StructField, value string) (interface{}, error)
- func (a *AccountRoles) SetFieldValue(field *mapping.StructField, value interface{}) (err error)
- func (a *AccountRoles) SetFieldZeroValue(field *mapping.StructField) error
- func (a *AccountRoles) SetFrom(model mapping.Model) error
- func (a *AccountRoles) SetPrimaryKeyStringValue(value string) error
- func (a *AccountRoles) SetPrimaryKeyValue(value interface{}) error
- func (a *AccountRoles) SetRelationModel(relation *mapping.StructField, model mapping.Model) error
- type Authenticator
- func (a *Authenticator) Authenticate(ctx context.Context, email, password string) (accountID interface{}, err error)
- func (a *Authenticator) Initialize(c *controller.Controller) error
- func (a *Authenticator) InspectToken(token string) (interface{}, error)
- func (a *Authenticator) RefreshToken(ctx context.Context, refreshToken string) (auth.Token, error)
- func (a *Authenticator) Token(ctx context.Context, options ...auth.TokenOption) (auth.Token, error)
- type AuthorizeScope
- func (a *AuthorizeScope) AddRelationModel(relation *mapping.StructField, model mapping.Model) error
- func (a *AuthorizeScope) GetFieldValue(field *mapping.StructField) (interface{}, error)
- func (a *AuthorizeScope) GetFieldZeroValue(field *mapping.StructField) (interface{}, error)
- func (a *AuthorizeScope) GetFieldsAddress(field *mapping.StructField) (interface{}, error)
- func (a *AuthorizeScope) GetHashableFieldValue(field *mapping.StructField) (interface{}, error)
- func (a *AuthorizeScope) GetPrimaryKeyAddress() interface{}
- func (a *AuthorizeScope) GetPrimaryKeyHashableValue() interface{}
- func (a *AuthorizeScope) GetPrimaryKeyStringValue() (string, error)
- func (a *AuthorizeScope) GetPrimaryKeyValue() interface{}
- func (a *AuthorizeScope) GetPrimaryKeyZeroValue() interface{}
- func (a *AuthorizeScope) GetRelationLen(relation *mapping.StructField) (int, error)
- func (a *AuthorizeScope) GetRelationModelAt(relation *mapping.StructField, index int) (models mapping.Model, err error)
- func (a *AuthorizeScope) GetRelationModels(relation *mapping.StructField) (models []mapping.Model, err error)
- func (a *AuthorizeScope) IsFieldZero(field *mapping.StructField) (bool, error)
- func (a *AuthorizeScope) IsPrimaryKeyZero() bool
- func (a *AuthorizeScope) NeuronCollectionName() string
- func (a *AuthorizeScope) ParseFieldsStringValue(field *mapping.StructField, value string) (interface{}, error)
- func (a *AuthorizeScope) SetFieldValue(field *mapping.StructField, value interface{}) (err error)
- func (a *AuthorizeScope) SetFieldZeroValue(field *mapping.StructField) error
- func (a *AuthorizeScope) SetFrom(model mapping.Model) error
- func (a *AuthorizeScope) SetPrimaryKeyStringValue(value string) error
- func (a *AuthorizeScope) SetPrimaryKeyValue(value interface{}) error
- func (a *AuthorizeScope) SetRelationModels(relation *mapping.StructField, models ...mapping.Model) error
- type Authorizer
- func (a *Authorizer) AddRole(ctx context.Context, db database.DB, accountID interface{}, role string) error
- func (a *Authorizer) Authorize(ctx context.Context, accountID interface{}, scopes ...string) error
- func (a *Authorizer) ClearRoles(ctx context.Context, db database.DB, accountID interface{}) error
- func (a *Authorizer) CreateRole(ctx context.Context, role, description string) (auth.Role, error)
- func (a *Authorizer) DeleteRole(ctx context.Context, roleName string) error
- func (a *Authorizer) FindRoles(ctx context.Context, options ...auth.RoleFindOption) ([]auth.Role, error)
- func (a *Authorizer) GetRoles(ctx context.Context, accountID interface{}) ([]auth.Role, error)
- func (a *Authorizer) GrantRole(ctx context.Context, db database.DB, role, scope string) error
- func (a *Authorizer) Initialize(c *controller.Controller) error
- func (a *Authorizer) RemoveRole(ctx context.Context, db database.DB, accountID interface{}, role string) error
- func (a *Authorizer) RevokeRole(ctx context.Context, db database.DB, role, scope string) error
- func (a *Authorizer) SetRoles(ctx context.Context, db database.DB, accountID interface{}, roles ...string) error
- type Claims
- type Role
- func (r *Role) AddRelationModel(relation *mapping.StructField, model mapping.Model) error
- func (r *Role) GetFieldValue(field *mapping.StructField) (interface{}, error)
- func (r *Role) GetFieldZeroValue(field *mapping.StructField) (interface{}, error)
- func (r *Role) GetFieldsAddress(field *mapping.StructField) (interface{}, error)
- func (r *Role) GetHashableFieldValue(field *mapping.StructField) (interface{}, error)
- func (r *Role) GetPrimaryKeyAddress() interface{}
- func (r *Role) GetPrimaryKeyHashableValue() interface{}
- func (r *Role) GetPrimaryKeyStringValue() (string, error)
- func (r *Role) GetPrimaryKeyValue() interface{}
- func (r *Role) GetPrimaryKeyZeroValue() interface{}
- func (r *Role) GetRelationLen(relation *mapping.StructField) (int, error)
- func (r *Role) GetRelationModelAt(relation *mapping.StructField, index int) (models mapping.Model, err error)
- func (r *Role) GetRelationModels(relation *mapping.StructField) (models []mapping.Model, err error)
- func (r *Role) IsFieldZero(field *mapping.StructField) (bool, error)
- func (r *Role) IsPrimaryKeyZero() bool
- func (r *Role) NeuronCollectionName() string
- func (r *Role) ParseFieldsStringValue(field *mapping.StructField, value string) (interface{}, error)
- func (r *Role) RoleName() string
- func (r *Role) SetFieldValue(field *mapping.StructField, value interface{}) (err error)
- func (r *Role) SetFieldZeroValue(field *mapping.StructField) error
- func (r *Role) SetFrom(model mapping.Model) error
- func (r *Role) SetPrimaryKeyStringValue(value string) error
- func (r *Role) SetPrimaryKeyValue(value interface{}) error
- func (r *Role) SetRelationModels(relation *mapping.StructField, models ...mapping.Model) error
- type RoleScopes
- func (r *RoleScopes) GetFieldValue(field *mapping.StructField) (interface{}, error)
- func (r *RoleScopes) GetFieldZeroValue(field *mapping.StructField) (interface{}, error)
- func (r *RoleScopes) GetFieldsAddress(field *mapping.StructField) (interface{}, error)
- func (r *RoleScopes) GetHashableFieldValue(field *mapping.StructField) (interface{}, error)
- func (r *RoleScopes) GetPrimaryKeyAddress() interface{}
- func (r *RoleScopes) GetPrimaryKeyHashableValue() interface{}
- func (r *RoleScopes) GetPrimaryKeyStringValue() (string, error)
- func (r *RoleScopes) GetPrimaryKeyValue() interface{}
- func (r *RoleScopes) GetPrimaryKeyZeroValue() interface{}
- func (r *RoleScopes) GetRelationModel(relation *mapping.StructField) (mapping.Model, error)
- func (r *RoleScopes) IsFieldZero(field *mapping.StructField) (bool, error)
- func (r *RoleScopes) IsPrimaryKeyZero() bool
- func (r *RoleScopes) NeuronCollectionName() string
- func (r *RoleScopes) ParseFieldsStringValue(field *mapping.StructField, value string) (interface{}, error)
- func (r *RoleScopes) SetFieldValue(field *mapping.StructField, value interface{}) (err error)
- func (r *RoleScopes) SetFieldZeroValue(field *mapping.StructField) error
- func (r *RoleScopes) SetFrom(model mapping.Model) error
- func (r *RoleScopes) SetPrimaryKeyStringValue(value string) error
- func (r *RoleScopes) SetPrimaryKeyValue(value interface{}) error
- func (r *RoleScopes) SetRelationModel(relation *mapping.StructField, model mapping.Model) error
Constants ¶
This section is empty.
Variables ¶
var NRN_AccountRoles = &_AccountRoles{}
NRN_AccountRoles is the collection used to query AccountRoles model.
var NRN_Accounts = &_Accounts{}
NRN_Accounts is the collection used to query Account model.
var NRN_AuthorizeScopes = &_AuthorizeScopes{}
NRN_AuthorizeScopes is the collection used to query AuthorizeScope model.
var NRN_RoleScopes = &_RoleScopes{}
NRN_RoleScopes is the collection used to query RoleScopes model.
var NRN_Roles = &_Roles{}
NRN_Roles is the collection used to query Role model.
var Neuron_Collections = []database.Collection{ NRN_Accounts, NRN_AccountRoles, NRN_AuthorizeScopes, NRN_Roles, NRN_RoleScopes, }
Neuron_Collections stores all generated collections.
var Neuron_Models = []mapping.Model{ &Account{}, &AccountRoles{}, &AuthorizeScope{}, &Role{}, &RoleScopes{}, }
Neuron_Models stores all generated models in this package.
Functions ¶
Types ¶
type Account ¶
type Account struct { ID uuid.UUID // Timestamps for the account. CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time // Email is the unique Email string `db:"unique,notnull"` // HashPassword is the hash obtained by hashing the password. HashPassword []byte `codec:"-"` // Password is the user provided password. Password string `db:"-"` Roles []*Role }
Account is the basic model used for authentication and authorization.
func CtxGetAccount ¶
CtxGetAccount gets account from provided context.
func (*Account) AddRelationModel ¶
AddRelationModel implements mapping.MultiRelationer interface.
func (*Account) GetFieldValue ¶
func (a *Account) GetFieldValue(field *mapping.StructField) (interface{}, error)
GetFieldValue implements mapping.Fielder interface.
func (*Account) GetFieldZeroValue ¶
func (a *Account) GetFieldZeroValue(field *mapping.StructField) (interface{}, error)
GetFieldZeroValue implements mapping.Fielder interface.s
func (*Account) GetFieldsAddress ¶
func (a *Account) GetFieldsAddress(field *mapping.StructField) (interface{}, error)
GetFieldsAddress gets the address of provided 'field'.
func (*Account) GetHashableFieldValue ¶
func (a *Account) GetHashableFieldValue(field *mapping.StructField) (interface{}, error)
GetHashableFieldValue implements mapping.Fielder interface.
func (*Account) GetPrimaryKeyAddress ¶
func (a *Account) GetPrimaryKeyAddress() interface{}
GetPrimaryKeyAddress implements mapping.Model interface method.
func (*Account) GetPrimaryKeyHashableValue ¶
func (a *Account) GetPrimaryKeyHashableValue() interface{}
GetPrimaryKeyHashableValue implements mapping.Model interface method.
func (*Account) GetPrimaryKeyStringValue ¶
GetPrimaryKeyStringValue implements mapping.Model interface method.
func (*Account) GetPrimaryKeyValue ¶
func (a *Account) GetPrimaryKeyValue() interface{}
GetPrimaryKeyValue implements mapping.Model interface method.
func (*Account) GetPrimaryKeyZeroValue ¶
func (a *Account) GetPrimaryKeyZeroValue() interface{}
GetPrimaryKeyZeroValue implements mapping.Model interface method.
func (*Account) GetRelationLen ¶
func (a *Account) GetRelationLen(relation *mapping.StructField) (int, error)
GetRelationLen implements mapping.MultiRelationer interface.
func (*Account) GetRelationModelAt ¶
func (a *Account) GetRelationModelAt(relation *mapping.StructField, index int) (models mapping.Model, err error)
GetRelationModelAt implements mapping.MultiRelationer interface.
func (*Account) GetRelationModels ¶
func (a *Account) GetRelationModels(relation *mapping.StructField) (models []mapping.Model, err error)
GetRelationModels implements mapping.MultiRelationer interface.
func (*Account) InsertValidate ¶
Validate does the validation of the input account. It checks the email address as well as the
func (*Account) IsFieldZero ¶
func (a *Account) IsFieldZero(field *mapping.StructField) (bool, error)
IsFieldZero implements mapping.Fielder interface.
func (*Account) IsPrimaryKeyZero ¶
IsPrimaryKeyZero implements mapping.Model interface method.
func (*Account) NeuronCollectionName ¶
NeuronCollectionName implements mapping.Model interface method. Returns the name of the collection for the 'Account'.
func (*Account) ParseFieldsStringValue ¶
func (a *Account) ParseFieldsStringValue(field *mapping.StructField, value string) (interface{}, error)
SetPrimaryKeyStringValue implements mapping.Model interface method.
func (*Account) SetFieldValue ¶
func (a *Account) SetFieldValue(field *mapping.StructField, value interface{}) (err error)
SetFieldValue implements mapping.Fielder interface.
func (*Account) SetFieldZeroValue ¶
func (a *Account) SetFieldZeroValue(field *mapping.StructField) error
SetFieldZeroValue implements mapping.Fielder interface.s
func (*Account) SetPrimaryKeyStringValue ¶
SetPrimaryKeyStringValue implements mapping.Model interface method.
func (*Account) SetPrimaryKeyValue ¶
SetPrimaryKey implements mapping.Model interface method.
func (*Account) SetRelationModels ¶
SetRelationModels implements mapping.MultiRelationer interface.
type AccountRoles ¶
type AccountRoles struct { ID uuid.UUID // Timestamps CreatedAt time.Time DeletedAt *time.Time // Join Model relations. Role *Role RoleID uint Account *Account AccountID uuid.UUID }
AccountRoles is the join model for the account roles many-to-many relationship.
func (*AccountRoles) GetFieldValue ¶
func (a *AccountRoles) GetFieldValue(field *mapping.StructField) (interface{}, error)
GetFieldValue implements mapping.Fielder interface.
func (*AccountRoles) GetFieldZeroValue ¶
func (a *AccountRoles) GetFieldZeroValue(field *mapping.StructField) (interface{}, error)
GetFieldZeroValue implements mapping.Fielder interface.s
func (*AccountRoles) GetFieldsAddress ¶
func (a *AccountRoles) GetFieldsAddress(field *mapping.StructField) (interface{}, error)
GetFieldsAddress gets the address of provided 'field'.
func (*AccountRoles) GetHashableFieldValue ¶
func (a *AccountRoles) GetHashableFieldValue(field *mapping.StructField) (interface{}, error)
GetHashableFieldValue implements mapping.Fielder interface.
func (*AccountRoles) GetPrimaryKeyAddress ¶
func (a *AccountRoles) GetPrimaryKeyAddress() interface{}
GetPrimaryKeyAddress implements mapping.Model interface method.
func (*AccountRoles) GetPrimaryKeyHashableValue ¶
func (a *AccountRoles) GetPrimaryKeyHashableValue() interface{}
GetPrimaryKeyHashableValue implements mapping.Model interface method.
func (*AccountRoles) GetPrimaryKeyStringValue ¶
func (a *AccountRoles) GetPrimaryKeyStringValue() (string, error)
GetPrimaryKeyStringValue implements mapping.Model interface method.
func (*AccountRoles) GetPrimaryKeyValue ¶
func (a *AccountRoles) GetPrimaryKeyValue() interface{}
GetPrimaryKeyValue implements mapping.Model interface method.
func (*AccountRoles) GetPrimaryKeyZeroValue ¶
func (a *AccountRoles) GetPrimaryKeyZeroValue() interface{}
GetPrimaryKeyZeroValue implements mapping.Model interface method.
func (*AccountRoles) GetRelationModel ¶
func (a *AccountRoles) GetRelationModel(relation *mapping.StructField) (mapping.Model, error)
GetRelationModel implements mapping.SingleRelationer interface.
func (*AccountRoles) IsFieldZero ¶
func (a *AccountRoles) IsFieldZero(field *mapping.StructField) (bool, error)
IsFieldZero implements mapping.Fielder interface.
func (*AccountRoles) IsPrimaryKeyZero ¶
func (a *AccountRoles) IsPrimaryKeyZero() bool
IsPrimaryKeyZero implements mapping.Model interface method.
func (*AccountRoles) NeuronCollectionName ¶
func (a *AccountRoles) NeuronCollectionName() string
NeuronCollectionName implements mapping.Model interface method. Returns the name of the collection for the 'AccountRoles'.
func (*AccountRoles) ParseFieldsStringValue ¶
func (a *AccountRoles) ParseFieldsStringValue(field *mapping.StructField, value string) (interface{}, error)
SetPrimaryKeyStringValue implements mapping.Model interface method.
func (*AccountRoles) SetFieldValue ¶
func (a *AccountRoles) SetFieldValue(field *mapping.StructField, value interface{}) (err error)
SetFieldValue implements mapping.Fielder interface.
func (*AccountRoles) SetFieldZeroValue ¶
func (a *AccountRoles) SetFieldZeroValue(field *mapping.StructField) error
SetFieldZeroValue implements mapping.Fielder interface.s
func (*AccountRoles) SetFrom ¶
func (a *AccountRoles) SetFrom(model mapping.Model) error
SetFrom implements FromSetter interface.
func (*AccountRoles) SetPrimaryKeyStringValue ¶
func (a *AccountRoles) SetPrimaryKeyStringValue(value string) error
SetPrimaryKeyStringValue implements mapping.Model interface method.
func (*AccountRoles) SetPrimaryKeyValue ¶
func (a *AccountRoles) SetPrimaryKeyValue(value interface{}) error
SetPrimaryKey implements mapping.Model interface method.
func (*AccountRoles) SetRelationModel ¶
func (a *AccountRoles) SetRelationModel(relation *mapping.StructField, model mapping.Model) error
SetRelationModel implements mapping.SingleRelationer interface.
type Authenticator ¶
type Authenticator struct { Options auth.Options SigningMethod jwt.SigningMethod Parser jwt.Parser // contains filtered or unexported fields }
Authenticator is the structure that implements auth.Authenticator as well as auth.Tokener interfaces. It is used to provide full authentication process for the
func New ¶
func New(options ...auth.Option) (*Authenticator, error)
New creates new validation error.
func (*Authenticator) Authenticate ¶
func (a *Authenticator) Authenticate(ctx context.Context, email, password string) (accountID interface{}, err error)
Authenticate implements auth.Authenticator interface. Does the authentication using bcrypt algorihtm. Returns accountID as uuid.UUID.
func (*Authenticator) Initialize ¶
func (a *Authenticator) Initialize(c *controller.Controller) error
Initialize implements initializer interface.
func (*Authenticator) InspectToken ¶
func (a *Authenticator) InspectToken(token string) (interface{}, error)
InspectToken inspects given token string and returns provided claims.
func (*Authenticator) RefreshToken ¶
RefreshToken generates new auth.Token based on provided refresh token.
func (*Authenticator) Token ¶
func (a *Authenticator) Token(ctx context.Context, options ...auth.TokenOption) (auth.Token, error)
Token creates an auth.Token from provided options.
type AuthorizeScope ¶
type AuthorizeScope struct { ID uint CreatedAt time.Time DeletedAt *time.Time Name string `db:",index=unique"` Description string `json:"omitempty"` Roles []*Role `neuron:"many2many=RoleScopes;foreign=ScopeID"` }
AuthorizeScope is a scope used for the authorization process.
func (*AuthorizeScope) AddRelationModel ¶
func (a *AuthorizeScope) AddRelationModel(relation *mapping.StructField, model mapping.Model) error
AddRelationModel implements mapping.MultiRelationer interface.
func (*AuthorizeScope) GetFieldValue ¶
func (a *AuthorizeScope) GetFieldValue(field *mapping.StructField) (interface{}, error)
GetFieldValue implements mapping.Fielder interface.
func (*AuthorizeScope) GetFieldZeroValue ¶
func (a *AuthorizeScope) GetFieldZeroValue(field *mapping.StructField) (interface{}, error)
GetFieldZeroValue implements mapping.Fielder interface.s
func (*AuthorizeScope) GetFieldsAddress ¶
func (a *AuthorizeScope) GetFieldsAddress(field *mapping.StructField) (interface{}, error)
GetFieldsAddress gets the address of provided 'field'.
func (*AuthorizeScope) GetHashableFieldValue ¶
func (a *AuthorizeScope) GetHashableFieldValue(field *mapping.StructField) (interface{}, error)
GetHashableFieldValue implements mapping.Fielder interface.
func (*AuthorizeScope) GetPrimaryKeyAddress ¶
func (a *AuthorizeScope) GetPrimaryKeyAddress() interface{}
GetPrimaryKeyAddress implements mapping.Model interface method.
func (*AuthorizeScope) GetPrimaryKeyHashableValue ¶
func (a *AuthorizeScope) GetPrimaryKeyHashableValue() interface{}
GetPrimaryKeyHashableValue implements mapping.Model interface method.
func (*AuthorizeScope) GetPrimaryKeyStringValue ¶
func (a *AuthorizeScope) GetPrimaryKeyStringValue() (string, error)
GetPrimaryKeyStringValue implements mapping.Model interface method.
func (*AuthorizeScope) GetPrimaryKeyValue ¶
func (a *AuthorizeScope) GetPrimaryKeyValue() interface{}
GetPrimaryKeyValue implements mapping.Model interface method.
func (*AuthorizeScope) GetPrimaryKeyZeroValue ¶
func (a *AuthorizeScope) GetPrimaryKeyZeroValue() interface{}
GetPrimaryKeyZeroValue implements mapping.Model interface method.
func (*AuthorizeScope) GetRelationLen ¶
func (a *AuthorizeScope) GetRelationLen(relation *mapping.StructField) (int, error)
GetRelationLen implements mapping.MultiRelationer interface.
func (*AuthorizeScope) GetRelationModelAt ¶
func (a *AuthorizeScope) GetRelationModelAt(relation *mapping.StructField, index int) (models mapping.Model, err error)
GetRelationModelAt implements mapping.MultiRelationer interface.
func (*AuthorizeScope) GetRelationModels ¶
func (a *AuthorizeScope) GetRelationModels(relation *mapping.StructField) (models []mapping.Model, err error)
GetRelationModels implements mapping.MultiRelationer interface.
func (*AuthorizeScope) IsFieldZero ¶
func (a *AuthorizeScope) IsFieldZero(field *mapping.StructField) (bool, error)
IsFieldZero implements mapping.Fielder interface.
func (*AuthorizeScope) IsPrimaryKeyZero ¶
func (a *AuthorizeScope) IsPrimaryKeyZero() bool
IsPrimaryKeyZero implements mapping.Model interface method.
func (*AuthorizeScope) NeuronCollectionName ¶
func (a *AuthorizeScope) NeuronCollectionName() string
NeuronCollectionName implements mapping.Model interface method. Returns the name of the collection for the 'AuthorizeScope'.
func (*AuthorizeScope) ParseFieldsStringValue ¶
func (a *AuthorizeScope) ParseFieldsStringValue(field *mapping.StructField, value string) (interface{}, error)
SetPrimaryKeyStringValue implements mapping.Model interface method.
func (*AuthorizeScope) SetFieldValue ¶
func (a *AuthorizeScope) SetFieldValue(field *mapping.StructField, value interface{}) (err error)
SetFieldValue implements mapping.Fielder interface.
func (*AuthorizeScope) SetFieldZeroValue ¶
func (a *AuthorizeScope) SetFieldZeroValue(field *mapping.StructField) error
SetFieldZeroValue implements mapping.Fielder interface.s
func (*AuthorizeScope) SetFrom ¶
func (a *AuthorizeScope) SetFrom(model mapping.Model) error
SetFrom implements FromSetter interface.
func (*AuthorizeScope) SetPrimaryKeyStringValue ¶
func (a *AuthorizeScope) SetPrimaryKeyStringValue(value string) error
SetPrimaryKeyStringValue implements mapping.Model interface method.
func (*AuthorizeScope) SetPrimaryKeyValue ¶
func (a *AuthorizeScope) SetPrimaryKeyValue(value interface{}) error
SetPrimaryKey implements mapping.Model interface method.
func (*AuthorizeScope) SetRelationModels ¶
func (a *AuthorizeScope) SetRelationModels(relation *mapping.StructField, models ...mapping.Model) error
SetRelationModels implements mapping.MultiRelationer interface.
type Authorizer ¶
Authorizer is an implementation of the auth.Authorizer interface. It also implements full auth.RoleAuthorizer.
func (*Authorizer) AddRole ¶
func (a *Authorizer) AddRole(ctx context.Context, db database.DB, accountID interface{}, role string) error
AddRole implements RoleAuthorizer interface.
func (*Authorizer) Authorize ¶
func (a *Authorizer) Authorize(ctx context.Context, accountID interface{}, scopes ...string) error
Authorize checks if the account with provided ID is allowed to use the 'resource'. Provided account must be authorized for ALL provided scopes.
func (*Authorizer) ClearRoles ¶
ClearRoles implements RoleAuthorizer interface.
func (*Authorizer) CreateRole ¶
CreateRole creates a new 'role' with optional 'description'.
func (*Authorizer) DeleteRole ¶
func (a *Authorizer) DeleteRole(ctx context.Context, roleName string) error
DeleteRole implements auth.RoleAuthorizer interface.
func (*Authorizer) FindRoles ¶
func (a *Authorizer) FindRoles(ctx context.Context, options ...auth.RoleFindOption) ([]auth.Role, error)
func (*Authorizer) Initialize ¶
func (a *Authorizer) Initialize(c *controller.Controller) error
Initialize implements core.Initializer interface.
func (*Authorizer) RemoveRole ¶
func (a *Authorizer) RemoveRole(ctx context.Context, db database.DB, accountID interface{}, role string) error
RemoveRole implements RoleAuthorizer interface.
func (*Authorizer) RevokeRole ¶
type Claims ¶
type Claims struct { AccountID uuid.UUID Email string CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time Roles []string jwt.StandardClaims }
Claims is the jwt claims implementation that keeps the accountID stored in given token.
type Role ¶
type Role struct { ID uint // Timestamps CreatedAt time.Time UpdatedAt *time.Time DeletedAt *time.Time // Attributes Name string `db:"index=unique"` Description string // Many2Many relations Accounts []*Account Scopes []*AuthorizeScope `neuron:"many2many=RoleScopes;foreign=,ScopeID"` }
Role is a simple role model for the RBAC authorization. It contains a many2many relation to Accounts.
func (*Role) AddRelationModel ¶
AddRelationModel implements mapping.MultiRelationer interface.
func (*Role) GetFieldValue ¶
func (r *Role) GetFieldValue(field *mapping.StructField) (interface{}, error)
GetFieldValue implements mapping.Fielder interface.
func (*Role) GetFieldZeroValue ¶
func (r *Role) GetFieldZeroValue(field *mapping.StructField) (interface{}, error)
GetFieldZeroValue implements mapping.Fielder interface.s
func (*Role) GetFieldsAddress ¶
func (r *Role) GetFieldsAddress(field *mapping.StructField) (interface{}, error)
GetFieldsAddress gets the address of provided 'field'.
func (*Role) GetHashableFieldValue ¶
func (r *Role) GetHashableFieldValue(field *mapping.StructField) (interface{}, error)
GetHashableFieldValue implements mapping.Fielder interface.
func (*Role) GetPrimaryKeyAddress ¶
func (r *Role) GetPrimaryKeyAddress() interface{}
GetPrimaryKeyAddress implements mapping.Model interface method.
func (*Role) GetPrimaryKeyHashableValue ¶
func (r *Role) GetPrimaryKeyHashableValue() interface{}
GetPrimaryKeyHashableValue implements mapping.Model interface method.
func (*Role) GetPrimaryKeyStringValue ¶
GetPrimaryKeyStringValue implements mapping.Model interface method.
func (*Role) GetPrimaryKeyValue ¶
func (r *Role) GetPrimaryKeyValue() interface{}
GetPrimaryKeyValue implements mapping.Model interface method.
func (*Role) GetPrimaryKeyZeroValue ¶
func (r *Role) GetPrimaryKeyZeroValue() interface{}
GetPrimaryKeyZeroValue implements mapping.Model interface method.
func (*Role) GetRelationLen ¶
func (r *Role) GetRelationLen(relation *mapping.StructField) (int, error)
GetRelationLen implements mapping.MultiRelationer interface.
func (*Role) GetRelationModelAt ¶
func (r *Role) GetRelationModelAt(relation *mapping.StructField, index int) (models mapping.Model, err error)
GetRelationModelAt implements mapping.MultiRelationer interface.
func (*Role) GetRelationModels ¶
GetRelationModels implements mapping.MultiRelationer interface.
func (*Role) IsFieldZero ¶
func (r *Role) IsFieldZero(field *mapping.StructField) (bool, error)
IsFieldZero implements mapping.Fielder interface.
func (*Role) IsPrimaryKeyZero ¶
IsPrimaryKeyZero implements mapping.Model interface method.
func (*Role) NeuronCollectionName ¶
NeuronCollectionName implements mapping.Model interface method. Returns the name of the collection for the 'Role'.
func (*Role) ParseFieldsStringValue ¶
func (r *Role) ParseFieldsStringValue(field *mapping.StructField, value string) (interface{}, error)
SetPrimaryKeyStringValue implements mapping.Model interface method.
func (*Role) SetFieldValue ¶
func (r *Role) SetFieldValue(field *mapping.StructField, value interface{}) (err error)
SetFieldValue implements mapping.Fielder interface.
func (*Role) SetFieldZeroValue ¶
func (r *Role) SetFieldZeroValue(field *mapping.StructField) error
SetFieldZeroValue implements mapping.Fielder interface.s
func (*Role) SetPrimaryKeyStringValue ¶
SetPrimaryKeyStringValue implements mapping.Model interface method.
func (*Role) SetPrimaryKeyValue ¶
SetPrimaryKey implements mapping.Model interface method.
func (*Role) SetRelationModels ¶
SetRelationModels implements mapping.MultiRelationer interface.
type RoleScopes ¶
type RoleScopes struct { ID uint64 CreatedAt time.Time DeletedAt *time.Time Scope *AuthorizeScope ScopeID uint `db:",index=unique_roles,unique"` Role *Role RoleID uint `db:",index=unique_roles,unique"` }
RoleScopes is a join model for the mapping roles to scopes.
func (*RoleScopes) GetFieldValue ¶
func (r *RoleScopes) GetFieldValue(field *mapping.StructField) (interface{}, error)
GetFieldValue implements mapping.Fielder interface.
func (*RoleScopes) GetFieldZeroValue ¶
func (r *RoleScopes) GetFieldZeroValue(field *mapping.StructField) (interface{}, error)
GetFieldZeroValue implements mapping.Fielder interface.s
func (*RoleScopes) GetFieldsAddress ¶
func (r *RoleScopes) GetFieldsAddress(field *mapping.StructField) (interface{}, error)
GetFieldsAddress gets the address of provided 'field'.
func (*RoleScopes) GetHashableFieldValue ¶
func (r *RoleScopes) GetHashableFieldValue(field *mapping.StructField) (interface{}, error)
GetHashableFieldValue implements mapping.Fielder interface.
func (*RoleScopes) GetPrimaryKeyAddress ¶
func (r *RoleScopes) GetPrimaryKeyAddress() interface{}
GetPrimaryKeyAddress implements mapping.Model interface method.
func (*RoleScopes) GetPrimaryKeyHashableValue ¶
func (r *RoleScopes) GetPrimaryKeyHashableValue() interface{}
GetPrimaryKeyHashableValue implements mapping.Model interface method.
func (*RoleScopes) GetPrimaryKeyStringValue ¶
func (r *RoleScopes) GetPrimaryKeyStringValue() (string, error)
GetPrimaryKeyStringValue implements mapping.Model interface method.
func (*RoleScopes) GetPrimaryKeyValue ¶
func (r *RoleScopes) GetPrimaryKeyValue() interface{}
GetPrimaryKeyValue implements mapping.Model interface method.
func (*RoleScopes) GetPrimaryKeyZeroValue ¶
func (r *RoleScopes) GetPrimaryKeyZeroValue() interface{}
GetPrimaryKeyZeroValue implements mapping.Model interface method.
func (*RoleScopes) GetRelationModel ¶
func (r *RoleScopes) GetRelationModel(relation *mapping.StructField) (mapping.Model, error)
GetRelationModel implements mapping.SingleRelationer interface.
func (*RoleScopes) IsFieldZero ¶
func (r *RoleScopes) IsFieldZero(field *mapping.StructField) (bool, error)
IsFieldZero implements mapping.Fielder interface.
func (*RoleScopes) IsPrimaryKeyZero ¶
func (r *RoleScopes) IsPrimaryKeyZero() bool
IsPrimaryKeyZero implements mapping.Model interface method.
func (*RoleScopes) NeuronCollectionName ¶
func (r *RoleScopes) NeuronCollectionName() string
NeuronCollectionName implements mapping.Model interface method. Returns the name of the collection for the 'RoleScopes'.
func (*RoleScopes) ParseFieldsStringValue ¶
func (r *RoleScopes) ParseFieldsStringValue(field *mapping.StructField, value string) (interface{}, error)
SetPrimaryKeyStringValue implements mapping.Model interface method.
func (*RoleScopes) SetFieldValue ¶
func (r *RoleScopes) SetFieldValue(field *mapping.StructField, value interface{}) (err error)
SetFieldValue implements mapping.Fielder interface.
func (*RoleScopes) SetFieldZeroValue ¶
func (r *RoleScopes) SetFieldZeroValue(field *mapping.StructField) error
SetFieldZeroValue implements mapping.Fielder interface.s
func (*RoleScopes) SetFrom ¶
func (r *RoleScopes) SetFrom(model mapping.Model) error
SetFrom implements FromSetter interface.
func (*RoleScopes) SetPrimaryKeyStringValue ¶
func (r *RoleScopes) SetPrimaryKeyStringValue(value string) error
SetPrimaryKeyStringValue implements mapping.Model interface method.
func (*RoleScopes) SetPrimaryKeyValue ¶
func (r *RoleScopes) SetPrimaryKeyValue(value interface{}) error
SetPrimaryKey implements mapping.Model interface method.
func (*RoleScopes) SetRelationModel ¶
func (r *RoleScopes) SetRelationModel(relation *mapping.StructField, model mapping.Model) error
SetRelationModel implements mapping.SingleRelationer interface.