Documentation
¶
Overview ¶
Package hiro is a foundational component for Model Rocket platform API services
Index ¶
- Constants
- Variables
- func ErrTxCommit(err error) error
- func IsTransaction(db DB) bool
- func ParseSQLError(err error) error
- func RegisterOption(name string, val interface{}) error
- func RegisterOptionUpdateHandler(name string, handler OptionUpdateHandler)
- func Routes() []api.Route
- func TokenSecret(s *Secret) (oauth.TokenSecret, error)
- type AccessToken
- type Application
- type ApplicationController
- type ApplicationCountRoute
- type ApplicationCreateInput
- type ApplicationCreateRoute
- type ApplicationDeleteInput
- type ApplicationDeleteRoute
- type ApplicationGetInput
- type ApplicationGetRoute
- type ApplicationListInput
- type ApplicationListRoute
- type ApplicationType
- type ApplicationUpdateInput
- type ApplicationUpdateRoute
- type Asset
- type AssetController
- type AssetCountRoute
- type AssetCreateInput
- type AssetCreateRoute
- type AssetDeleteInput
- type AssetDeleteRoute
- type AssetGetInput
- type AssetGetRoute
- type AssetListInput
- type AssetListRoute
- type AssetReader
- type AssetUpdateInput
- type AssetUpdateRoute
- type Audience
- type AudienceController
- type AudienceCountRoute
- type AudienceCreateInput
- type AudienceCreateRoute
- type AudienceDeleteInput
- type AudienceDeleteRoute
- type AudienceGetInput
- type AudienceGetRoute
- type AudienceInitializeInput
- type AudienceListInput
- type AudienceListRoute
- type AudiencePermissionsUpdate
- type AudienceUpdateInput
- type AudienceUpdateRoute
- type Backend
- func (b *Backend) ApplicationCreate(ctx context.Context, params ApplicationCreateInput) (*Application, error)
- func (b *Backend) ApplicationDelete(ctx context.Context, params ApplicationDeleteInput) error
- func (b *Backend) ApplicationGet(ctx context.Context, params ApplicationGetInput) (*Application, error)
- func (b *Backend) ApplicationList(ctx context.Context, params ApplicationListInput) ([]*Application, error)
- func (b *Backend) ApplicationUpdate(ctx context.Context, params ApplicationUpdateInput) (*Application, error)
- func (b *Backend) AssetCreate(ctx context.Context, params AssetCreateInput) (*Asset, error)
- func (b *Backend) AssetDelete(ctx context.Context, params AssetDeleteInput) error
- func (b *Backend) AssetGet(ctx context.Context, params AssetGetInput) (*Asset, error)
- func (b *Backend) AssetList(ctx context.Context, params AssetListInput) ([]*Asset, error)
- func (b *Backend) AssetUpdate(ctx context.Context, params AssetUpdateInput) (*Asset, error)
- func (b *Backend) AudienceCreate(ctx context.Context, params AudienceCreateInput) (*Audience, error)
- func (b *Backend) AudienceDelete(ctx context.Context, params AudienceDeleteInput) error
- func (b *Backend) AudienceGet(ctx context.Context, params AudienceGetInput) (*Audience, error)
- func (b *Backend) AudienceInitialize(ctx context.Context, params AudienceInitializeInput) (*Audience, error)
- func (b *Backend) AudienceList(ctx context.Context, params AudienceListInput) ([]*Audience, error)
- func (b *Backend) AudienceUpdate(ctx context.Context, params AudienceUpdateInput) (*Audience, error)
- func (b *Backend) Context(ctx context.Context) context.Context
- func (b *Backend) DB(ctx context.Context) DB
- func (b *Backend) Log(ctx context.Context) log.Interface
- func (b *Backend) OAuthController() oauth.Controller
- func (b *Backend) OptionGet(ctx context.Context, params *OptionGetInput) (Option, error)
- func (b *Backend) OptionRemove(ctx context.Context, params *OptionRemoveInput) error
- func (b *Backend) OptionUpdate(ctx context.Context, params *OptionUpdateInput) (Option, error)
- func (b *Backend) PasswordManager() PasswordManager
- func (b *Backend) RoleCreate(ctx context.Context, params RoleCreateInput) (*Role, error)
- func (b *Backend) RoleDelete(ctx context.Context, params RoleDeleteInput) error
- func (b *Backend) RoleGet(ctx context.Context, params RoleGetInput) (*Role, error)
- func (b *Backend) RoleList(ctx context.Context, params RoleListInput) ([]*Role, error)
- func (b *Backend) RoleUpdate(ctx context.Context, params RoleUpdateInput) (*Role, error)
- func (b *Backend) SecretCreate(ctx context.Context, params SecretCreateInput) (*Secret, error)
- func (b *Backend) SecretDelete(ctx context.Context, params SecretDeleteInput) error
- func (b *Backend) SessionController() session.Controller
- func (b *Backend) Transact(ctx context.Context, handler TxHandler, ignore ...error) (err error)
- func (b *Backend) UserCreate(ctx context.Context, params UserCreateInput) (*User, error)
- func (b *Backend) UserDelete(ctx context.Context, params UserDeleteInput) error
- func (b *Backend) UserGet(ctx context.Context, params UserGetInput) (*User, error)
- func (b *Backend) UserList(ctx context.Context, params UserListInput) ([]*User, error)
- func (b *Backend) UserUpdate(ctx context.Context, params UserUpdateInput) (*User, error)
- type BackendOption
- type Controller
- type DB
- type ID
- type Job
- type Migration
- type Option
- type OptionController
- type OptionGetInput
- type OptionRemoveInput
- type OptionUpdateHandler
- type OptionUpdateInput
- type PasswordManager
- type PermissionsUpdate
- type RPCServer
- func (s *RPCServer) ApplicationCreate(ctx context.Context, params *pb.ApplicationCreateRequest) (*pb.Application, error)
- func (s *RPCServer) ApplicationDelete(ctx context.Context, params *pb.ApplicationDeleteRequest) (*empty.Empty, error)
- func (s *RPCServer) ApplicationGet(ctx context.Context, params *pb.ApplicationGetRequest) (*pb.Application, error)
- func (s *RPCServer) ApplicationList(req *pb.ApplicationListRequest, stream pb.Hiro_ApplicationListServer) error
- func (s *RPCServer) ApplicationUpdate(ctx context.Context, params *pb.ApplicationUpdateRequest) (*pb.Application, error)
- func (s *RPCServer) AudienceCreate(ctx context.Context, params *pb.AudienceCreateRequest) (*pb.Audience, error)
- func (s *RPCServer) AudienceDelete(ctx context.Context, params *pb.AudienceDeleteRequest) (*empty.Empty, error)
- func (s *RPCServer) AudienceGet(ctx context.Context, params *pb.AudienceGetRequest) (*pb.Audience, error)
- func (s *RPCServer) AudienceList(req *pb.AudienceListRequest, stream pb.Hiro_AudienceListServer) error
- func (s *RPCServer) AudienceUpdate(ctx context.Context, params *pb.AudienceUpdateRequest) (*pb.Audience, error)
- func (s *RPCServer) SecretCreate(ctx context.Context, params *pb.SecretCreateRequest) (*pb.Secret, error)
- func (s *RPCServer) SecreteDelete(ctx context.Context, params *pb.SecretDeleteRequest) (*empty.Empty, error)
- type RequestToken
- type Role
- type RoleController
- type RoleCreateInput
- type RoleDeleteInput
- type RoleGetInput
- type RoleListInput
- type RoleType
- type RoleUpdateInput
- type Secret
- type SecretCreateInput
- type SecretCreateRoute
- type SecretDeleteInput
- type SecretDeleteRoute
- type SecretType
- type SecretsController
- type Service
- type ServiceOption
- func WithAPIOptions(o ...api.Option) ServiceOption
- func WithAPIServer(srv *api.Server) ServiceOption
- func WithBackendOptions(o []BackendOption) ServiceOption
- func WithController(c Controller) ServiceOption
- func WithName(name string) ServiceOption
- func WithOAuthController(o oauth.Controller) ServiceOption
- func WithRPCServer(r *grpc.Server) ServiceOption
- func WithServerAddr(addr string) ServiceOption
- func WithSessionController(c session.Controller) ServiceOption
- type Session
- type SessionKey
- type SpecGetInput
- type SpecRoute
- type TxHandler
- type User
- type UserController
- type UserCountRoute
- type UserCreateInput
- type UserCreateRoute
- type UserDeleteInput
- type UserDeleteRoute
- type UserGetInput
- type UserGetRoute
- type UserListInput
- type UserListRoute
- type UserUpdateInput
- type UserUpdateRoute
Constants ¶
const ( // DefaultTokenAlgorithm is the default token algorithm DefaultTokenAlgorithm = oauth.TokenAlgorithmRS256 // DefaultTokenLifetime is the default audience token lifetime DefaultTokenLifetime = time.Hour // DefaultSessionLifetime is the default audience session lifetime DefaultSessionLifetime = time.Hour * 24 * 30 )
const ( // ScopeAudienceRead is used to read audience properties ScopeAudienceRead = "audience:read" // ScopeAudienceWrite is used to create or modify audiences ScopeAudienceWrite = "audience:write" // ScopeApplicationRead is used to read application properties ScopeApplicationRead = "application:read" // ScopeApplicationWrite is used to create or modify applications ScopeApplicationWrite = "application:write" // ScopeRoleRead is used to read roles ScopeRoleRead = "role:read" // ScopeRoleWrite is used to create or modify roles ScopeRoleWrite = "role:write" // ScopeAssetRead is required to read assets ScopeAssetRead = "asset:read" // ScopeAssetWrite is required to write and update assets ScopeAssetWrite = "asset:write" // ScopeUserRead is used to read users ScopeUserRead = "user:read" // ScopeUserWrite is used to create or modify users ScopeUserWrite = "user:write" // ScopeTokenRead is used to read request and access tokens ScopeTokenRead = "token:read" // ScopeTokenCreate is used to create access tokens ScopeTokenCreate = "token:create" // ScopeTokenRevoke is used to revoke request or access tokens ScopeTokenRevoke = "token:revoked" // ScopeSessionRead is used to read sessions ScopeSessionRead = "session:read" // ScopeSessionRevoke is used to destory sessions ScopeSessionRevoke = "session:destroy" )
const ( // MaxPasswordAge is the max age of a password before it must be changed MaxPasswordAge = time.Hour * 24 * 90 )
Variables ¶
var ( // Scopes is the spec defined oauth 2.0 scopes for the Hiro API Scopes = oauth.Scope{ ScopeAudienceRead, ScopeAudienceWrite, ScopeApplicationRead, ScopeApplicationWrite, ScopeUserRead, ScopeUserWrite, ScopeTokenRead, ScopeTokenCreate, ScopeTokenRevoke, ScopeSessionRead, ScopeSessionRevoke, ScopeRoleRead, ScopeRoleWrite, ScopeAssetRead, ScopeAssetWrite, } // Roles is the list of hiro roles by name Roles = oauth.ScopeSet{ "admin": Scopes, } )
var ( // ErrDuplicateObject is returned where there is unique constraint violation ErrDuplicateObject = api.ErrConflict // ErrInputValidation is returned when a object validation fails ErrInputValidation = api.ErrBadRequest // ErrNotFound is returned when an object is not found ErrNotFound = api.ErrNotFound // ErrAuthFailed is returned when user authentication fails to due to password mistmatch ErrAuthFailed = api.ErrUnauthorized // ErrDatabaseTimeout is returned when the database cannot be reached ErrDatabaseTimeout = api.ErrServerError.WithDetail("database connection timeout") // ErrContextNotFound is returned when hiro is not in the context ErrContextNotFound = api.ErrServerError.WithDetail("hiro not found in context") )
var (
// DefaultPasswordManager is the default password manager
DefaultPasswordManager = passwordManager{}
)
Functions ¶
func ErrTxCommit ¶
ErrTxCommit is used to return an error from within a tx handler but still commit
func IsTransaction ¶
IsTransaction returns true of the DB interface is a transaction
func ParseSQLError ¶
ParseSQLError provides cleaner errors for database issues
func RegisterOption ¶
RegisterOption registers an option type
func RegisterOptionUpdateHandler ¶
func RegisterOptionUpdateHandler(name string, handler OptionUpdateHandler)
RegisterOptionUpdateHandler registers an update handler for options
func TokenSecret ¶
func TokenSecret(s *Secret) (oauth.TokenSecret, error)
TokenSecret retuns a token secret from the Secret key
Types ¶
type AccessToken ¶
type AccessToken struct { ID ID `json:"id" db:"id"` Issuer *oauth.URI `json:"issuer,omitempty" db:"issuer"` Audience ID `json:"audience_id" db:"audience_id"` ApplicationID ID `json:"application_id" db:"application_id"` UserID ID `json:"user_id,omitempty" db:"user_id,omitempty"` Use oauth.TokenUse `json:"token_use" db:"token_use"` AuthTime *oauth.Time `db:"-"` Scope oauth.Scope `json:"scope,omitempty" db:"scope"` CreatedAt oauth.Time `json:"created_at" db:"created_at"` ExpiresAt *oauth.Time `json:"expires_at,omitempty" db:"expires_at"` Revokable bool `db:"-"` RevokedAt *oauth.Time `json:"revoked_at,omitempty" db:"revoked_at"` Claims oauth.Claims `json:"claims,omitempty" db:"claims"` Bearer *string `db:"-"` }
AccessToken is the backend representation of an oauth.Token (type=TokenTypeAccess)
type Application ¶
type Application struct { ID ID `json:"id" db:"id"` Name string `json:"name" db:"name"` Slug string `json:"slug" db:"slug"` Description *string `json:"description,omitempty" db:"description"` Type oauth.ClientType `json:"type" db:"type"` SecretKey *string `json:"secret_key,omitempty" db:"secret_key"` Permissions oauth.ScopeSet `json:"permissions,omitempty" db:"-"` Grants oauth.Grants `json:"grants,omitempty" db:"-"` URIs oauth.URIList `json:"uris,omitempty" db:"uris"` CreatedAt time.Time `json:"created_at" db:"created_at"` UpdatedAt *time.Time `json:"updated_at,omitempty" db:"updated_at"` Metadata common.Map `json:"metadata,omitempty" db:"metadata"` }
Application is the database model for an application
type ApplicationController ¶ added in v0.1.1
type ApplicationController interface { ApplicationCreate(ctx context.Context, params ApplicationCreateInput) (*Application, error) ApplicationGet(ctx context.Context, params ApplicationGetInput) (*Application, error) ApplicationList(ctx context.Context, params ApplicationListInput) ([]*Application, error) ApplicationUpdate(ctx context.Context, params ApplicationUpdateInput) (*Application, error) ApplicationDelete(ctx context.Context, params ApplicationDeleteInput) error }
ApplicationController is the applications API interface
type ApplicationCountRoute ¶
type ApplicationCountRoute func(ctx context.Context, params *ApplicationListInput) api.Responder
ApplicationCountRoute is the application count route definition
func (ApplicationCountRoute) Methods ¶
func (ApplicationCountRoute) Methods() []string
Methods implements api.Route
func (ApplicationCountRoute) Name ¶
func (ApplicationCountRoute) Name() string
Name implements api.Route
func (ApplicationCountRoute) Path ¶
func (ApplicationCountRoute) Path() string
Path implements api.Route
func (ApplicationCountRoute) RequireAuth ¶
func (ApplicationCountRoute) RequireAuth() []api.CredentialType
RequireAuth implements the api.AuthorizedRoute
func (ApplicationCountRoute) Scopes ¶
func (ApplicationCountRoute) Scopes() oauth.ScopeList
Scopes implements oauth.Route
type ApplicationCreateInput ¶
type ApplicationCreateInput struct { Name string `json:"name"` Description *string `json:"description,omitempty"` Type oauth.ClientType `json:"type" db:"type"` Permissions oauth.ScopeSet `json:"permissions,omitempty"` Grants oauth.Grants `json:"grants,omitempty"` URIs oauth.URIList `json:"uris,omitempty"` Metadata common.Map `json:"metadata,omitempty"` }
ApplicationCreateInput is the application create request
func (ApplicationCreateInput) ValidateWithContext ¶
func (a ApplicationCreateInput) ValidateWithContext(ctx context.Context) error
ValidateWithContext handles validation of the ApplicationCreateInput struct
type ApplicationCreateRoute ¶
type ApplicationCreateRoute func(ctx context.Context, params *ApplicationCreateInput) api.Responder
ApplicationCreateRoute is the application create route definition
func (ApplicationCreateRoute) Methods ¶
func (ApplicationCreateRoute) Methods() []string
Methods implements api.Route
func (ApplicationCreateRoute) Name ¶
func (ApplicationCreateRoute) Name() string
Name implements api.Route
func (ApplicationCreateRoute) Path ¶
func (ApplicationCreateRoute) Path() string
Path implements api.Route
func (ApplicationCreateRoute) RequireAuth ¶
func (ApplicationCreateRoute) RequireAuth() []api.CredentialType
RequireAuth implements the api.AuthorizedRoute
func (ApplicationCreateRoute) Scopes ¶
func (ApplicationCreateRoute) Scopes() oauth.ScopeList
Scopes implements oauth.Route
type ApplicationDeleteInput ¶
type ApplicationDeleteInput struct {
ApplicationID ID `json:"application_id"`
}
ApplicationDeleteInput is the application delete request input
func (ApplicationDeleteInput) ValidateWithContext ¶
func (a ApplicationDeleteInput) ValidateWithContext(ctx context.Context) error
ValidateWithContext handles validation of the ApplicationDeleteInput
type ApplicationDeleteRoute ¶
type ApplicationDeleteRoute func(ctx context.Context, params *ApplicationDeleteInput) api.Responder
ApplicationDeleteRoute is the application create route definition
func (ApplicationDeleteRoute) Methods ¶
func (ApplicationDeleteRoute) Methods() []string
Methods implements api.Route
func (ApplicationDeleteRoute) Name ¶
func (ApplicationDeleteRoute) Name() string
Name implements api.Route
func (ApplicationDeleteRoute) Path ¶
func (ApplicationDeleteRoute) Path() string
Path implements api.Route
func (ApplicationDeleteRoute) RequireAuth ¶
func (ApplicationDeleteRoute) RequireAuth() []api.CredentialType
RequireAuth implements the api.AuthorizedRoute
func (ApplicationDeleteRoute) Scopes ¶
func (ApplicationDeleteRoute) Scopes() oauth.ScopeList
Scopes implements oauth.Route
type ApplicationGetInput ¶
type ApplicationGetInput struct { ApplicationID ID `json:"application_id,omitempty"` Name *string `json:"name,omitempty"` }
ApplicationGetInput is used to get an application for the id
func (ApplicationGetInput) ValidateWithContext ¶
func (a ApplicationGetInput) ValidateWithContext(ctx context.Context) error
ValidateWithContext handles validation of the ApplicationGetInput struct
type ApplicationGetRoute ¶
type ApplicationGetRoute func(ctx context.Context, params *ApplicationGetInput) api.Responder
ApplicationGetRoute is the application create route definition
func (ApplicationGetRoute) Methods ¶
func (ApplicationGetRoute) Methods() []string
Methods implements api.Route
func (ApplicationGetRoute) Name ¶
func (ApplicationGetRoute) Name() string
Name implements api.Route
func (ApplicationGetRoute) Path ¶
func (ApplicationGetRoute) Path() string
Path implements api.Route
func (ApplicationGetRoute) RequireAuth ¶
func (ApplicationGetRoute) RequireAuth() []api.CredentialType
RequireAuth implements the api.AuthorizedRoute
func (ApplicationGetRoute) Scopes ¶
func (ApplicationGetRoute) Scopes() oauth.ScopeList
Scopes implements oauth.Route
type ApplicationListInput ¶
type ApplicationListInput struct { Limit *uint64 `json:"limit,omitempty"` Offset *uint64 `json:"offset,omitempty"` Count *uint64 `json:"count,omitempty"` }
ApplicationListInput is the application list request
func (ApplicationListInput) ValidateWithContext ¶
func (a ApplicationListInput) ValidateWithContext(context.Context) error
ValidateWithContext handles validation of the ApplicationListInput struct
type ApplicationListRoute ¶
type ApplicationListRoute func(ctx context.Context, params *ApplicationListInput) api.Responder
ApplicationListRoute is the application count route definition
func (ApplicationListRoute) Methods ¶
func (ApplicationListRoute) Methods() []string
Methods implements api.Route
func (ApplicationListRoute) Name ¶
func (ApplicationListRoute) Name() string
Name implements api.Route
func (ApplicationListRoute) Path ¶
func (ApplicationListRoute) Path() string
Path implements api.Route
func (ApplicationListRoute) RequireAuth ¶
func (ApplicationListRoute) RequireAuth() []api.CredentialType
RequireAuth implements the api.AuthorizedRoute
func (ApplicationListRoute) Scopes ¶
func (ApplicationListRoute) Scopes() oauth.ScopeList
Scopes implements oauth.Route
type ApplicationUpdateInput ¶
type ApplicationUpdateInput struct { ApplicationID ID `json:"id" structs:"-"` Name *string `json:"name" structs:"name,omitempty"` Description *string `json:"description,omitempty" structs:"description,omitempty"` Type *oauth.ClientType `json:"type" structs:"type,omitempty"` Permissions *PermissionsUpdate `json:"permissions,omitempty" structs:"-"` Grants oauth.Grants `json:"grants,omitempty" structs:"-"` URIs oauth.URIList `json:"uris,omitempty" structs:"-"` Metadata common.Map `json:"metadata,omitempty" structs:"metadata,omitempty"` }
ApplicationUpdateInput is the application update request
func (ApplicationUpdateInput) ValidateWithContext ¶
func (a ApplicationUpdateInput) ValidateWithContext(ctx context.Context) error
ValidateWithContext handles validation of the ApplicationUpdateInput struct
type ApplicationUpdateRoute ¶
type ApplicationUpdateRoute func(ctx context.Context, params *ApplicationUpdateInput) api.Responder
ApplicationUpdateRoute is the application create route definition
func (ApplicationUpdateRoute) Methods ¶
func (ApplicationUpdateRoute) Methods() []string
Methods implements api.Route
func (ApplicationUpdateRoute) Name ¶
func (ApplicationUpdateRoute) Name() string
Name implements api.Route
func (ApplicationUpdateRoute) Path ¶
func (ApplicationUpdateRoute) Path() string
Path implements api.Route
func (ApplicationUpdateRoute) RequireAuth ¶
func (ApplicationUpdateRoute) RequireAuth() []api.CredentialType
RequireAuth implements the api.AuthorizedRoute
func (ApplicationUpdateRoute) Scopes ¶
func (ApplicationUpdateRoute) Scopes() oauth.ScopeList
Scopes implements oauth.Route
type Asset ¶
type Asset struct { ID ID `json:"id" db:"id"` AudienceID ID `json:"audience_id" db:"audience_id"` OwnerID *ID `json:"owner_id,omitempty" db:"owner_id"` Title string `json:"title" db:"title"` Description *string `json:"description,omitempty" db:"description"` Filename string `json:"filename" db:"filename"` MimeType string `json:"mime_type" db:"mime_type"` Size int64 `json:"size" db:"size"` Public bool `json:"public" db:"public"` CreatedAt time.Time `json:"created_at" db:"created_at"` UpdatedAt *time.Time `json:"updated_at,omitempty" db:"updated_at"` Metadata common.Map `json:"metadata,omitempty" db:"metadata"` SHA256 *string `json:"sha256,omitempty" db:"sha256"` Payload AssetReader `json:"-" db:"-"` }
Asset objects are application assets that are stored in the asset volume
type AssetController ¶ added in v0.1.1
type AssetController interface { AssetCreate(ctx context.Context, params AssetCreateInput) (*Asset, error) AssetGet(ctc context.Context, params AssetGetInput) (*Asset, error) AssetList(ctx context.Context, params AssetListInput) ([]*Asset, error) AssetUpdate(ctx context.Context, params AssetUpdateInput) (*Asset, error) AssetDelete(ctx context.Context, params AssetDeleteInput) error }
AssetController is the asset API interface
type AssetCountRoute ¶ added in v0.1.1
type AssetCountRoute func(ctx context.Context, params *AssetListInput) api.Responder
AssetCountRoute is the asset count route definition
func (AssetCountRoute) Methods ¶ added in v0.1.1
func (AssetCountRoute) Methods() []string
Methods implements api.Route
func (AssetCountRoute) Name ¶ added in v0.1.1
func (AssetCountRoute) Name() string
Name implements api.Route
func (AssetCountRoute) Path ¶ added in v0.1.1
func (AssetCountRoute) Path() string
Path implements api.Route
func (AssetCountRoute) RequireAuth ¶ added in v0.1.1
func (AssetCountRoute) RequireAuth() []api.CredentialType
RequireAuth implements the api.AuthorizedRoute
func (AssetCountRoute) Scopes ¶ added in v0.1.1
func (AssetCountRoute) Scopes() oauth.ScopeList
Scopes implements oauth.Route
type AssetCreateInput ¶ added in v0.1.1
type AssetCreateInput struct { AudienceID ID `json:"audience_id"` OwnerID *ID `json:"owner_id,omitempty"` Title string `json:"title"` Description *string `json:"description,omitempty"` Filename string `json:"filename"` Public bool `json:"public"` Metadata common.Map `json:"metadata,omitempty"` Payload io.Reader `json:"-"` }
AssetCreateInput is the input to AssetCreate
func (*AssetCreateInput) ValidateWithContext ¶ added in v0.1.1
func (a *AssetCreateInput) ValidateWithContext(ctx context.Context) error
ValidateWithContext handles the validation for the AssetCreateInput
type AssetCreateRoute ¶ added in v0.1.1
type AssetCreateRoute func(ctx context.Context, params *AssetCreateInput) api.Responder
AssetCreateRoute is the asset create route definition
func (AssetCreateRoute) Methods ¶ added in v0.1.1
func (AssetCreateRoute) Methods() []string
Methods implements api.Route
func (AssetCreateRoute) Name ¶ added in v0.1.1
func (AssetCreateRoute) Name() string
Name implements api.Route
func (AssetCreateRoute) Path ¶ added in v0.1.1
func (AssetCreateRoute) Path() string
Path implements api.Route
func (AssetCreateRoute) RequireAuth ¶ added in v0.1.1
func (AssetCreateRoute) RequireAuth() []api.CredentialType
RequireAuth implements the api.AuthorizedRoute
func (AssetCreateRoute) Scopes ¶ added in v0.1.1
func (AssetCreateRoute) Scopes() oauth.ScopeList
Scopes implements oauth.Route
type AssetDeleteInput ¶ added in v0.1.1
AssetDeleteInput is the input to AssetDelete
func (AssetDeleteInput) ValidateWithContext ¶ added in v0.1.1
func (a AssetDeleteInput) ValidateWithContext(ctx context.Context) error
Validate handles validation for AssetGetInput
type AssetDeleteRoute ¶ added in v0.1.1
type AssetDeleteRoute func(ctx context.Context, params *AssetDeleteInput) api.Responder
AssetDeleteRoute is the asset create route definition
func (AssetDeleteRoute) Methods ¶ added in v0.1.1
func (AssetDeleteRoute) Methods() []string
Methods implements api.Route
func (AssetDeleteRoute) Name ¶ added in v0.1.1
func (AssetDeleteRoute) Name() string
Name implements api.Route
func (AssetDeleteRoute) Path ¶ added in v0.1.1
func (AssetDeleteRoute) Path() string
Path implements api.Route
func (AssetDeleteRoute) RequireAuth ¶ added in v0.1.1
func (AssetDeleteRoute) RequireAuth() []api.CredentialType
RequireAuth implements the api.AuthorizedRoute
func (AssetDeleteRoute) Scopes ¶ added in v0.1.1
func (AssetDeleteRoute) Scopes() oauth.ScopeList
Scopes implements oauth.Route
type AssetGetInput ¶ added in v0.1.1
type AssetGetInput struct { AudienceID ID `json:"audience_id"` AssetID *ID `json:"asset_id"` Filename *string `json:"filename"` WithPayload bool `json:"-"` }
AssetGetInput is the input to AssetGet
func (AssetGetInput) ValidateWithContext ¶ added in v0.1.1
func (a AssetGetInput) ValidateWithContext(ctx context.Context) error
Validate handles validation for AssetGetInput
type AssetGetRoute ¶ added in v0.1.1
type AssetGetRoute func(ctx context.Context, params *AssetGetInput) api.Responder
AssetGetRoute is the asset create route definition
func (AssetGetRoute) Methods ¶ added in v0.1.1
func (AssetGetRoute) Methods() []string
Methods implements api.Route
func (AssetGetRoute) Name ¶ added in v0.1.1
func (AssetGetRoute) Name() string
Name implements api.Route
func (AssetGetRoute) Path ¶ added in v0.1.1
func (AssetGetRoute) Path() string
Path implements api.Route
func (AssetGetRoute) RequireAuth ¶ added in v0.1.1
func (AssetGetRoute) RequireAuth() []api.CredentialType
RequireAuth implements the api.AuthorizedRoute
func (AssetGetRoute) Scopes ¶ added in v0.1.1
func (AssetGetRoute) Scopes() oauth.ScopeList
Scopes implements oauth.Route
type AssetListInput ¶ added in v0.1.1
type AssetListInput struct { AudienceID ID `json:"audience_id"` Offset *uint64 `json:"offset,omitempty"` Limit *uint64 `json:"limit,omitempty"` Count *uint64 `json:"count,omitempty"` MimeType *string `json:"mime_type,omitempty"` }
AssetListInput is the input to AssetList
func (AssetListInput) ValidateWithContext ¶ added in v0.1.1
func (a AssetListInput) ValidateWithContext(ctx context.Context) error
Validate handles validation for AssetGetInput
type AssetListRoute ¶ added in v0.1.1
type AssetListRoute func(ctx context.Context, params *AssetListInput) api.Responder
AssetListRoute is the asset count route definition
func (AssetListRoute) Methods ¶ added in v0.1.1
func (AssetListRoute) Methods() []string
Methods implements api.Route
func (AssetListRoute) Name ¶ added in v0.1.1
func (AssetListRoute) Name() string
Name implements api.Route
func (AssetListRoute) Path ¶ added in v0.1.1
func (AssetListRoute) Path() string
Path implements api.Route
func (AssetListRoute) RequireAuth ¶ added in v0.1.1
func (AssetListRoute) RequireAuth() []api.CredentialType
RequireAuth implements the api.AuthorizedRoute
func (AssetListRoute) Scopes ¶ added in v0.1.1
func (AssetListRoute) Scopes() oauth.ScopeList
Scopes implements oauth.Route
type AssetReader ¶ added in v0.1.1
type AssetReader interface { io.ReadSeeker io.Closer }
AssetReader is an interface for asset io
type AssetUpdateInput ¶ added in v0.1.1
type AssetUpdateInput struct { AudienceID ID `json:"audience_id" structs:"audience_id"` AssetID ID `json:"asset_id" structs:"asset_id"` Title *string `json:"title" structs:"title,omitempty"` Description *string `json:"description,omitempty" structs:"description,omitempty"` Filename *string `json:"filename" structs:"filename,omitempty"` Public *bool `json:"public" structs:"public,omitempty"` Metadata common.Map `json:"metadata,omitempty" structs:"metadata,omitempty"` Payload io.Reader `json:"-" structs:"-"` }
AssetUpdateInput is the input to AssetUpdate
func (*AssetUpdateInput) ValidateWithContext ¶ added in v0.1.1
func (a *AssetUpdateInput) ValidateWithContext(ctx context.Context) error
ValidateWithContext handles the validation for the AssetUpdateInput
type AssetUpdateRoute ¶ added in v0.1.1
type AssetUpdateRoute func(ctx context.Context, params *AssetUpdateInput) api.Responder
AssetUpdateRoute is the asset create route definition
func (AssetUpdateRoute) Methods ¶ added in v0.1.1
func (AssetUpdateRoute) Methods() []string
Methods implements api.Route
func (AssetUpdateRoute) Name ¶ added in v0.1.1
func (AssetUpdateRoute) Name() string
Name implements api.Route
func (AssetUpdateRoute) Path ¶ added in v0.1.1
func (AssetUpdateRoute) Path() string
Path implements api.Route
func (AssetUpdateRoute) RequireAuth ¶ added in v0.1.1
func (AssetUpdateRoute) RequireAuth() []api.CredentialType
RequireAuth implements the api.AuthorizedRoute
func (AssetUpdateRoute) Scopes ¶ added in v0.1.1
func (AssetUpdateRoute) Scopes() oauth.ScopeList
Scopes implements oauth.Route
type Audience ¶
type Audience struct { ID ID `json:"id" db:"id"` Name string `json:"name" db:"name"` Slug string `json:"slug" db:"slug"` Domain *string `json:"domain" db:"domain"` Description *string `json:"description,omitempty" db:"description"` TokenSecrets []oauth.TokenSecret `json:"-" db:"-"` SessionKeys []SessionKey `json:"-" db:"-"` Secrets []*Secret `json:"secrets,omitempty" db:"-"` TokenAlgorithm oauth.TokenAlgorithm `json:"token_algorithm" db:"token_algorithm"` TokenLifetime time.Duration `json:"token_lifetime" db:"token_lifetime"` SessionLifetime time.Duration `json:"session_lifetime,omitempty" db:"session_lifetime"` CreatedAt time.Time `json:"created_at" db:"created_at"` UpdatedAt *time.Time `json:"updated_at,omitempty" db:"updated_at"` Permissions oauth.Scope `json:"permissions,omitempty" db:"-"` Metadata common.Map `json:"metadata,omitempty" db:"metadata"` }
Audience is the database model for an audience
type AudienceController ¶ added in v0.1.1
type AudienceController interface { AudienceCreate(ctx context.Context, params AudienceCreateInput) (*Audience, error) AudienceGet(ctx context.Context, params AudienceGetInput) (*Audience, error) AudienceList(ctx context.Context, params AudienceListInput) ([]*Audience, error) AudienceUpdate(ctx context.Context, params AudienceUpdateInput) (*Audience, error) AudienceDelete(ctx context.Context, params AudienceDeleteInput) error }
AudienceController is the audience API interface
type AudienceCountRoute ¶
type AudienceCountRoute func(ctx context.Context, params *AudienceListInput) api.Responder
AudienceCountRoute is the audience count route definition
func (AudienceCountRoute) Methods ¶
func (AudienceCountRoute) Methods() []string
Methods implements api.Route
func (AudienceCountRoute) RequireAuth ¶
func (AudienceCountRoute) RequireAuth() []api.CredentialType
RequireAuth implements the api.AuthorizedRoute
func (AudienceCountRoute) Scopes ¶
func (AudienceCountRoute) Scopes() oauth.ScopeList
Scopes implements oauth.Route
type AudienceCreateInput ¶
type AudienceCreateInput struct { Name string `json:"name"` Description *string `json:"description,omitempty"` Domain *string `json:"domain" db:"domain"` TokenLifetime time.Duration `json:"token_lifetime"` TokenAlgorithm oauth.TokenAlgorithm `json:"token_algorithm"` SessionLifetime time.Duration `json:"session_lifetime,omitempty"` Permissions oauth.Scope `json:"permissions,omitempty"` Metadata common.Map `json:"metadata,omitempty"` }
AudienceCreateInput is the audience create request
func (AudienceCreateInput) ValidateWithContext ¶
func (a AudienceCreateInput) ValidateWithContext(ctx context.Context) error
ValidateWithContext handles validation of the AudienceCreateInput struct
type AudienceCreateRoute ¶
type AudienceCreateRoute func(ctx context.Context, params *AudienceCreateInput) api.Responder
AudienceCreateRoute is the audience create route definition
func (AudienceCreateRoute) Methods ¶
func (AudienceCreateRoute) Methods() []string
Methods implements api.Route
func (AudienceCreateRoute) Name ¶
func (AudienceCreateRoute) Name() string
Name implements api.Route
func (AudienceCreateRoute) Path ¶
func (AudienceCreateRoute) Path() string
Path implements api.Route
func (AudienceCreateRoute) RequireAuth ¶
func (AudienceCreateRoute) RequireAuth() []api.CredentialType
RequireAuth implements the api.AuthorizedRoute
func (AudienceCreateRoute) Scopes ¶
func (AudienceCreateRoute) Scopes() oauth.ScopeList
Scopes implements oauth.Route
type AudienceDeleteInput ¶
type AudienceDeleteInput struct {
AudienceID ID `json:"audience_id"`
}
AudienceDeleteInput is the audience delete request input
func (AudienceDeleteInput) ValidateWithContext ¶
func (a AudienceDeleteInput) ValidateWithContext(ctx context.Context) error
ValidateWithContext handles validation of the ApplicationDeleteInput
type AudienceDeleteRoute ¶
type AudienceDeleteRoute func(ctx context.Context, params *AudienceDeleteInput) api.Responder
AudienceDeleteRoute is the audience create route definition
func (AudienceDeleteRoute) Methods ¶
func (AudienceDeleteRoute) Methods() []string
Methods implements api.Route
func (AudienceDeleteRoute) Name ¶
func (AudienceDeleteRoute) Name() string
Name implements api.Route
func (AudienceDeleteRoute) Path ¶
func (AudienceDeleteRoute) Path() string
Path implements api.Route
func (AudienceDeleteRoute) RequireAuth ¶
func (AudienceDeleteRoute) RequireAuth() []api.CredentialType
RequireAuth implements the api.AuthorizedRoute
func (AudienceDeleteRoute) Scopes ¶
func (AudienceDeleteRoute) Scopes() oauth.ScopeList
Scopes implements oauth.Route
type AudienceGetInput ¶
type AudienceGetInput struct { AudienceID ID `json:"audience_id,omitempty"` Name *string `json:"name,omitempty"` Domain *string `json:"domain,omitempty"` }
AudienceGetInput is used to get an audience for the id
func (AudienceGetInput) ValidateWithContext ¶
func (a AudienceGetInput) ValidateWithContext(ctx context.Context) error
ValidateWithContext handles validation of the AudienceGetInput struct
type AudienceGetRoute ¶
type AudienceGetRoute func(ctx context.Context, params *AudienceGetInput) api.Responder
AudienceGetRoute is the audience create route definition
func (AudienceGetRoute) Methods ¶
func (AudienceGetRoute) Methods() []string
Methods implements api.Route
func (AudienceGetRoute) RequireAuth ¶
func (AudienceGetRoute) RequireAuth() []api.CredentialType
RequireAuth implements the api.AuthorizedRoute
func (AudienceGetRoute) Scopes ¶
func (AudienceGetRoute) Scopes() oauth.ScopeList
Scopes implements oauth.Route
type AudienceInitializeInput ¶
type AudienceInitializeInput struct { Name string `json:"name"` Description *string `json:"description,omitempty"` Domain *string `json:"domain" db:"domain"` TokenLifetime *time.Duration `json:"token_lifetime"` TokenAlgorithm *oauth.TokenAlgorithm `json:"token_algorithm"` SessionLifetime *time.Duration `json:"session_lifetime,omitempty"` Permissions oauth.Scope `json:"permissions,omitempty"` Metadata common.Map `json:"metadata,omitempty"` Roles oauth.ScopeSet `json:"roles,omitempty"` }
AudienceInitializeInput is the input to the audience initialization
func (AudienceInitializeInput) ValidateWithContext ¶
func (a AudienceInitializeInput) ValidateWithContext(ctx context.Context) error
ValidateWithContext handles validation of the AudienceInitializeInput struct
type AudienceListInput ¶
type AudienceListInput struct { Limit *uint64 `json:"limit,omitempty"` Offset *uint64 `json:"offset,omitempty"` Count *uint64 `json:"count,omitempty"` }
AudienceListInput is the audience list request
func (AudienceListInput) ValidateWithContext ¶
func (a AudienceListInput) ValidateWithContext(context.Context) error
ValidateWithContext handles validation of the AudienceListInput struct
type AudienceListRoute ¶
type AudienceListRoute func(ctx context.Context, params *AudienceListInput) api.Responder
AudienceListRoute is the audience count route definition
func (AudienceListRoute) Methods ¶
func (AudienceListRoute) Methods() []string
Methods implements api.Route
func (AudienceListRoute) RequireAuth ¶
func (AudienceListRoute) RequireAuth() []api.CredentialType
RequireAuth implements the api.AuthorizedRoute
func (AudienceListRoute) Scopes ¶
func (AudienceListRoute) Scopes() oauth.ScopeList
Scopes implements oauth.Route
type AudiencePermissionsUpdate ¶
type AudiencePermissionsUpdate struct { Add oauth.Scope `json:"add,omitempty"` Remove oauth.Scope `json:"remove,omitempty"` Overwrite bool `json:"overrite"` }
AudiencePermissionsUpdate is used to update audience permissions
type AudienceUpdateInput ¶
type AudienceUpdateInput struct { AudienceID ID `json:"audience_id" structs:"-"` Name *string `json:"name" structs:"name,omitempty"` Description *string `json:"description,omitempty" structs:"description,omitempty"` Domain *string `json:"domain" structs:"domain,omitempty"` TokenAlgorithm *oauth.TokenAlgorithm `json:"token_algorithm,omitempty" structs:"token_algorithm,omitempty"` TokenLifetime *time.Duration `json:"token_lifetime" structs:"token_lifetime,omitempty"` SessionLifetime *time.Duration `json:"session_lifetime,omitempty" structs:"session_lifetime,omitempty"` Permissions *AudiencePermissionsUpdate `json:"permissions,omitempty" structs:"-"` Metadata common.Map `json:"metadata,omitempty" structs:"-"` }
AudienceUpdateInput is the audience update request
func (AudienceUpdateInput) ValidateWithContext ¶
func (a AudienceUpdateInput) ValidateWithContext(ctx context.Context) error
ValidateWithContext handles validation of the AudienceUpdateInput struct
type AudienceUpdateRoute ¶
type AudienceUpdateRoute func(ctx context.Context, params *AudienceUpdateInput) api.Responder
AudienceUpdateRoute is the audience create route definition
func (AudienceUpdateRoute) Methods ¶
func (AudienceUpdateRoute) Methods() []string
Methods implements api.Route
func (AudienceUpdateRoute) Name ¶
func (AudienceUpdateRoute) Name() string
Name implements api.Route
func (AudienceUpdateRoute) Path ¶
func (AudienceUpdateRoute) Path() string
Path implements api.Route
func (AudienceUpdateRoute) RequireAuth ¶
func (AudienceUpdateRoute) RequireAuth() []api.CredentialType
RequireAuth implements the api.AuthorizedRoute
func (AudienceUpdateRoute) Scopes ¶
func (AudienceUpdateRoute) Scopes() oauth.ScopeList
Scopes implements oauth.Route
type Backend ¶
type Backend struct {
// contains filtered or unexported fields
}
Backend is the hiro api backend implementation
func FromContext ¶
FromContext returns a hiro from the context
func (*Backend) ApplicationCreate ¶
func (b *Backend) ApplicationCreate(ctx context.Context, params ApplicationCreateInput) (*Application, error)
ApplicationCreate create a new permission object
func (*Backend) ApplicationDelete ¶
func (b *Backend) ApplicationDelete(ctx context.Context, params ApplicationDeleteInput) error
ApplicationDelete deletes an application by id
func (*Backend) ApplicationGet ¶
func (b *Backend) ApplicationGet(ctx context.Context, params ApplicationGetInput) (*Application, error)
ApplicationGet gets an application by id and optionally preloads child objects
func (*Backend) ApplicationList ¶
func (b *Backend) ApplicationList(ctx context.Context, params ApplicationListInput) ([]*Application, error)
ApplicationList returns a listing of applications
func (*Backend) ApplicationUpdate ¶
func (b *Backend) ApplicationUpdate(ctx context.Context, params ApplicationUpdateInput) (*Application, error)
ApplicationUpdate updates an application by id, including child objects
func (*Backend) AssetCreate ¶ added in v0.1.1
AssetCreate creates a new asset for the audience
func (*Backend) AssetDelete ¶ added in v0.1.1
func (b *Backend) AssetDelete(ctx context.Context, params AssetDeleteInput) error
AssetDelete deletes an asset
func (*Backend) AssetUpdate ¶ added in v0.1.1
AssetUpdate updates an asset
func (*Backend) AudienceCreate ¶
func (b *Backend) AudienceCreate(ctx context.Context, params AudienceCreateInput) (*Audience, error)
AudienceCreate create a new permission object
func (*Backend) AudienceDelete ¶
func (b *Backend) AudienceDelete(ctx context.Context, params AudienceDeleteInput) error
AudienceDelete deletes an audience by id
func (*Backend) AudienceGet ¶
AudienceGet gets an audience by id and optionally preloads child objects
func (*Backend) AudienceInitialize ¶
func (b *Backend) AudienceInitialize(ctx context.Context, params AudienceInitializeInput) (*Audience, error)
AudienceInitialize will create or update and audience, intialize a default application and secrets
func (*Backend) AudienceList ¶
AudienceList returns a listing of audiences
func (*Backend) AudienceUpdate ¶
func (b *Backend) AudienceUpdate(ctx context.Context, params AudienceUpdateInput) (*Audience, error)
AudienceUpdate updates an application by id, including child objects
func (*Backend) OAuthController ¶
func (b *Backend) OAuthController() oauth.Controller
OAuthController returns an oauth controller from a hiro.Backend
func (*Backend) OptionRemove ¶
func (b *Backend) OptionRemove(ctx context.Context, params *OptionRemoveInput) error
OptionRemove removes the named option from the backend
func (*Backend) OptionUpdate ¶
OptionUpdate stores a named option in the backend data store
func (*Backend) PasswordManager ¶
func (b *Backend) PasswordManager() PasswordManager
PasswordManager returns the current password manager for the instance
func (*Backend) RoleCreate ¶
RoleCreate create a new permission object
func (*Backend) RoleDelete ¶
func (b *Backend) RoleDelete(ctx context.Context, params RoleDeleteInput) error
RoleDelete deletes an role by id
func (*Backend) RoleUpdate ¶
RoleUpdate updates an role by id, including child objects
func (*Backend) SecretCreate ¶
SecretCreate creates a new secret, generating the key if not is provided
func (*Backend) SecretDelete ¶
func (b *Backend) SecretDelete(ctx context.Context, params SecretDeleteInput) error
SecretDelete deletes an audience by id
func (*Backend) SessionController ¶
func (b *Backend) SessionController() session.Controller
SessionController returns an oauth controller from a hiro.Backend
func (*Backend) Transact ¶
Transact starts a db transaction, adds it to the context and calls the handler
func (*Backend) UserCreate ¶
UserCreate create a new permission object
func (*Backend) UserDelete ¶
func (b *Backend) UserDelete(ctx context.Context, params UserDeleteInput) error
UserDelete deletes an user by id
func (*Backend) UserUpdate ¶
UserUpdate updates an user by id, including child objects
type BackendOption ¶
type BackendOption func(b *Backend)
BackendOption defines a backend option
func Automigrate ¶
func Automigrate(m ...Migration) BackendOption
Automigrate will perform the database initialization, creating tables and indexes.
func Initialize ¶
func Initialize(a ...AudienceInitializeInput) BackendOption
Initialize will create the default hiro audience and application to use for management
func WithAssetVolume ¶ added in v0.1.1
func WithAssetVolume(v string) BackendOption
WithAssetVolume sets the asset volume for the instance
func WithDBSource ¶
func WithDBSource(source string) BackendOption
WithDBSource sets the database source string
type Controller ¶
type Controller interface { AudienceController SecretsController ApplicationController RoleController UserController AssetController // Returns the log from the context Log(ctx context.Context) log.Interface // Starts a database transaction Transact(ctx context.Context, handler TxHandler, ignore ...error) error // Gets a handle to the database DB(ctx context.Context) DB oauth.ControllerProxy // SessionController return the session controller SessionController() session.Controller }
Controller is the hiro API controller interface
type DB ¶
type DB interface { sqlx.Ext sqlx.ExtContext SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error }
DB is an aggregate interface for sqlx transactions
type ID ¶
type ID string
ID is the hiro uuid implementation wrapper that base58 encodes/decodes the values as text or json
func NullID ¶
func NullID(id ...interface{}) ID
NullID will parse or generate a value to make a new ID
func (ID) MarshalJSON ¶
MarshalJSON handles json marshaling of this type
func (*ID) UnmarshalJSON ¶
UnmarshalJSON handles the unmarshaling of this type
type Migration ¶
type Migration struct { *migrate.AssetMigrationSource Schema string }
Migration is a db migration
type Option ¶
Option An instance configuration option
func UnmarshalOption ¶
UnmarshalOption unmarshals polymorphic Option
type OptionController ¶
type OptionController interface { // OptionUpdate stores a named option in the backend data store, the value should be created if it does not exist OptionUpdate(ctx context.Context, params *OptionUpdateInput) (Option, error) // OptionGet returns a named option from the backend, an error should be returned if the option does not exist OptionGet(ctx context.Context, params *OptionGetInput) (Option, error) // OptionRemove removes the named option from the backend, and error should not be returned if the option does not exist OptionRemove(ctx context.Context, params *OptionRemoveInput) error }
OptionController provides instance configuration
type OptionGetInput ¶
type OptionGetInput struct { Name string `json:"name"` Value interface{} `json:"-"` }
OptionGetInput is the option get input
func (OptionGetInput) Validate ¶
func (o OptionGetInput) Validate() error
Validate validates OptionGetInput
type OptionRemoveInput ¶
type OptionRemoveInput struct {
Name string `json:"name"`
}
OptionRemoveInput is the option get input
func (OptionRemoveInput) Validate ¶
func (o OptionRemoveInput) Validate() error
Validate validates OptionRemoveInput
type OptionUpdateHandler ¶
OptionUpdateHandler is called when options are updated
type OptionUpdateInput ¶
type OptionUpdateInput struct { AudienceID ID `json:"audience_id"` Name string `json:"name"` Option Option `json:"-"` // contains filtered or unexported fields }
OptionUpdateInput is the option update input
func (OptionUpdateInput) Validate ¶
func (o OptionUpdateInput) Validate() error
Validate validates OptionUpdateInput
type PasswordManager ¶
type PasswordManager interface { HashPassword(password string) (string, error) CheckPasswordHash(password, hash string) bool EnforcePasswordPolicy(enabled bool) ValidatePassword(password string) error PasswordExpiry() time.Duration MaxLoginAttempts() int AccountLockoutPeriod() time.Duration }
PasswordManager is an interface for hashing and validation of passwords
type PermissionsUpdate ¶
type PermissionsUpdate struct { Add oauth.ScopeSet `json:"add,omitempty"` Remove oauth.ScopeSet `json:"remove,omitempty"` Overwrite bool `json:"overwrite"` }
PermissionsUpdate is used to modify permissions
type RPCServer ¶
type RPCServer struct { Controller pb.UnimplementedHiroServer }
RPCServer is a hiro rpc server
func NewRPCServer ¶
func NewRPCServer(c Controller) *RPCServer
NewRPCServer returns a new hiro rpc Server
func (*RPCServer) ApplicationCreate ¶
func (s *RPCServer) ApplicationCreate(ctx context.Context, params *pb.ApplicationCreateRequest) (*pb.Application, error)
ApplicationCreate implements the pb.HiroServer interface
func (*RPCServer) ApplicationDelete ¶
func (s *RPCServer) ApplicationDelete(ctx context.Context, params *pb.ApplicationDeleteRequest) (*empty.Empty, error)
ApplicationDelete implements the pb.HiroServer interface
func (*RPCServer) ApplicationGet ¶
func (s *RPCServer) ApplicationGet(ctx context.Context, params *pb.ApplicationGetRequest) (*pb.Application, error)
ApplicationGet implements the pb.HiroServer interface
func (*RPCServer) ApplicationList ¶
func (s *RPCServer) ApplicationList(req *pb.ApplicationListRequest, stream pb.Hiro_ApplicationListServer) error
ApplicationList implements the pb.HiroServer interface
func (*RPCServer) ApplicationUpdate ¶
func (s *RPCServer) ApplicationUpdate(ctx context.Context, params *pb.ApplicationUpdateRequest) (*pb.Application, error)
ApplicationUpdate implements the pb.HiroServer interface
func (*RPCServer) AudienceCreate ¶
func (s *RPCServer) AudienceCreate(ctx context.Context, params *pb.AudienceCreateRequest) (*pb.Audience, error)
AudienceCreate implements the pb.HiroServer interface
func (*RPCServer) AudienceDelete ¶
func (s *RPCServer) AudienceDelete(ctx context.Context, params *pb.AudienceDeleteRequest) (*empty.Empty, error)
AudienceDelete implements the pb.HiroServer interface
func (*RPCServer) AudienceGet ¶
func (s *RPCServer) AudienceGet(ctx context.Context, params *pb.AudienceGetRequest) (*pb.Audience, error)
AudienceGet implements the pb.HiroServer interface
func (*RPCServer) AudienceList ¶
func (s *RPCServer) AudienceList(req *pb.AudienceListRequest, stream pb.Hiro_AudienceListServer) error
AudienceList implements the pb.HiroServer interface
func (*RPCServer) AudienceUpdate ¶
func (s *RPCServer) AudienceUpdate(ctx context.Context, params *pb.AudienceUpdateRequest) (*pb.Audience, error)
AudienceUpdate implements the pb.HiroServer interface
func (*RPCServer) SecretCreate ¶
func (s *RPCServer) SecretCreate(ctx context.Context, params *pb.SecretCreateRequest) (*pb.Secret, error)
SecretCreate implements the pb.HiroServer interface
func (*RPCServer) SecreteDelete ¶
func (s *RPCServer) SecreteDelete(ctx context.Context, params *pb.SecretDeleteRequest) (*empty.Empty, error)
SecreteDelete implements the pb.HiroServer interface
type RequestToken ¶
type RequestToken struct { ID ID `json:"id" db:"id"` Type oauth.RequestTokenType `json:"type" db:"type"` CreatedAt oauth.Time `json:"created_at" db:"created_at"` Audience ID `json:"audience_id" db:"audience_id"` ApplicationID ID `json:"application_id" db:"application_id"` UserID ID `json:"user_id,omitempty" db:"user_id"` Scope oauth.Scope `json:"scope,omitempty" db:"scope"` Passcode *string `json:"passcode,omitempty" db:"passcode"` ExpiresAt oauth.Time `json:"expires_at" db:"expires_at"` CodeChallenge oauth.PKCEChallenge `json:"code_challenge,omitempty" db:"code_challenge"` CodeChallengeMethod oauth.PKCEChallengeMethod `json:"code_challenge_method,omitempty" db:"code_challenge_method"` LoginAttempts *int `json:"login_attempts,omitempty" db:"login_attempts"` AppURI *oauth.URI `json:"app_uri,omitempty" db:"app_uri"` RedirectURI *oauth.URI `json:"redirect_uri,omitempty" db:"redirect_uri"` State *string `json:"state,omitempty" db:"state"` }
RequestToken is the backend representation of an oauth.RequestToken
type Role ¶
type Role struct { ID ID `json:"id" db:"id"` AudienceID ID `json:"audience_id" db:"audience_id"` Name string `json:"name" db:"name"` Slug string `json:"slug" db:"slug"` Description *string `json:"description,omitempty" db:"description"` Permissions oauth.ScopeSet `json:"permissions,omitempty" db:"-"` CreatedAt time.Time `json:"created_at" db:"created_at"` UpdatedAt *time.Time `json:"updated_at,omitempty" db:"updated_at"` Metadata common.Map `json:"metadata,omitempty" db:"metadata"` }
Role is the database model for an role
type RoleController ¶ added in v0.1.1
type RoleController interface { RoleCreate(ctx context.Context, params RoleCreateInput) (*Role, error) RoleGet(ctx context.Context, params RoleGetInput) (*Role, error) RoleList(ctx context.Context, params RoleListInput) ([]*Role, error) RoleUpdate(ctx context.Context, params RoleUpdateInput) (*Role, error) RoleDelete(ctx context.Context, params RoleDeleteInput) error }
RoleController is roles API interfcace
type RoleCreateInput ¶
type RoleCreateInput struct { AudienceID ID `json:"audience_id"` Name string `json:"name"` Description *string `json:"description,omitempty"` Permissions oauth.ScopeSet `json:"permissions,omitempty"` Metadata common.Map `json:"metadata,omitempty"` }
RoleCreateInput is the role create request
func (RoleCreateInput) ValidateWithContext ¶
func (a RoleCreateInput) ValidateWithContext(ctx context.Context) error
ValidateWithContext handles validation of the RoleCreateInput struct
type RoleDeleteInput ¶
type RoleDeleteInput struct {
RoleID ID `json:"role_id"`
}
RoleDeleteInput is the role delete request input
func (RoleDeleteInput) ValidateWithContext ¶
func (a RoleDeleteInput) ValidateWithContext(ctx context.Context) error
ValidateWithContext handles validation of the RoleDeleteInput
type RoleGetInput ¶
type RoleGetInput struct { RoleID *ID `json:"role_id,omitempty"` Name *string `json:"name,omitempty"` Preload *bool `json:"preload,omitempty"` }
RoleGetInput is used to get an role for the id
func (RoleGetInput) ValidateWithContext ¶
func (a RoleGetInput) ValidateWithContext(ctx context.Context) error
ValidateWithContext handles validation of the RoleGetInput struct
type RoleListInput ¶
type RoleListInput struct { Limit *uint64 `json:"limit,omitempty"` Offset *uint64 `json:"offset,omitempty"` }
RoleListInput is the role list request
func (RoleListInput) ValidateWithContext ¶
func (a RoleListInput) ValidateWithContext(context.Context) error
ValidateWithContext handles validation of the RoleListInput struct
type RoleUpdateInput ¶
type RoleUpdateInput struct { RoleID ID `json:"id" structs:"-"` Name *string `json:"name" structs:"name,omitempty"` Description *string `json:"description,omitempty" structs:"description,omitempty"` Permissions *PermissionsUpdate `json:"permissions,omitempty" structs:"-"` Metadata common.Map `json:"metadata,omitempty" structs:"metadata,omitempty"` }
RoleUpdateInput is the role update request
func (RoleUpdateInput) ValidateWithContext ¶
func (a RoleUpdateInput) ValidateWithContext(ctx context.Context) error
ValidateWithContext handles validation of the RoleUpdateInput struct
type Secret ¶
type Secret struct { ID ID `json:"id" db:"id"` Type SecretType `json:"type"` AudienceID ID `json:"audience_id" db:"audience_id"` Algorithm *oauth.TokenAlgorithm `json:"algorithm,omitempty" db:"algorithm"` Key string `json:"key" db:"key"` CreatedAt time.Time `json:"created_at" db:"created_at"` ExpiresAt *time.Time `json:"expires_at,omitempty" db:"expires_at"` }
Secret is a secret key implemenation of oauth.TokenSecret
type SecretCreateInput ¶
type SecretCreateInput struct { AudienceID ID `json:"audience_id"` Type SecretType `json:"type"` Algorithm *oauth.TokenAlgorithm `json:"algorithm,omitempty"` Key *string `json:"key,omitempty"` ExpiresAt *time.Time `json:"expires_at,omitempty"` }
SecretCreateInput is the params used to create a secret
func (SecretCreateInput) ValidateWithContext ¶
func (s SecretCreateInput) ValidateWithContext(ctx context.Context) error
ValidateWithContext handles validation of the AudienceCreateInput struct
type SecretCreateRoute ¶
type SecretCreateRoute func(ctx context.Context, params *SecretCreateInput) api.Responder
SecretCreateRoute is the secret create route definition
func (SecretCreateRoute) Methods ¶
func (SecretCreateRoute) Methods() []string
Methods implements api.Route
func (SecretCreateRoute) RequireAuth ¶
func (SecretCreateRoute) RequireAuth() []api.CredentialType
RequireAuth implements the api.AuthorizedRoute
func (SecretCreateRoute) Scopes ¶
func (SecretCreateRoute) Scopes() oauth.ScopeList
Scopes implements oauth.Route
type SecretDeleteInput ¶
type SecretDeleteInput struct {
SecretID ID `json:"secret_id"`
}
SecretDeleteInput is the secret delete request input
func (SecretDeleteInput) ValidateWithContext ¶
func (s SecretDeleteInput) ValidateWithContext(ctx context.Context) error
ValidateWithContext handles validation of the SecretDeleteInput
type SecretDeleteRoute ¶
type SecretDeleteRoute func(ctx context.Context, params *SecretDeleteInput) api.Responder
SecretDeleteRoute is the secret create route definition
func (SecretDeleteRoute) Methods ¶
func (SecretDeleteRoute) Methods() []string
Methods implements api.Route
func (SecretDeleteRoute) RequireAuth ¶
func (SecretDeleteRoute) RequireAuth() []api.CredentialType
RequireAuth implements the api.AuthorizedRoute
func (SecretDeleteRoute) Scopes ¶
func (SecretDeleteRoute) Scopes() oauth.ScopeList
Scopes implements oauth.Route
type SecretType ¶
type SecretType string
SecretType is a secret type
const ( // SecretTypeToken are used for token signing SecretTypeToken SecretType = "token" // SecretTypeSession are used for session signing SecretTypeSession SecretType = "session" )
type SecretsController ¶ added in v0.1.1
type SecretsController interface { SecretCreate(ctx context.Context, params SecretCreateInput) (*Secret, error) SecretDelete(ctx context.Context, params SecretDeleteInput) error }
SecretsController is the secrets API interface
type Service ¶ added in v0.1.1
type Service struct {
// contains filtered or unexported fields
}
Service is the core hiro service object Platoform projects use the hiro.Service to provide services
func NewService ¶ added in v0.1.1
func NewService(opts ...ServiceOption) (*Service, error)
NewService creates a new service object
func (*Service) APIServer ¶ added in v0.1.1
APIServer returns the api server that services can register with
func (*Service) RPCServer ¶ added in v0.1.1
RPCServer returns the rpc server services can register with
type ServiceOption ¶ added in v0.1.1
type ServiceOption func(d *Service)
ServiceOption is a service option
func WithAPIOptions ¶
func WithAPIOptions(o ...api.Option) ServiceOption
WithAPIOptions sets api server options; mutally exclusive with WithAPIServer
func WithAPIServer ¶
func WithAPIServer(srv *api.Server) ServiceOption
WithAPIServer sets the service api server; mutally exclusive with WithAPIOptions
func WithBackendOptions ¶
func WithBackendOptions(o []BackendOption) ServiceOption
WithBackendOptions sets backend options
func WithController ¶
func WithController(c Controller) ServiceOption
WithController sets the service controller
func WithOAuthController ¶
func WithOAuthController(o oauth.Controller) ServiceOption
WithOAuthController set the service oauth controller
func WithRPCServer ¶
func WithRPCServer(r *grpc.Server) ServiceOption
WithRPCServer sets the service rpc server
func WithServerAddr ¶
func WithServerAddr(addr string) ServiceOption
WithServerAddr sets the service listening address
func WithSessionController ¶
func WithSessionController(c session.Controller) ServiceOption
WithSessionController set the service session controller
type Session ¶
type Session struct { ID ID `json:"id" db:"id"` AudienceID ID `json:"audience_id" db:"audience_id"` UserID ID `json:"user_id" db:"user_id"` Data string `json:"data" db:"data"` CreatedAt time.Time `json:"created_at" db:"created_at"` ExpiresAt time.Time `json:"expires_at" db:"expires_at"` RevokedAt *time.Time `json:"revoked_at,omitempty" db:"revoked_at"` }
Session is the backend store representation of session.Session
type SpecGetInput ¶
SpecGetInput is the input for spec get method
type SpecRoute ¶
type SpecRoute func(ctx context.Context, params *SpecGetInput) api.Responder
SpecRoute is the swagger spec route handler
type User ¶
type User struct { ID ID `json:"id" db:"id"` CreatedAt time.Time `json:"created_at" db:"created_at"` UpdatedAt *time.Time `json:"updated_at,omitempty" db:"updated_at"` Login string `json:"login" db:"login"` Password *string `json:"-" db:"-"` PasswordHash *string `json:"-" db:"password_hash,omitempty"` PasswordExpiresAt *time.Time `json:"password_expires_at,omitempty" db:"password_expires_at"` LockedUntil *time.Time `json:"locked_until,omitempty" db:"locked_until,omitempty"` Roles []string `json:"roles,omitempty"` Permissions oauth.ScopeSet `json:"permissions,omitempty" db:"-"` Profile *openid.Profile `json:"profile,omitempty" db:"profile"` Metadata common.Map `json:"metadata,omitempty" db:"metadata"` }
User is a hiro user
type UserController ¶ added in v0.1.1
type UserController interface { UserCreate(ctx context.Context, params UserCreateInput) (*User, error) UserGet(ctx context.Context, params UserGetInput) (*User, error) UserList(ctx context.Context, params UserListInput) ([]*User, error) UserUpdate(ctx context.Context, params UserUpdateInput) (*User, error) UserDelete(ctx context.Context, params UserDeleteInput) error }
UserController is the user API interface
type UserCountRoute ¶
type UserCountRoute func(ctx context.Context, params *UserListInput) api.Responder
UserCountRoute is the user count route definition
func (UserCountRoute) Methods ¶
func (UserCountRoute) Methods() []string
Methods implements api.Route
func (UserCountRoute) RequireAuth ¶
func (UserCountRoute) RequireAuth() []api.CredentialType
RequireAuth implements the api.AuthorizedRoute
func (UserCountRoute) Scopes ¶
func (UserCountRoute) Scopes() oauth.ScopeList
Scopes implements oauth.Route
type UserCreateInput ¶
type UserCreateInput struct { Login string `json:"login"` Password *string `json:"password,omitempty"` Roles []string `json:"roles,omitempty"` Profile *openid.Profile `json:"profile,omitempty"` PasswordExpiresAt *time.Time `json:"password_expires_at,omitempty" ` Metadata common.Map `json:"metadata,omitempty"` }
UserCreateInput is the user create request input
func (UserCreateInput) ValidateWithContext ¶
func (u UserCreateInput) ValidateWithContext(ctx context.Context) error
ValidateWithContext handles validation of the UserCreateInput struct
type UserCreateRoute ¶
type UserCreateRoute func(ctx context.Context, params *UserCreateInput) api.Responder
UserCreateRoute is the user create route definition
func (UserCreateRoute) Methods ¶
func (UserCreateRoute) Methods() []string
Methods implements api.Route
func (UserCreateRoute) RequireAuth ¶
func (UserCreateRoute) RequireAuth() []api.CredentialType
RequireAuth implements the api.AuthorizedRoute
func (UserCreateRoute) Scopes ¶
func (UserCreateRoute) Scopes() oauth.ScopeList
Scopes implements oauth.Route
type UserDeleteInput ¶
type UserDeleteInput struct {
UserID ID `json:"user_id"`
}
UserDeleteInput is the user delete request input
func (UserDeleteInput) ValidateWithContext ¶
func (u UserDeleteInput) ValidateWithContext(ctx context.Context) error
ValidateWithContext handles validation of the UserDeleteInput
type UserDeleteRoute ¶
type UserDeleteRoute func(ctx context.Context, params *UserDeleteInput) api.Responder
UserDeleteRoute is the user create route definition
func (UserDeleteRoute) Methods ¶
func (UserDeleteRoute) Methods() []string
Methods implements api.Route
func (UserDeleteRoute) RequireAuth ¶
func (UserDeleteRoute) RequireAuth() []api.CredentialType
RequireAuth implements the api.AuthorizedRoute
func (UserDeleteRoute) Scopes ¶
func (UserDeleteRoute) Scopes() oauth.ScopeList
Scopes implements oauth.Route
type UserGetInput ¶
type UserGetInput struct { UserID ID `json:"user_id,omitempty"` Login *string `json:"login,omitempty"` }
UserGetInput is used to get an user for the id
func (UserGetInput) ValidateWithContext ¶
func (u UserGetInput) ValidateWithContext(ctx context.Context) error
ValidateWithContext handles validation of the UserGetInput struct
type UserGetRoute ¶
type UserGetRoute func(ctx context.Context, params *UserGetInput) api.Responder
UserGetRoute is the user create route definition
func (UserGetRoute) RequireAuth ¶
func (UserGetRoute) RequireAuth() []api.CredentialType
RequireAuth implements the api.AuthorizedRoute
func (UserGetRoute) Scopes ¶
func (UserGetRoute) Scopes() oauth.ScopeList
Scopes implements oauth.Route
type UserListInput ¶
type UserListInput struct { Limit *uint64 `json:"limit,omitempty"` Offset *uint64 `json:"offset,omitempty"` Count *uint64 `json:"count,omitempty"` }
UserListInput is the user list request
func (UserListInput) ValidateWithContext ¶
func (u UserListInput) ValidateWithContext(context.Context) error
ValidateWithContext handles validation of the UserListInput struct
type UserListRoute ¶
type UserListRoute func(ctx context.Context, params *UserListInput) api.Responder
UserListRoute is the user count route definition
func (UserListRoute) RequireAuth ¶
func (UserListRoute) RequireAuth() []api.CredentialType
RequireAuth implements the api.AuthorizedRoute
func (UserListRoute) Scopes ¶
func (UserListRoute) Scopes() oauth.ScopeList
Scopes implements oauth.Route
type UserUpdateInput ¶
type UserUpdateInput struct { UserID ID `json:"user_id" structs:"-"` Login *string `json:"login,omitempty"` Password *string `json:"password,omitempty" structs:"-"` Profile *openid.Profile `json:"profile,omitempty" structs:"profile,omitempty"` PasswordExpiresAt *time.Time `json:"-" structs:"password_expires_at,omitempty"` LockedUntil *time.Time `json:"locked_until,omitempty" structs:"-"` Roles []string `json:"roles,omitempty" structs:"-"` Metadata common.Map `json:"metadata,omitempty" structs:"-"` }
UserUpdateInput is the update user request input
func (UserUpdateInput) ValidateWithContext ¶
func (u UserUpdateInput) ValidateWithContext(ctx context.Context) error
ValidateWithContext handles validation of the UserCreateInput struct
type UserUpdateRoute ¶
type UserUpdateRoute func(ctx context.Context, params *UserUpdateInput) api.Responder
UserUpdateRoute is the user create route definition
func (UserUpdateRoute) Methods ¶
func (UserUpdateRoute) Methods() []string
Methods implements api.Route
func (UserUpdateRoute) RequireAuth ¶
func (UserUpdateRoute) RequireAuth() []api.CredentialType
RequireAuth implements the api.AuthorizedRoute
func (UserUpdateRoute) Scopes ¶
func (UserUpdateRoute) Scopes() oauth.ScopeList
Scopes implements oauth.Route
Source Files
¶
- application.go
- asset.go
- audience.go
- backend.go
- controller.go
- db.go
- errors.go
- hiro.go
- id.go
- oauth.go
- option.go
- password.go
- role.go
- route_application.go
- route_asset.go
- route_audience.go
- route_secret.go
- route_session.go
- route_swagger.go
- route_token.go
- route_user.go
- routes.go
- rpc_application.go
- rpc_audience.go
- rpc_secret.go
- rpc_server.go
- rpc_user.go
- scopes.go
- secret.go
- service.go
- session.go
- user.go