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 Log(ctx context.Context) log.Interface
- func ParseSQLError(err error) error
- func RegisterOptionUpdateHandler(key string, handler OptionUpdateHandler)
- func Routes() []api.Route
- func WithLogger(ctx context.Context, log log.Interface) context.Context
- type API
- type APIController
- type APICreateParams
- type APIGetParams
- type APIImportParams
- type AccessToken
- type Application
- type ApplicationController
- type ApplicationCountRoute
- type ApplicationCreateInput
- type ApplicationCreateRoute
- type ApplicationDeleteInput
- type ApplicationDeleteRoute
- type ApplicationEndpoint
- type ApplicationEndpointType
- type ApplicationGetInput
- type ApplicationGetRoute
- type ApplicationGrant
- 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 Controller
- type DB
- type DBController
- type Domain
- type DomainController
- type DomainCreateParams
- type DomainGetParams
- type EndpointUpdate
- type Expand
- type Expandable
- type GrantUpdate
- type Hiro
- func (h *Hiro) APICreate(ctx context.Context, params APICreateParams) (*API, error)
- func (h *Hiro) APIGet(ctx context.Context, params APIGetParams) (*API, error)
- func (h *Hiro) APIImport(ctx context.Context, params APIImportParams) (*API, error)
- func (h *Hiro) ApplicationCreate(ctx context.Context, params ApplicationCreateInput) (*Application, error)
- func (h *Hiro) ApplicationDelete(ctx context.Context, params ApplicationDeleteInput) error
- func (h *Hiro) ApplicationGet(ctx context.Context, params ApplicationGetInput) (*Application, error)
- func (h *Hiro) ApplicationList(ctx context.Context, params ApplicationListInput) ([]*Application, error)
- func (h *Hiro) ApplicationUpdate(ctx context.Context, params ApplicationUpdateInput) (*Application, error)
- func (h *Hiro) AssetCreate(ctx context.Context, params AssetCreateInput) (*Asset, error)
- func (h *Hiro) AssetDelete(ctx context.Context, params AssetDeleteInput) error
- func (h *Hiro) AssetGet(ctx context.Context, params AssetGetInput) (*Asset, error)
- func (h *Hiro) AssetList(ctx context.Context, params AssetListInput) ([]*Asset, error)
- func (h *Hiro) AssetUpdate(ctx context.Context, params AssetUpdateInput) (*Asset, error)
- func (h *Hiro) Context(ctx context.Context) context.Context
- func (b *Hiro) DB(ctx context.Context) DB
- func (h *Hiro) DomainCreate(ctx context.Context, params DomainCreateParams) (*Domain, error)
- func (h *Hiro) DomainGet(ctx context.Context, params DomainGetParams) (*Domain, error)
- func (h *Hiro) InstanceCreate(ctx context.Context, params InstanceCreateParams) (*Instance, error)
- func (h *Hiro) InstanceDelete(ctx context.Context, params InstanceDeleteParams) error
- func (h *Hiro) InstanceGet(ctx context.Context, params InstanceGetParams) (*Instance, error)
- func (h *Hiro) InstanceList(ctx context.Context, params InstanceListParams) ([]*Instance, error)
- func (h *Hiro) InstanceUpdate(ctx context.Context, params InstanceUpdateParams) (*Instance, error)
- func (h *Hiro) OAuthController() oauth.Controller
- func (h *Hiro) OptionGet(ctx context.Context, params OptionGetParams) (*Option, error)
- func (h *Hiro) OptionList(ctx context.Context, params OptionListParams) (Options, error)
- func (h *Hiro) OptionRemove(ctx context.Context, params OptionRemoveParams) error
- func (h *Hiro) OptionUpdate(ctx context.Context, params OptionUpdateParams) (*Option, error)
- func (h *Hiro) PasswordManager() PasswordManager
- func (h *Hiro) PermissionCreate(ctx context.Context, params PermissionCreateParams) (*Permission, error)
- func (h *Hiro) RoleCreate(ctx context.Context, params RoleCreateInput) (*Role, error)
- func (h *Hiro) RoleDelete(ctx context.Context, params RoleDeleteInput) error
- func (h *Hiro) RoleGet(ctx context.Context, params RoleGetInput) (*Role, error)
- func (h *Hiro) RoleList(ctx context.Context, params RoleListInput) ([]*Role, error)
- func (h *Hiro) RoleUpdate(ctx context.Context, params RoleUpdateInput) (*Role, error)
- func (h *Hiro) SecretCreate(ctx context.Context, params SecretCreateInput) (*Secret, error)
- func (h *Hiro) SecretDelete(ctx context.Context, params SecretDeleteInput) error
- func (h *Hiro) SessionCleanup(ctx context.Context) error
- func (h *Hiro) SessionCreate(ctx context.Context, sess *session.Session) error
- func (h *Hiro) SessionDestroy(ctx context.Context, id string) error
- func (h *Hiro) SessionLoad(ctx context.Context, id string) (session.Session, error)
- func (h *Hiro) SessionOptions(ctx context.Context, id string) (session.Options, error)
- func (h *Hiro) SessionUpdate(ctx context.Context, sess *session.Session) error
- func (h *Hiro) SpecCreate(ctx context.Context, params SpecCreateParams) (*Spec, error)
- func (b *Hiro) Transact(ctx context.Context, handler TxHandler, ignore ...error) (err error)
- func (h *Hiro) UserCreate(ctx context.Context, params UserCreateInput) (*User, error)
- func (h *Hiro) UserDelete(ctx context.Context, params UserDeleteInput) error
- func (h *Hiro) UserGet(ctx context.Context, params UserGetInput) (*User, error)
- func (h *Hiro) UserList(ctx context.Context, params UserListInput) ([]*User, error)
- func (h *Hiro) UserUpdate(ctx context.Context, params UserUpdateInput) (*User, error)
- type HiroOption
- type ID
- type Instance
- type InstanceController
- type InstanceCountRoute
- type InstanceCreateParams
- type InstanceCreateRoute
- type InstanceDeleteParams
- type InstanceDeleteRoute
- type InstanceGetParams
- type InstanceGetRoute
- type InstanceListParams
- type InstanceListRoute
- type InstanceUpdateParams
- type InstanceUpdateRoute
- type Job
- type ListParams
- type Option
- type OptionController
- type OptionGetParams
- type OptionListParams
- type OptionRemoveParams
- type OptionUpdateHandler
- type OptionUpdateParams
- type Options
- type Params
- type PasswordManager
- type Permission
- type PermissionController
- type PermissionCreateParams
- type PermissionUpdate
- type RPCServer
- func (s *RPCServer) APICreate(ctx context.Context, params *pb.APICreateRequest) (*pb.API, error)
- 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) InstanceCreate(ctx context.Context, params *pb.InstanceCreateRequest) (*pb.Instance, error)
- func (s *RPCServer) InstanceDelete(ctx context.Context, params *pb.InstanceDeleteRequest) (*empty.Empty, error)
- func (s *RPCServer) InstanceGet(ctx context.Context, params *pb.InstanceGetRequest) (*pb.Instance, error)
- func (s *RPCServer) InstanceList(req *pb.InstanceListRequest, stream pb.Hiro_InstanceListServer) error
- func (s *RPCServer) InstanceUpdate(ctx context.Context, params *pb.InstanceUpdateRequest) (*pb.Instance, 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 RoleUpdate
- type RoleUpdateInput
- type SchemaMigration
- 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 []HiroOption) 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 Spec
- type SpecController
- type SpecCreateParams
- type SpecFormat
- type SpecGetInput
- type SpecRoute
- type SpecType
- 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 UserPermission
- type UserRole
- type UserUpdateInput
- type UserUpdateRoute
Constants ¶
const ( // DefaultTokenAlgorithm is the default token algorithm DefaultTokenAlgorithm = oauth.TokenAlgorithmRS256 // DefaultTokenLifetime is the default instance token lifetime DefaultTokenLifetime = time.Hour // DefaultSessionLifetime is the default instance session lifetime DefaultSessionLifetime = time.Hour * 24 // DefaultRefreshTokenLifetime is the default refresh token lifetime DefaultRefreshTokenLifetime = time.Hour * 24 * 7 // DefaultLoginTokenLifetime is the default login token lifetime used for magic links, etc DefaultLoginTokenLifetime = time.Minute * 15 // DefaultInviteTokenLifetime is the token lifetime for invitation links DefaultInviteTokenLifetime = time.Hour * 24 * 7 // DefaultVerifyTokenLifetime is the default two-factor verification code lifetime DefaultVerifyTokenLifetime = time.Hour * 24 // DefaultAuthCodeLifetime is the default lifetime for oauth auth codes DefaultAuthCodeLifetime = time.Minute * 10 // RoleSuperAdmin is the superadmin scope RoleSuperAdmin = "superadmin" // RoleAdmin is the default admin role name RoleAdmin = "admin" // RoleUser is the default user role RoleUser = "user" )
const ( // ScopeInstanceRead is used to read instance properties ScopeInstanceRead = "instance:read" // ScopeInstanceWrite is used to create or modify instances ScopeInstanceWrite = "instance: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 ( SpecTypeOpenAPI SpecType = "openapi" SpecTypeRPC SpecType = "rpc" SpecFormatSwagger SpecFormat = "swagger-2.0" SpecFormatGrpcProto2 SpecFormat = "grpc-proto2" )
const ( // MaxPasswordAge is the max age of a password before it must be changed MaxPasswordAge = time.Hour * 24 * 90 )
Variables ¶
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.ErrTimeout.WithDetail("database connection timeout") // ErrContextNotFound is returned when hiro is not in the context ErrContextNotFound = api.ErrServerError.WithDetail("hiro not found in context") )
var ( // Scopes is the spec defined oauth 2.0 scopes for the Hiro API Scopes = append(oauth.Scopes, ScopeInstanceRead, ScopeInstanceWrite, ScopeApplicationRead, ScopeApplicationWrite, ScopeUserRead, ScopeUserWrite, ScopeTokenRead, ScopeTokenCreate, ScopeTokenRevoke, ScopeSessionRead, ScopeSessionRevoke, ScopeRoleRead, ScopeRoleWrite, ScopeAssetRead, ScopeAssetWrite, ) ScopesReadOnly = append(oauth.Scopes, ScopeInstanceRead, ScopeApplicationRead, ScopeUserRead, ScopeTokenRead, ScopeTokenCreate, ScopeTokenRevoke, ScopeSessionRead, ScopeSessionRevoke, ScopeRoleRead, ScopeAssetRead, ) // Roles is the list of hiro roles by name Roles = map[string]oauth.Scope{ RoleAdmin: Scopes, RoleUser: append(ScopesReadOnly, ScopeUserWrite), } )
var (
// DefaultPasswordManager is the default password manager
DefaultPasswordManager = passwordManager{}
)
var (
ExpandAll = []string{"*"}
)
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 RegisterOptionUpdateHandler ¶
func RegisterOptionUpdateHandler(key string, handler OptionUpdateHandler)
RegisterOptionUpdateHandler registers an update handler for options
Types ¶
type API ¶ added in v0.1.2
type API 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"` Name string `json:"name" db:"name"` Description *string `json:"description,omitempty" db:"description"` Specs []Spec `json:"specs,omitempty" db:"-"` Permissions []Permission `json:"permissions,omitempty" db:"-"` Metadata common.Map `json:"metadata,omitempty" db:"metadata"` }
API defines an api specification managed by hiro
type APIController ¶ added in v0.1.2
type APIController interface { APICreate(ctx context.Context, params APICreateParams) (*API, error) APIImport(ctx context.Context, params APICreateParams) (*API, error) APIGet(ctx context.Context, params APIGetParams) (*API, error) }
APIController is the API management interface
type APICreateParams ¶ added in v0.1.2
type APICreateParams struct { Params Name string `json:"name"` Description *string `json:"description,omitempty"` Specs []SpecCreateParams `json:"specs,omitempty"` Permissions []PermissionCreateParams `json:"permissions,omitempty"` }
APICreateParams is the input for APICreate
func (APICreateParams) ValidateWithContext ¶ added in v0.1.2
func (p APICreateParams) ValidateWithContext(ctx context.Context) error
ValidateWithContext validates the APICreateInput type
type APIGetParams ¶ added in v0.1.2
type APIGetParams struct { Params ID *ID `json:"id,omitempty"` Name *string `json:"name,omitempty"` }
APIGetParams is the input for APIGet
func (APIGetParams) ValidateWithContext ¶ added in v0.1.2
func (p APIGetParams) ValidateWithContext(ctx context.Context) error
ValidateWithContext validates the APICreateInput type
type APIImportParams ¶ added in v0.1.2
type APIImportParams struct { Params *APICreateParams SpecCreateParams }
APIImportParams is the input for APIImport
func (APIImportParams) ValidateWithContext ¶ added in v0.1.2
func (p APIImportParams) ValidateWithContext(ctx context.Context) error
ValidateWithContext validates the APICreateInput type
type AccessToken ¶
type AccessToken struct { ID ID `json:"id" db:"id"` Issuer *string `json:"issuer,omitempty" db:"issuer"` InstanceID ID `json:"instance_id" db:"instance_id"` Audience string `json:"audience" db:"audience"` ApplicationID ID `json:"application_id" db:"application_id"` ClientID string `json:"client_id" db:"client_id"` UserID ID `json:"user_id,omitempty" db:"user_id,omitempty"` Use oauth.TokenUse `json:"token_use" db:"token_use"` AuthTime *time.Time `db:"-"` Scope oauth.Scope `json:"scope,omitempty" db:"scope"` CreatedAt time.Time `json:"created_at" db:"created_at"` ExpiresAt *time.Time `json:"expires_at,omitempty" db:"expires_at"` Revokable bool `db:"-"` RevokedAt *time.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"` DomainID ID `json:"domain_id" db:"domain_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"` ClientID *string `json:"client_id,omitempty" db:"client_id"` ClientSecret *string `json:"client_secret,omitempty" db:"client_secret"` TokenSecretID *ID `json:"token_secret_id,omitempty" db:"token_secret_id"` TokenSecret *Secret `json:"-" db:"-"` Permissions []Permission `json:"permissions,omitempty" db:"-"` Grants []ApplicationGrant `json:"grants,omitempty" db:"-"` Endpoints []ApplicationEndpoint `json:"uris,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"` Domain *Domain `json:"domain,omitempty" db:"-"` }
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 { InstanceID ID `json:"instance_id"` Name string `json:"name"` Description *string `json:"description,omitempty"` Type oauth.ClientType `json:"type"` TokenSecretID *ID `json:"token_secret_id,omitempty"` Permissions []Permission `json:"permissions,omitempty"` Grants []ApplicationGrant `json:"grants,omitempty"` Endpoints []ApplicationEndpoint `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 { DomainID ID `json:"instance_id" db:"instance_id"` 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 ApplicationEndpoint ¶ added in v0.1.2
type ApplicationEndpoint struct { InstanceID ID `json:"instance_id"` URI string `json:"uri"` Type ApplicationEndpointType `json:"type"` }
ApplicationEndpoint is an application uri
type ApplicationEndpointType ¶ added in v0.1.2
type ApplicationEndpointType string
ApplicationEndpointType is an application uri type
const ( ApplicationEndpointTypeApp ApplicationEndpointType = "application" ApplicationEndpointTypeRedirect ApplicationEndpointType = "redirect" )
type ApplicationGetInput ¶
type ApplicationGetInput struct { DomainID ID `json:"-"` ApplicationID *ID `json:"application_id,omitempty"` Expand common.StringSlice `json:"expand,omitempty"` ClientID *string `json:"-"` Name *string `json:"-"` }
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 ApplicationGrant ¶ added in v0.1.2
type ApplicationGrant struct { InstanceID ID `json:"instance_id"` Type oauth.GrantType `json:"grant_type"` }
ApplicationGrant is an application grant entry
type ApplicationListInput ¶
type ApplicationListInput struct { DomainID ID `json:"-"` Expand common.StringSlice `json:"expand,omitempty"` 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:"-"` InstanceID ID `json:"instance_id" db:"instance_id"` Name *string `json:"name" structs:"name,omitempty"` Description *string `json:"description,omitempty" structs:"description,omitempty"` Type *oauth.ClientType `json:"type" structs:"type,omitempty"` TokenSecretID *ID `json:"token_secret_id,omitempty" structs:"token_secret_id,omitempty"` Permissions PermissionUpdate `json:"permissions,omitempty" structs:"-"` Grants GrantUpdate `json:"grants,omitempty" structs:"-"` Endpoints EndpointUpdate `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"` InstanceID ID `json:"instance_id" db:"instance_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 { InstanceID ID `json:"instance_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 { InstanceID ID `json:"instance_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 { InstanceID ID `json:"instance_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 { InstanceID ID `json:"instance_id" structs:"instance_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 Controller ¶
type Controller interface { InstanceController SecretsController ApplicationController RoleController UserController AssetController }
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 DBController ¶ added in v0.1.2
type DBController 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 }
DBController is the db interface
type Domain ¶ added in v0.1.3
type Domain 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"` Name string `json:"name" db:"name"` Description *string `json:"description,omitempty" db:"description"` Metadata common.Map `json:"metadata,omitempty" db:"metadata"` Secrets []Secret `json:"secrets,omitempty" db:"-"` Permissions []Permission `json:"permissions" db:"-"` Options Options `json:"options,omitempty" db:"-"` }
Domain defines an domain specification managed by hiro
type DomainController ¶ added in v0.1.3
type DomainController interface { DomainCreate(ctx context.Context, params DomainCreateParams) (*Domain, error) DomainGet(ctx context.Context, params DomainGetParams) (*Domain, error) }
DomainController is the Domain management interface
type DomainCreateParams ¶ added in v0.1.3
type DomainCreateParams struct { Params Name string `json:"name"` Description *string `json:"description,omitempty"` Audience string `json:"audience"` }
DomainCreateParams is the input for DomainCreate
func (DomainCreateParams) ValidateWithContext ¶ added in v0.1.3
func (p DomainCreateParams) ValidateWithContext(ctx context.Context) error
ValidateWithContext validates the DomainCreateInput type
type DomainGetParams ¶ added in v0.1.3
type DomainGetParams struct { Params ID *ID `json:"id,omitempty"` Name *string `json:"name,omitempty"` }
DomainGetParams is the input for DomainGet
func (DomainGetParams) ValidateWithContext ¶ added in v0.1.3
func (p DomainGetParams) ValidateWithContext(ctx context.Context) error
ValidateWithContext validates the DomainCreateInput type
type EndpointUpdate ¶ added in v0.1.2
type EndpointUpdate struct { Add []ApplicationEndpoint `json:"add,omitempty"` Remove []ApplicationEndpoint `json:"remove,omitempty"` }
EndpointUpdate is used to modify application URIs
type Expand ¶ added in v0.1.2
type Expand common.StringSlice
type Expandable ¶ added in v0.1.3
type GrantUpdate ¶ added in v0.1.2
type GrantUpdate struct { Add []ApplicationGrant `json:"add,omitempty"` Remove []ApplicationGrant `json:"remove,omitempty"` }
GrantUpdate is used to modify application grants
type Hiro ¶ added in v0.1.2
type Hiro struct {
// contains filtered or unexported fields
}
Hiro is the hiro api backend implementation
func FromContext ¶
FromContext returns a hiro from the context
func (*Hiro) ApplicationCreate ¶ added in v0.1.2
func (h *Hiro) ApplicationCreate(ctx context.Context, params ApplicationCreateInput) (*Application, error)
ApplicationCreate create a new permission object
func (*Hiro) ApplicationDelete ¶ added in v0.1.2
func (h *Hiro) ApplicationDelete(ctx context.Context, params ApplicationDeleteInput) error
ApplicationDelete deletes an application by id
func (*Hiro) ApplicationGet ¶ added in v0.1.2
func (h *Hiro) ApplicationGet(ctx context.Context, params ApplicationGetInput) (*Application, error)
ApplicationGet gets an application by id and optionally preloads child objects
func (*Hiro) ApplicationList ¶ added in v0.1.2
func (h *Hiro) ApplicationList(ctx context.Context, params ApplicationListInput) ([]*Application, error)
ApplicationList returns a listing of applications
func (*Hiro) ApplicationUpdate ¶ added in v0.1.2
func (h *Hiro) ApplicationUpdate(ctx context.Context, params ApplicationUpdateInput) (*Application, error)
ApplicationUpdate updates an application by id, including child objects
func (*Hiro) AssetCreate ¶ added in v0.1.2
AssetCreate creates a new asset for the instance
func (*Hiro) AssetDelete ¶ added in v0.1.2
func (h *Hiro) AssetDelete(ctx context.Context, params AssetDeleteInput) error
AssetDelete deletes an asset
func (*Hiro) AssetUpdate ¶ added in v0.1.2
AssetUpdate updates an asset
func (*Hiro) DomainCreate ¶ added in v0.1.3
DomainCreate creates a new domain
func (*Hiro) InstanceCreate ¶ added in v0.1.2
InstanceCreate create a new permission object
func (*Hiro) InstanceDelete ¶ added in v0.1.2
func (h *Hiro) InstanceDelete(ctx context.Context, params InstanceDeleteParams) error
InstanceDelete deletes an instance by id
func (*Hiro) InstanceGet ¶ added in v0.1.2
InstanceGet gets an instance by id and optionally preloads child objects
func (*Hiro) InstanceList ¶ added in v0.1.2
InstanceList returns a listing of instances
func (*Hiro) InstanceUpdate ¶ added in v0.1.2
InstanceUpdate updates an application by id, including child objects
func (*Hiro) OAuthController ¶ added in v0.1.2
func (h *Hiro) OAuthController() oauth.Controller
func (*Hiro) OptionList ¶ added in v0.1.3
OptionGet returns a named option from the backend
func (*Hiro) OptionRemove ¶ added in v0.1.2
func (h *Hiro) OptionRemove(ctx context.Context, params OptionRemoveParams) error
OptionRemove removes the named option from the backend
func (*Hiro) OptionUpdate ¶ added in v0.1.2
OptionUpdate stores a named option in the backend data store
func (*Hiro) PasswordManager ¶ added in v0.1.2
func (h *Hiro) PasswordManager() PasswordManager
PasswordManager returns the current password manager for the instance
func (*Hiro) PermissionCreate ¶ added in v0.1.2
func (h *Hiro) PermissionCreate(ctx context.Context, params PermissionCreateParams) (*Permission, error)
func (*Hiro) RoleCreate ¶ added in v0.1.2
RoleCreate create a new permission object
func (*Hiro) RoleDelete ¶ added in v0.1.2
func (h *Hiro) RoleDelete(ctx context.Context, params RoleDeleteInput) error
RoleDelete deletes an role by id
func (*Hiro) RoleGet ¶ added in v0.1.2
RoleGet gets an role by id and optionally preloads child objects
func (*Hiro) RoleUpdate ¶ added in v0.1.2
RoleUpdate updates an role by id, including child objects
func (*Hiro) SecretCreate ¶ added in v0.1.2
SecretCreate creates a new secret, generating the key if not is provided
func (*Hiro) SecretDelete ¶ added in v0.1.2
func (h *Hiro) SecretDelete(ctx context.Context, params SecretDeleteInput) error
SecretDelete deletes an instance by id
func (*Hiro) SessionCleanup ¶ added in v0.1.2
SessionCleanup removes expired sessions
func (*Hiro) SessionCreate ¶ added in v0.1.2
SessionCreate creates a session
func (*Hiro) SessionDestroy ¶ added in v0.1.2
func (*Hiro) SessionLoad ¶ added in v0.1.2
SessionLoad gets a session by id
func (*Hiro) SessionOptions ¶ added in v0.1.2
func (*Hiro) SessionUpdate ¶ added in v0.1.2
SessionUpdate saves a session
func (*Hiro) SpecCreate ¶ added in v0.1.3
func (*Hiro) Transact ¶ added in v0.1.2
Transact starts a db transaction, adds it to the context and calls the handler
func (*Hiro) UserCreate ¶ added in v0.1.2
UserCreate create a new permission object
func (*Hiro) UserDelete ¶ added in v0.1.2
func (h *Hiro) UserDelete(ctx context.Context, params UserDeleteInput) error
UserDelete deletes an user by id
func (*Hiro) UserGet ¶ added in v0.1.2
UserGet gets an user by id and optionally preloads child objects
func (*Hiro) UserUpdate ¶ added in v0.1.2
UserUpdate updates an user by id, including child objects
type HiroOption ¶ added in v0.1.2
type HiroOption func(b *Hiro)
HiroOption defines a backend option
func Automigrate ¶
func Automigrate(m ...SchemaMigration) HiroOption
Automigrate will perform the database initialization, creating tables and indexes.
func WithAssetVolume ¶ added in v0.1.1
func WithAssetVolume(v string) HiroOption
WithAssetVolume sets the asset volume for the instance
func WithDBSource ¶
func WithDBSource(source string) HiroOption
WithDBSource sets the database source string
type ID ¶
type ID string
ID is the hiro uuid implementation wrapper that base58 encodes/decodes the values as text or json
func NewID ¶ added in v0.1.2
func NewID(id ...interface{}) ID
NewID 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 Instance ¶ added in v0.1.2
type Instance 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"` DomainID ID `json:"domain_id" db:"domain_id"` ApiID ID `json:"api_id" db:"api_id"` Name string `json:"name" db:"name"` Description *string `json:"description,omitempty" db:"description"` Metadata common.Map `json:"metadata,omitempty" db:"metadata"` API *API `json:"api,omitempty" db:"-"` Domain *Domain `json:"domain,omitempty" db:"-"` }
Instance is the database model for an instance
type InstanceController ¶ added in v0.1.2
type InstanceController interface { InstanceCreate(ctx context.Context, params InstanceCreateParams) (*Instance, error) InstanceGet(ctx context.Context, params InstanceGetParams) (*Instance, error) InstanceList(ctx context.Context, params InstanceListParams) ([]*Instance, error) InstanceUpdate(ctx context.Context, params InstanceUpdateParams) (*Instance, error) InstanceDelete(ctx context.Context, params InstanceDeleteParams) error }
InstanceController is the instance API interface
type InstanceCountRoute ¶ added in v0.1.2
type InstanceCountRoute func(ctx context.Context, params *InstanceListParams) api.Responder
InstanceCountRoute is the instance count route definition
func (InstanceCountRoute) Methods ¶ added in v0.1.2
func (InstanceCountRoute) Methods() []string
Methods implements api.Route
func (InstanceCountRoute) Name ¶ added in v0.1.2
func (InstanceCountRoute) Name() string
Name implements api.Route
func (InstanceCountRoute) Path ¶ added in v0.1.2
func (InstanceCountRoute) Path() string
Path implements api.Route
func (InstanceCountRoute) RequireAuth ¶ added in v0.1.2
func (InstanceCountRoute) RequireAuth() []api.CredentialType
RequireAuth implements the api.AuthorizedRoute
func (InstanceCountRoute) Scopes ¶ added in v0.1.2
func (InstanceCountRoute) Scopes() oauth.ScopeList
Scopes implements oauth.Route
type InstanceCreateParams ¶ added in v0.1.3
type InstanceCreateParams struct { Params DomainID ID `json:"domain_id"` ApiID ID `json:"api_id"` Name string `json:"name"` Description *string `json:"description,omitempty"` }
InstanceCreateParams is the instance create request
func (InstanceCreateParams) ValidateWithContext ¶ added in v0.1.3
func (i InstanceCreateParams) ValidateWithContext(ctx context.Context) error
ValidateWithContext handles validation of the InstanceCreateInput struct
type InstanceCreateRoute ¶ added in v0.1.2
type InstanceCreateRoute func(ctx context.Context, params *InstanceCreateParams) api.Responder
InstanceCreateRoute is the instance create route definition
func (InstanceCreateRoute) Methods ¶ added in v0.1.2
func (InstanceCreateRoute) Methods() []string
Methods implements api.Route
func (InstanceCreateRoute) Name ¶ added in v0.1.2
func (InstanceCreateRoute) Name() string
Name implements api.Route
func (InstanceCreateRoute) Path ¶ added in v0.1.2
func (InstanceCreateRoute) Path() string
Path implements api.Route
func (InstanceCreateRoute) RequireAuth ¶ added in v0.1.2
func (InstanceCreateRoute) RequireAuth() []api.CredentialType
RequireAuth implements the api.AuthorizedRoute
func (InstanceCreateRoute) Scopes ¶ added in v0.1.2
func (InstanceCreateRoute) Scopes() oauth.ScopeList
Scopes implements oauth.Route
type InstanceDeleteParams ¶ added in v0.1.3
InstanceDeleteParams is the instance delete request input
func (InstanceDeleteParams) ValidateWithContext ¶ added in v0.1.3
func (i InstanceDeleteParams) ValidateWithContext(ctx context.Context) error
ValidateWithContext handles validation of the ApplicationDeleteInput
type InstanceDeleteRoute ¶ added in v0.1.2
type InstanceDeleteRoute func(ctx context.Context, params *InstanceDeleteParams) api.Responder
InstanceDeleteRoute is the instance create route definition
func (InstanceDeleteRoute) Methods ¶ added in v0.1.2
func (InstanceDeleteRoute) Methods() []string
Methods implements api.Route
func (InstanceDeleteRoute) Name ¶ added in v0.1.2
func (InstanceDeleteRoute) Name() string
Name implements api.Route
func (InstanceDeleteRoute) Path ¶ added in v0.1.2
func (InstanceDeleteRoute) Path() string
Path implements api.Route
func (InstanceDeleteRoute) RequireAuth ¶ added in v0.1.2
func (InstanceDeleteRoute) RequireAuth() []api.CredentialType
RequireAuth implements the api.AuthorizedRoute
func (InstanceDeleteRoute) Scopes ¶ added in v0.1.2
func (InstanceDeleteRoute) Scopes() oauth.ScopeList
Scopes implements oauth.Route
type InstanceGetParams ¶ added in v0.1.3
type InstanceGetParams struct { Params DomainID *ID `json:"domain_id,omitempty"` InstanceID *ID `json:"instance_id,omitempty"` Name *string `json:"-"` Audience *string `json:"-"` }
InstanceGetParams is used to get an instance for the id
func (InstanceGetParams) ValidateWithContext ¶ added in v0.1.3
func (i InstanceGetParams) ValidateWithContext(ctx context.Context) error
ValidateWithContext handles validation of the InstanceGetInput struct
type InstanceGetRoute ¶ added in v0.1.2
type InstanceGetRoute func(ctx context.Context, params *InstanceGetParams) api.Responder
InstanceGetRoute is the instance create route definition
func (InstanceGetRoute) Methods ¶ added in v0.1.2
func (InstanceGetRoute) Methods() []string
Methods implements api.Route
func (InstanceGetRoute) Name ¶ added in v0.1.2
func (InstanceGetRoute) Name() string
Name implements api.Route
func (InstanceGetRoute) Path ¶ added in v0.1.2
func (InstanceGetRoute) Path() string
Path implements api.Route
func (InstanceGetRoute) RequireAuth ¶ added in v0.1.2
func (InstanceGetRoute) RequireAuth() []api.CredentialType
RequireAuth implements the api.AuthorizedRoute
func (InstanceGetRoute) Scopes ¶ added in v0.1.2
func (InstanceGetRoute) Scopes() oauth.ScopeList
Scopes implements oauth.Route
type InstanceListParams ¶ added in v0.1.3
type InstanceListParams struct { Params DomainID *ID `json:"domain_id,omitempty"` Limit *uint64 `json:"limit,omitempty"` Offset *uint64 `json:"offset,omitempty"` Count *uint64 `json:"count,omitempty"` }
InstanceListParams is the instance list request
func (InstanceListParams) ValidateWithContext ¶ added in v0.1.3
func (i InstanceListParams) ValidateWithContext(context.Context) error
ValidateWithContext handles validation of the InstanceListInput struct
type InstanceListRoute ¶ added in v0.1.2
type InstanceListRoute func(ctx context.Context, params *InstanceListParams) api.Responder
InstanceListRoute is the instance count route definition
func (InstanceListRoute) Methods ¶ added in v0.1.2
func (InstanceListRoute) Methods() []string
Methods implements api.Route
func (InstanceListRoute) Name ¶ added in v0.1.2
func (InstanceListRoute) Name() string
Name implements api.Route
func (InstanceListRoute) Path ¶ added in v0.1.2
func (InstanceListRoute) Path() string
Path implements api.Route
func (InstanceListRoute) RequireAuth ¶ added in v0.1.2
func (InstanceListRoute) RequireAuth() []api.CredentialType
RequireAuth implements the api.AuthorizedRoute
func (InstanceListRoute) Scopes ¶ added in v0.1.2
func (InstanceListRoute) Scopes() oauth.ScopeList
Scopes implements oauth.Route
type InstanceUpdateParams ¶ added in v0.1.3
type InstanceUpdateParams struct { Params `structs:"-"` DomainID ID `json:"domain_id" structs:"-"` InstanceID ID `json:"instance_id" structs:"-"` Name *string `json:"name" structs:"name,omitempty"` Description *string `json:"description,omitempty" structs:"description,omitempty"` }
InstanceUpdateParams is the instance update request
func (InstanceUpdateParams) ValidateWithContext ¶ added in v0.1.3
func (i InstanceUpdateParams) ValidateWithContext(ctx context.Context) error
ValidateWithContext handles validation of the InstanceUpdateInput struct
type InstanceUpdateRoute ¶ added in v0.1.2
type InstanceUpdateRoute func(ctx context.Context, params *InstanceUpdateParams) api.Responder
InstanceUpdateRoute is the instance create route definition
func (InstanceUpdateRoute) Methods ¶ added in v0.1.2
func (InstanceUpdateRoute) Methods() []string
Methods implements api.Route
func (InstanceUpdateRoute) Name ¶ added in v0.1.2
func (InstanceUpdateRoute) Name() string
Name implements api.Route
func (InstanceUpdateRoute) Path ¶ added in v0.1.2
func (InstanceUpdateRoute) Path() string
Path implements api.Route
func (InstanceUpdateRoute) RequireAuth ¶ added in v0.1.2
func (InstanceUpdateRoute) RequireAuth() []api.CredentialType
RequireAuth implements the api.AuthorizedRoute
func (InstanceUpdateRoute) Scopes ¶ added in v0.1.2
func (InstanceUpdateRoute) Scopes() oauth.ScopeList
Scopes implements oauth.Route
type ListParams ¶ added in v0.1.2
type ListParams struct { Expand []string `json:"expand,omitempty"` Limit *int64 `json:"limit,omitempty"` Offset *int64 `json:"offset,omitempty"` After *time.Time `json:"after"` Before *time.Time `json:"before"` DB DB `json:"-"` }
ListParams contains common components for list type methods
func (*ListParams) AddExpand ¶ added in v0.1.2
func (p *ListParams) AddExpand(e ...string) *ListParams
AddExpand appends values to the expand
type Option ¶
type Option struct { ID int `json:"id" db:"id"` DomainID ID `json:"domain_id" db:"domain_id"` InstanceID *ID `json:"instance_id,omitempty" db:"instance_id"` Key string `json:"key" db:"key"` RawValue json.RawMessage `json:"value" db:"value"` TTL int `json:"ttl" db:"ttl"` }
Option defines domain based 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 *OptionUpdateParams) (*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 *OptionGetParams) (*Option, error) // OptionList returns a list of options OptionList(ctx context.Context, params *OptionListParams) (Options, 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 *OptionRemoveParams) error }
OptionController provides instance configuration
type OptionGetParams ¶ added in v0.1.3
type OptionGetParams struct { Params DomainID ID `json:"domain_id"` InstanceID *ID `json:"instance_id,omitempty"` Key string `json:"key"` }
OptionGetParams is the option get input
func (OptionGetParams) CacheKey ¶ added in v0.1.3
func (o OptionGetParams) CacheKey() string
func (OptionGetParams) Validate ¶ added in v0.1.3
func (o OptionGetParams) Validate() error
Validate validates OptionGetInput
type OptionListParams ¶ added in v0.1.3
type OptionListParams struct { Params DomainID ID `json:"domain_id"` InstanceID *ID `json:"instance_id,omitempty"` }
OptionListParams is the option list input
func (OptionListParams) Validate ¶ added in v0.1.3
func (o OptionListParams) Validate() error
Validate validates OptionGetInput
type OptionRemoveParams ¶ added in v0.1.3
type OptionRemoveParams struct { Params DomainID ID `json:"domain_id"` InstanceID *ID `json:"instance_id,omitempty"` Key string `json:"key"` }
OptionRemoveParams is the option get input
func (OptionRemoveParams) Validate ¶ added in v0.1.3
func (o OptionRemoveParams) Validate() error
Validate validates OptionRemoveInput
type OptionUpdateHandler ¶
OptionUpdateHandler is called when options are updated
type OptionUpdateParams ¶ added in v0.1.3
type OptionUpdateParams struct { Params DomainID ID `json:"domain_id"` InstanceID *ID `json:"instance_id,omitempty"` Key string `json:"key"` Value json.RawMessage `json:"value"` TTL *int `json:"ttl,omitempty"` }
OptionUpdateParams is the option update input
func (OptionUpdateParams) Validate ¶ added in v0.1.3
func (o OptionUpdateParams) Validate() error
Validate validates OptionUpdateInput
type Params ¶ added in v0.1.2
type Params struct { Expand common.StringSlice `json:"expand,omitempty"` Metadata common.Map `json:"metadata,omitempty"` DB DB `json:"-"` NoCache bool `json:"nocache"` UpdateOnConflict bool `json:"-"` Principal api.Principal `json:"-"` }
Params contains common components for library methods
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 Permission ¶ added in v0.1.2
type Permission 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"` ApiID ID `json:"api_id" db:"api_id"` SpecID *ID `json:"spec_id,omitempty" db:"spec_id"` Definition string `jsoon:"definition" db:"definition"` Scope string `json:"scope" db:"scope"` Description *string `json:"description,omitempty" db:"description"` }
Permission is an api permission object
type PermissionController ¶ added in v0.1.2
type PermissionController interface {
PermissionCreate(ctx context.Context, params PermissionCreateParams) (*Permission, error)
}
PermissionController is the permission API interface
type PermissionCreateParams ¶ added in v0.1.3
type PermissionCreateParams struct { Params ApiID ID `json:"api_id"` SpecID *ID `json:"spec_id,omitempty"` Definition string `jsoon:"definition"` Scope string `json:"scope"` Description *string `json:"description,omitempty"` }
func (PermissionCreateParams) ValidateWithContext ¶ added in v0.1.3
func (i PermissionCreateParams) ValidateWithContext(ctx context.Context) error
ValidateWithContext validates the PermissionCreateInput type
type PermissionUpdate ¶ added in v0.1.2
type PermissionUpdate struct { Add []Permission `json:"add,omitempty"` Remove []Permission `json:"remove,omitempty"` }
PermissionUpdate is used to modify application 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) InstanceCreate ¶ added in v0.1.2
func (s *RPCServer) InstanceCreate(ctx context.Context, params *pb.InstanceCreateRequest) (*pb.Instance, error)
InstanceCreate implements the pb.HiroServer interface
func (*RPCServer) InstanceDelete ¶ added in v0.1.2
func (s *RPCServer) InstanceDelete(ctx context.Context, params *pb.InstanceDeleteRequest) (*empty.Empty, error)
InstanceDelete implements the pb.HiroServer interface
func (*RPCServer) InstanceGet ¶ added in v0.1.2
func (s *RPCServer) InstanceGet(ctx context.Context, params *pb.InstanceGetRequest) (*pb.Instance, error)
InstanceGet implements the pb.HiroServer interface
func (*RPCServer) InstanceList ¶ added in v0.1.2
func (s *RPCServer) InstanceList(req *pb.InstanceListRequest, stream pb.Hiro_InstanceListServer) error
InstanceList implements the pb.HiroServer interface
func (*RPCServer) InstanceUpdate ¶ added in v0.1.2
func (s *RPCServer) InstanceUpdate(ctx context.Context, params *pb.InstanceUpdateRequest) (*pb.Instance, error)
InstanceUpdate 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 time.Time `json:"created_at" db:"created_at"` InstanceID ID `json:"instance_id" db:"instance_id"` Audience string `json:"audience" db:"audience"` ApplicationID ID `json:"application_id" db:"application_id"` ClientID string `json:"client_id" db:"client_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 *time.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 *string `json:"app_uri,omitempty" db:"app_uri"` RedirectURI *string `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"` InstanceID ID `json:"instance_id" db:"instance_id"` Name string `json:"name" db:"name"` Description *string `json:"description,omitempty" db:"description"` Default bool `json:"default" db:"is_default"` Permissions []Permission `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 { InstanceID ID `json:"instance_id"` Name string `json:"name"` Description *string `json:"description,omitempty"` Default bool `json:"default"` Permissions []Permission `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 ¶
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"` InstanceID ID `json:"-"` Expand common.StringSlice `json:"expand,omitempty"` Name *string `json:"-"` }
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 { InstanceID ID `json:"-"` Expand common.StringSlice `json:"expand,omitempty"` 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 RoleUpdate ¶ added in v0.1.2
type RoleUpdate struct { Add []UserRole `json:"add,omitempty"` Remove []UserRole `json:"remove,omitempty"` }
RoleUpdate is used to update roles of a user
type RoleUpdateInput ¶
type RoleUpdateInput struct { InstanceID ID `json:"-"` RoleID ID `json:"id" structs:"-"` Name *string `json:"name" structs:"name,omitempty"` Description *string `json:"description,omitempty" structs:"description,omitempty"` Default *bool `json:"default,omitempty" structs:"default,omitempty"` Permissions PermissionUpdate `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 SchemaMigration ¶ added in v0.1.2
type SchemaMigration struct { migrate.MigrationSource Schema string }
SchemaMigration is a db migration source with a schema
type Secret ¶
type Secret struct { ID ID `json:"id" db:"id"` Type SecretType `json:"type"` InstanceID ID `json:"instance_id" db:"instance_id"` Algorithm *oauth.TokenAlgorithm `json:"algorithm,omitempty" db:"algorithm"` RawKey string `json:"key" db:"key"` CreatedAt time.Time `json:"created_at" db:"created_at"` ExpiresAt *time.Time `json:"expires_at,omitempty" db:"expires_at"` Default bool `json:"default" db:"is_default"` // contains filtered or unexported fields }
Secret is a secret key implemenation of oauth.TokenSecret
type SecretCreateInput ¶
type SecretCreateInput struct { InstanceID ID `json:"instance_id"` Type SecretType `json:"type"` Algorithm *oauth.TokenAlgorithm `json:"algorithm,omitempty"` Key *string `json:"key,omitempty"` ExpiresAt *time.Time `json:"expires_at,omitempty"` Default bool `json:"default"` }
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 InstanceCreateInput 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 ¶
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 []HiroOption) 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"` InstanceID ID `json:"instance_id" db:"instance_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 Spec ¶ added in v0.1.3
type Spec 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"` ApiID ID `json:"api_id" db:"api_id"` Version string `json:"version" db:"version"` Spec []byte `json:"spec" db:"spec"` SpecType SpecType `json:"spec_type" db:"spec_type"` SpecFormat SpecFormat `json:"spec_format" db:"spec_format"` Permissions []Permission `json:"permissions,omitempty" db:"-"` }
Spec is an api permission object
type SpecController ¶ added in v0.1.3
type SpecController interface {
SpecCreate(ctx context.Context, params SpecCreateParams) (*Spec, error)
}
SpecController is the permission API interface
type SpecCreateParams ¶ added in v0.1.3
type SpecCreateParams struct { Params ApiID ID `json:"api_id"` Version *string `json:"version,omitempty"` Spec []byte `json:"spec"` SpecType SpecType `json:"spec_type"` SpecFormat SpecFormat `json:"spec_format"` Permissions []PermissionCreateParams `json:"permissions,omitempty"` }
func (SpecCreateParams) ValidateWithContext ¶ added in v0.1.3
func (i SpecCreateParams) ValidateWithContext(ctx context.Context) error
ValidateWithContext validates the SpecCreateInput type
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"` 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 []Role `json:"roles,omitempty"` 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 { InstanceID ID `json:"instance_id"` Login string `json:"login"` Password *string `json:"password,omitempty"` Roles []UserRole `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 { InstanceID *ID `json:"instance_id,omitempty"` 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 { InstanceID *ID `json:"instance_id,omitempty"` UserID ID `json:"user_id,omitempty"` Expand common.StringSlice `json:"expand,omitempty"` Login *string `json:"-"` }
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 { InstanceID *ID `json:"instance_id,omitempty"` Expand common.StringSlice `json:"expand,omitempty"` 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 UserPermission ¶ added in v0.1.2
type UserPermission struct { InstanceID ID `json:"instance_id"` Permission string `json:"permission"` }
UserPermission is a user permission entry
type UserRole ¶ added in v0.1.2
type UserRole struct { InstanceID ID `json:"instance_id"` RoleID *ID `json:"role_id,omitempty"` Role *string `json:"role,omitempty"` }
UserRole is used to add roles to a user
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 RoleUpdate `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 ¶
- api.go
- application.go
- asset.go
- controller.go
- db.go
- domain.go
- errors.go
- hiro.go
- id.go
- instance.go
- oauth.go
- oauth_audience.go
- oauth_client.go
- oauth_user.go
- option.go
- params.go
- password.go
- permission.go
- role.go
- route_application.go
- route_asset.go
- route_instance.go
- route_secret.go
- route_session.go
- route_swagger.go
- route_token.go
- route_user.go
- routes.go
- rpc_api.go
- rpc_application.go
- rpc_instance.go
- rpc_secret.go
- rpc_server.go
- rpc_user.go
- scopes.go
- secret.go
- service.go
- session.go
- spec.go
- user.go