hiro

package
v0.1.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 13, 2022 License: MIT Imports: 67 Imported by: 0

README

Hiro Application Platform

Controller

The hiro.Controller interface is designed to built on-top of the hiro.Backend implementation, but it is abstracted into an interface to simplify testing and improve extensibility such that it could be provided over other interfaces easily like grpc.

The interface is responsbile for managing the CRUD operations and persistence of instances, applications, roles, users, and secrets.

Instances
Secrets
Applications
Roles
Users

Daemon

The hiro service is the core platform component that provides all of the underlying services for higher level client implementations. The only dependencies are a hiro.Controller, an oauth.Controller and a session.Controller. These three interfaces can be implemented by the same object.

API Server

The service will ensure the core services are ready for platforms to utilize by creating both an api.Server and a grpc.Server instance. The api server will always provide hiro services at the /hiro/{version} (i.e. /hiro/1.0.0) path.

This api is defined as an Open API 2.0 (aka Swagger) spec. And can be fetched from the service at /hiro/{version}/swagger.{json|yaml}.

Routes

The API routes are defined in the route_*.go modules. These are wrappers around the hiro.Controller, providing a REST/CRUD to the controller methods. Most of the routes are secured by the oauth.Authorizer.

OAuth Controller

The service adds the oauth controller to the path /oauth. This provides all of the neccessary authentication and authorization support for the api server.

This api is defined as an Open API 2.0 (aka Swagger) spec. And can be fetched from the service at /oauth/swagger.{json|yaml}.

RPC Server
Scheduler

Documentation

Overview

Package hiro is a foundational component for Model Rocket platform API services

Index

Constants

View Source
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"
)
View Source
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"
)
View Source
const (
	SpecTypeOpenAPI SpecType = "openapi"
	SpecTypeRPC     SpecType = "rpc"

	SpecFormatSwagger    SpecFormat = "swagger-2.0"
	SpecFormatGrpcProto2 SpecFormat = "grpc-proto2"
)
View Source
const (
	// MaxPasswordAge is the max age of a password before it must be changed
	MaxPasswordAge = time.Hour * 24 * 90
)

Variables

View Source
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")
)
View Source
var (
	// DefaultPasswordManager is the default password manager
	DefaultPasswordManager = passwordManager{}
)
View Source
var (
	ExpandAll = []string{"*"}
)

Functions

func ErrTxCommit

func ErrTxCommit(err error) error

ErrTxCommit is used to return an error from within a tx handler but still commit

func IsTransaction

func IsTransaction(db DB) bool

IsTransaction returns true of the DB interface is a transaction

func Log added in v0.1.2

func Log(ctx context.Context) log.Interface

Log returns the log from the context or from the server

func ParseSQLError

func ParseSQLError(err error) error

ParseSQLError provides cleaner errors for database issues

func RegisterOptionUpdateHandler

func RegisterOptionUpdateHandler(key string, handler OptionUpdateHandler)

RegisterOptionUpdateHandler registers an update handler for options

func Routes

func Routes() []api.Route

Routes returns the oauth api routes

func WithLogger added in v0.1.2

func WithLogger(ctx context.Context, log log.Interface) context.Context

WithLogger sets a context logger for requests

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

func (*API) Expand added in v0.1.3

func (a *API) Expand(ctx context.Context, e ...string) error

Expand implements the expandable interface

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

Name implements api.Route

func (ApplicationCountRoute) Path

Path implements api.Route

func (ApplicationCountRoute) RequireAuth

func (ApplicationCountRoute) RequireAuth() []api.CredentialType

RequireAuth implements the api.AuthorizedRoute

func (ApplicationCountRoute) Scopes

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

Name implements api.Route

func (ApplicationCreateRoute) Path

Path implements api.Route

func (ApplicationCreateRoute) RequireAuth

func (ApplicationCreateRoute) RequireAuth() []api.CredentialType

RequireAuth implements the api.AuthorizedRoute

func (ApplicationCreateRoute) Scopes

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

Name implements api.Route

func (ApplicationDeleteRoute) Path

Path implements api.Route

func (ApplicationDeleteRoute) RequireAuth

func (ApplicationDeleteRoute) RequireAuth() []api.CredentialType

RequireAuth implements the api.AuthorizedRoute

func (ApplicationDeleteRoute) Scopes

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

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

Name implements api.Route

func (ApplicationListRoute) Path

Path implements api.Route

func (ApplicationListRoute) RequireAuth

func (ApplicationListRoute) RequireAuth() []api.CredentialType

RequireAuth implements the api.AuthorizedRoute

func (ApplicationListRoute) Scopes

Scopes implements oauth.Route

type ApplicationType

type ApplicationType string

ApplicationType defines an application type

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

Name implements api.Route

func (ApplicationUpdateRoute) Path

Path implements api.Route

func (ApplicationUpdateRoute) RequireAuth

func (ApplicationUpdateRoute) RequireAuth() []api.CredentialType

RequireAuth implements the api.AuthorizedRoute

func (ApplicationUpdateRoute) Scopes

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

type AssetDeleteInput struct {
	InstanceID ID `json:"instance_id"`
	AssetID    ID `json:"asset_id"`
}

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

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

func (*Domain) Expand added in v0.1.3

func (a *Domain) Expand(ctx context.Context, e ...string) error

Expand implements the expandable interface

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 Expandable interface {
	Expand(ctx context.Context, expand ...string) error
}

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

func FromContext(ctx context.Context) *Hiro

FromContext returns a hiro from the context

func New

func New(opts ...HiroOption) (*Hiro, error)

New returns a new hiro backend

func (*Hiro) APICreate added in v0.1.2

func (h *Hiro) APICreate(ctx context.Context, params APICreateParams) (*API, error)

APICreate creates a new api

func (*Hiro) APIGet added in v0.1.2

func (h *Hiro) APIGet(ctx context.Context, params APIGetParams) (*API, error)

APIGet retrieves an api

func (*Hiro) APIImport added in v0.1.2

func (h *Hiro) APIImport(ctx context.Context, params APIImportParams) (*API, error)

APIImport imports an api definition

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

func (h *Hiro) AssetCreate(ctx context.Context, params AssetCreateInput) (*Asset, error)

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) AssetGet added in v0.1.2

func (h *Hiro) AssetGet(ctx context.Context, params AssetGetInput) (*Asset, error)

AssetGet returns the asset in the instance

func (*Hiro) AssetList added in v0.1.2

func (h *Hiro) AssetList(ctx context.Context, params AssetListInput) ([]*Asset, error)

AssetList lists the assets in the instance

func (*Hiro) AssetUpdate added in v0.1.2

func (h *Hiro) AssetUpdate(ctx context.Context, params AssetUpdateInput) (*Asset, error)

AssetUpdate updates an asset

func (*Hiro) Context added in v0.1.2

func (h *Hiro) Context(ctx context.Context) context.Context

Context returns the context with hiro

func (*Hiro) DB added in v0.1.2

func (b *Hiro) DB(ctx context.Context) DB

DB returns a transaction from the context if it exists or the db

func (*Hiro) DomainCreate added in v0.1.3

func (h *Hiro) DomainCreate(ctx context.Context, params DomainCreateParams) (*Domain, error)

DomainCreate creates a new domain

func (*Hiro) DomainGet added in v0.1.3

func (h *Hiro) DomainGet(ctx context.Context, params DomainGetParams) (*Domain, error)

DomainGet retrieves an domain

func (*Hiro) InstanceCreate added in v0.1.2

func (h *Hiro) InstanceCreate(ctx context.Context, params InstanceCreateParams) (*Instance, error)

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

func (h *Hiro) InstanceGet(ctx context.Context, params InstanceGetParams) (*Instance, error)

InstanceGet gets an instance by id and optionally preloads child objects

func (*Hiro) InstanceList added in v0.1.2

func (h *Hiro) InstanceList(ctx context.Context, params InstanceListParams) ([]*Instance, error)

InstanceList returns a listing of instances

func (*Hiro) InstanceUpdate added in v0.1.2

func (h *Hiro) InstanceUpdate(ctx context.Context, params InstanceUpdateParams) (*Instance, error)

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) OptionGet added in v0.1.2

func (h *Hiro) OptionGet(ctx context.Context, params OptionGetParams) (*Option, error)

OptionGet returns a named option from the backend

func (*Hiro) OptionList added in v0.1.3

func (h *Hiro) OptionList(ctx context.Context, params OptionListParams) (Options, error)

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

func (h *Hiro) OptionUpdate(ctx context.Context, params OptionUpdateParams) (*Option, error)

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

func (h *Hiro) RoleCreate(ctx context.Context, params RoleCreateInput) (*Role, error)

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

func (h *Hiro) RoleGet(ctx context.Context, params RoleGetInput) (*Role, error)

RoleGet gets an role by id and optionally preloads child objects

func (*Hiro) RoleList added in v0.1.2

func (h *Hiro) RoleList(ctx context.Context, params RoleListInput) ([]*Role, error)

RoleList returns a listing of roles

func (*Hiro) RoleUpdate added in v0.1.2

func (h *Hiro) RoleUpdate(ctx context.Context, params RoleUpdateInput) (*Role, error)

RoleUpdate updates an role by id, including child objects

func (*Hiro) SecretCreate added in v0.1.2

func (h *Hiro) SecretCreate(ctx context.Context, params SecretCreateInput) (*Secret, error)

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

func (h *Hiro) SessionCleanup(ctx context.Context) error

SessionCleanup removes expired sessions

func (*Hiro) SessionCreate added in v0.1.2

func (h *Hiro) SessionCreate(ctx context.Context, sess *session.Session) error

SessionCreate creates a session

func (*Hiro) SessionDestroy added in v0.1.2

func (h *Hiro) SessionDestroy(ctx context.Context, id string) error

func (*Hiro) SessionLoad added in v0.1.2

func (h *Hiro) SessionLoad(ctx context.Context, id string) (session.Session, error)

SessionLoad gets a session by id

func (*Hiro) SessionOptions added in v0.1.2

func (h *Hiro) SessionOptions(ctx context.Context, id string) (session.Options, error)

func (*Hiro) SessionUpdate added in v0.1.2

func (h *Hiro) SessionUpdate(ctx context.Context, sess *session.Session) error

SessionUpdate saves a session

func (*Hiro) SpecCreate added in v0.1.3

func (h *Hiro) SpecCreate(ctx context.Context, params SpecCreateParams) (*Spec, error)

func (*Hiro) Transact added in v0.1.2

func (b *Hiro) Transact(ctx context.Context, handler TxHandler, ignore ...error) (err error)

Transact starts a db transaction, adds it to the context and calls the handler

func (*Hiro) UserCreate added in v0.1.2

func (h *Hiro) UserCreate(ctx context.Context, params UserCreateInput) (*User, error)

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

func (h *Hiro) UserGet(ctx context.Context, params UserGetInput) (*User, error)

UserGet gets an user by id and optionally preloads child objects

func (*Hiro) UserList added in v0.1.2

func (h *Hiro) UserList(ctx context.Context, params UserListInput) ([]*User, error)

UserList returns a listing of users

func (*Hiro) UserUpdate added in v0.1.2

func (h *Hiro) UserUpdate(ctx context.Context, params UserUpdateInput) (*User, error)

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 WithDB

func WithDB(db *sql.DB) HiroOption

WithDB sets the database 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) Hex

func (id ID) Hex() string

Hex encodes the id as hex

func (ID) MarshalJSON

func (id ID) MarshalJSON() ([]byte, error)

MarshalJSON handles json marshaling of this type

func (*ID) Scan

func (id *ID) Scan(value interface{}) error

Scan implements the Scanner interface.

func (ID) String

func (id ID) String() string

func (*ID) UnmarshalJSON

func (id *ID) UnmarshalJSON(b []byte) error

UnmarshalJSON handles the unmarshaling of this type

func (ID) Valid

func (id ID) Valid() bool

Valid returns true if the id is valid

func (ID) Validate

func (id ID) Validate() error

Validate validates the id as a uuid

func (ID) Value

func (id ID) Value() (driver.Value, error)

Value implements the driver Valuer interface.

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

func (*Instance) Expand added in v0.1.3

func (i *Instance) Expand(ctx context.Context, e ...string) error

func (*Instance) FromProto added in v0.1.2

func (a *Instance) FromProto(p *pb.Instance)

FromProto convert the proto instance to an api instance

func (Instance) ToProto added in v0.1.2

func (a Instance) ToProto() (*pb.Instance, error)

ToProto converts the audiece to its protobuf conterpart

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

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

Scopes implements oauth.Route

type InstanceDeleteParams added in v0.1.3

type InstanceDeleteParams struct {
	Params
	InstanceID ID `json:"instance_id"`
}

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

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

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

Scopes implements oauth.Route

type Job

type Job struct {
	Function interface{}
	Params   []interface{}
	Interval time.Duration
	At       *time.Time
}

Job is a job handler that the service will schedule

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

func (*Option) CacheKey added in v0.1.3

func (o *Option) CacheKey() string

func (*Option) Value added in v0.1.3

func (o *Option) Value() generic.Value

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

type OptionUpdateHandler func(context.Context, *Option) error

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 Options added in v0.1.3

type Options []Option

Options is a list of options

func (Options) Get added in v0.1.3

func (o Options) Get(key string, def ...interface{}) generic.Value

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

func (*Params) AddExpand added in v0.1.2

func (p *Params) AddExpand(e ...string) *Params

AddExpand appends values to the expand

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) APICreate added in v0.1.2

func (s *RPCServer) APICreate(ctx context.Context, params *pb.APICreateRequest) (*pb.API, error)

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

type RoleDeleteInput struct {
	InstanceID ID `json:"-"`
	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"`
	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 RoleType

type RoleType string

RoleType defines an role type

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

func (*Secret) FromProto

func (s *Secret) FromProto(p *pb.Secret)

FromProto convert the proto Secret to an api Secret

func (*Secret) Key

func (s *Secret) Key() (interface{}, error)

func (Secret) ToProto

func (s Secret) ToProto() *pb.Secret

ToProto converts the Secret to its protobuf conterpart

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) Name

func (SecretCreateRoute) Name() string

Name implements api.Route

func (SecretCreateRoute) Path

func (SecretCreateRoute) Path() string

Path implements api.Route

func (SecretCreateRoute) RequireAuth

func (SecretCreateRoute) RequireAuth() []api.CredentialType

RequireAuth implements the api.AuthorizedRoute

func (SecretCreateRoute) Scopes

Scopes implements oauth.Route

type SecretDeleteInput

type SecretDeleteInput struct {
	InstanceID ID `json:"instance_id"`
	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) Name

func (SecretDeleteRoute) Name() string

Name implements api.Route

func (SecretDeleteRoute) Path

func (SecretDeleteRoute) Path() string

Path implements api.Route

func (SecretDeleteRoute) RequireAuth

func (SecretDeleteRoute) RequireAuth() []api.CredentialType

RequireAuth implements the api.AuthorizedRoute

func (SecretDeleteRoute) Scopes

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

func (d *Service) APIServer() *api.Server

APIServer returns the api server that services can register with

func (*Service) AddJob added in v0.1.1

func (d *Service) AddJob(job Job) error

AddJob adds a job to the service scheduler

func (*Service) RPCServer added in v0.1.1

func (d *Service) RPCServer() *grpc.Server

RPCServer returns the rpc server services can register with

func (*Service) Run added in v0.1.1

func (d *Service) Run() error

Run starts the service, blocks and handle interrupts

func (*Service) Serve added in v0.1.1

func (d *Service) Serve(ready func()) error

Serve starts the dameon server

func (*Service) Shutdown added in v0.1.1

func (d *Service) Shutdown(ctx context.Context) error

Shutdown terminates the service services

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 WithName

func WithName(name string) ServiceOption

WithName sets the service name

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 SessionKey

type SessionKey Secret

SessionKey is a wrapper around a token secret

func (SessionKey) Block

func (s SessionKey) Block() []byte

Block returns the session key block

func (SessionKey) Hash

func (s SessionKey) Hash() []byte

Hash returns the session key hash

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

func (*Spec) Expand added in v0.1.3

func (s *Spec) Expand(ctx context.Context, e ...string) error

Expand implements the expandable interface

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 SpecFormat added in v0.1.3

type SpecFormat string

SpecFormat defines a format for the type

type SpecGetInput

type SpecGetInput struct {
	Format string `json:"format"`
	Pretty bool   `json:"pretty"`
}

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

func (SpecRoute) Methods

func (SpecRoute) Methods() []string

Methods implements api.Route

func (SpecRoute) Name

func (SpecRoute) Name() string

Name implements api.Route

func (SpecRoute) Path

func (SpecRoute) Path() string

Path implements api.Route

type SpecType added in v0.1.3

type SpecType string

SpecType defines a specification type

type TxHandler

type TxHandler func(context.Context, DB) error

TxHandler is a db transaction 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) Name

func (UserCountRoute) Name() string

Name implements api.Route

func (UserCountRoute) Path

func (UserCountRoute) Path() string

Path 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) Name

func (UserCreateRoute) Name() string

Name implements api.Route

func (UserCreateRoute) Path

func (UserCreateRoute) Path() string

Path 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) Name

func (UserDeleteRoute) Name() string

Name implements api.Route

func (UserDeleteRoute) Path

func (UserDeleteRoute) Path() string

Path 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) Methods

func (UserGetRoute) Methods() []string

Methods implements api.Route

func (UserGetRoute) Name

func (UserGetRoute) Name() string

Name implements api.Route

func (UserGetRoute) Path

func (UserGetRoute) Path() string

Path implements api.Route

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) Methods

func (UserListRoute) Methods() []string

Methods implements api.Route

func (UserListRoute) Name

func (UserListRoute) Name() string

Name implements api.Route

func (UserListRoute) Path

func (UserListRoute) Path() string

Path implements api.Route

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) Name

func (UserUpdateRoute) Name() string

Name implements api.Route

func (UserUpdateRoute) Path

func (UserUpdateRoute) Path() string

Path 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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL