hiro

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2020 License: GPL-3.0 Imports: 65 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 audiences, applications, roles, users, and secrets.

Audiences
Secrets
Applications
Roles
Users

Daemon

The hiro daemon 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 daemon 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 daemon 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 audience token lifetime
	DefaultTokenLifetime = time.Hour

	// DefaultSessionLifetime is the default audience session lifetime
	DefaultSessionLifetime = time.Hour * 24 * 30
)
View Source
const (
	// ScopeAudienceRead is used to read audience properties
	ScopeAudienceRead = "audience:read"

	// ScopeAudienceWrite is used to create or modify audiences
	ScopeAudienceWrite = "audience:write"

	// ScopeApplicationRead is used to read application properties
	ScopeApplicationRead = "application:read"

	// ScopeApplicationWrite is used to create or modify applications
	ScopeApplicationWrite = "application:write"

	// ScopeRoleRead is used to read roles
	ScopeRoleRead = "role:read"

	// ScopeRoleWrite is used to create or modify roles
	ScopeRoleWrite = "role:write"

	// 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"

	// SessionRevoke is used to destory sessions
	SessionRevoke = "session:destroy"
)
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 (
	// Scopes is the spec defined oauth 2.0 scopes for the Hiro API
	Scopes = oauth.Scope{
		"audience:read",
		"audience:write",
		"application:read",
		"application:write",
		"user:read",
		"user:write",
		"token:read",
		"token:write",
		"session:read",
		"session:write",
	}

	// Roles is the list of hiro roles by name
	Roles = oauth.ScopeSet{
		"admin": Scopes,
	}
)
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.ErrServerError.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{}
)

Functions

func ApiSwaggerV1HiroSwaggerYaml

func ApiSwaggerV1HiroSwaggerYaml() (*asset, error)

func ApiSwaggerV1HiroSwaggerYamlBytes

func ApiSwaggerV1HiroSwaggerYamlBytes() ([]byte, error)

func Asset

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetDir

func AssetDir(name string) ([]string, error)

AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:

data/
  foo.txt
  img/
    a.png
    b.png

then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.

func AssetInfo

func AssetInfo(name string) (os.FileInfo, error)

AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetNames

func AssetNames() []string

AssetNames returns the names of the assets.

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 MustAsset

func MustAsset(name string) []byte

MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.

func ParseSQLError

func ParseSQLError(err error) error

ParseSQLError provides cleaner errors for database issues

func RegisterOption

func RegisterOption(name string, val interface{}) error

RegisterOption registers an option type

func RegisterOptionUpdateHandler

func RegisterOptionUpdateHandler(name string, handler OptionUpdateHandler)

RegisterOptionUpdateHandler registers an update handler for options

func RestoreAsset

func RestoreAsset(dir, name string) error

RestoreAsset restores an asset under the given directory

func RestoreAssets

func RestoreAssets(dir, name string) error

RestoreAssets restores an asset under the given directory recursively

func Routes

func Routes() []api.Route

Routes returns the oauth api routes

func TokenSecret

func TokenSecret(s *Secret) (oauth.TokenSecret, error)

TokenSecret retuns a token secret from the Secret key

Types

type AccessToken

type AccessToken struct {
	ID            ID             `json:"id" db:"id"`
	Issuer        *oauth.URI     `json:"issuer,omitempty" db:"issuer"`
	Audience      ID             `json:"audience_id" db:"audience_id"`
	ApplicationID ID             `json:"application_id" db:"application_id"`
	UserID        ID             `json:"user_id,omitempty" db:"user_id,omitempty"`
	Use           oauth.TokenUse `json:"token_use" db:"token_use"`
	AuthTime      *oauth.Time    `db:"-"`
	Scope         oauth.Scope    `json:"scope,omitempty" db:"scope"`
	CreatedAt     oauth.Time     `json:"created_at" db:"created_at"`
	ExpiresAt     *oauth.Time    `json:"expires_at,omitempty" db:"expires_at"`
	Revokable     bool           `db:"-"`
	RevokedAt     *oauth.Time    `json:"revoked_at,omitempty" db:"revoked_at"`
	Claims        oauth.Claims   `json:"claims,omitempty" db:"claims"`
	Bearer        *string        `db:"-"`
}

AccessToken is the backend representation of an oauth.Token (type=TokenTypeAccess)

type Application

type Application struct {
	ID          ID                `json:"id" db:"id"`
	Name        string            `json:"name" db:"name"`
	Slug        string            `json:"slug" db:"slug"`
	Description *string           `json:"description,omitempty" db:"description"`
	Type        oauth.ClientType  `json:"type" db:"type"`
	SecretKey   *string           `json:"secret_key,omitempty" db:"secret_key"`
	Permissions oauth.ScopeSet    `json:"permissions,omitempty" db:"-"`
	Grants      oauth.Grants      `json:"grants,omitempty" db:"-"`
	URIs        oauth.URIList     `json:"uris,omitempty" db:"uris"`
	CreatedAt   time.Time         `json:"created_at" db:"created_at"`
	UpdatedAt   *time.Time        `json:"updated_at,omitempty" db:"updated_at"`
	Metadata    reno.InterfaceMap `json:"metadata,omitempty" db:"metadata"`
}

Application is the database model for an application

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 {
	Name        string            `json:"name"`
	Description *string           `json:"description,omitempty"`
	Type        oauth.ClientType  `json:"type" db:"type"`
	Permissions oauth.ScopeSet    `json:"permissions,omitempty"`
	Grants      oauth.Grants      `json:"grants,omitempty"`
	URIs        oauth.URIList     `json:"uris,omitempty"`
	Metadata    reno.InterfaceMap `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 {
	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 ApplicationGetInput

type ApplicationGetInput struct {
	ApplicationID ID      `json:"application_id,omitempty"`
	Name          *string `json:"name,omitempty"`
}

ApplicationGetInput is used to get an application for the id

func (ApplicationGetInput) ValidateWithContext

func (a ApplicationGetInput) ValidateWithContext(ctx context.Context) error

ValidateWithContext handles validation of the ApplicationGetInput struct

type ApplicationGetRoute

type ApplicationGetRoute func(ctx context.Context, params *ApplicationGetInput) api.Responder

ApplicationGetRoute is the application create route definition

func (ApplicationGetRoute) Methods

func (ApplicationGetRoute) Methods() []string

Methods implements api.Route

func (ApplicationGetRoute) Name

func (ApplicationGetRoute) Name() string

Name implements api.Route

func (ApplicationGetRoute) Path

func (ApplicationGetRoute) Path() string

Path implements api.Route

func (ApplicationGetRoute) RequireAuth

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

RequireAuth implements the api.AuthorizedRoute

func (ApplicationGetRoute) Scopes

Scopes implements oauth.Route

type ApplicationListInput

type ApplicationListInput struct {
	Limit  *uint64 `json:"limit,omitempty"`
	Offset *uint64 `json:"offset,omitempty"`
	Count  *uint64 `json:"count,omitempty"`
}

ApplicationListInput is the application list request

func (ApplicationListInput) ValidateWithContext

func (a ApplicationListInput) ValidateWithContext(context.Context) error

ValidateWithContext handles validation of the ApplicationListInput struct

type ApplicationListRoute

type ApplicationListRoute func(ctx context.Context, params *ApplicationListInput) api.Responder

ApplicationListRoute is the application count route definition

func (ApplicationListRoute) Methods

func (ApplicationListRoute) Methods() []string

Methods implements api.Route

func (ApplicationListRoute) Name

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:"-"`
	Name          *string            `json:"name" structs:"name,omitempty"`
	Description   *string            `json:"description,omitempty" structs:"description,omitempty"`
	Type          *oauth.ClientType  `json:"type" structs:"type,omitempty"`
	Permissions   *PermissionsUpdate `json:"permissions,omitempty" structs:"-"`
	Grants        oauth.Grants       `json:"grants,omitempty" structs:"-"`
	URIs          oauth.URIList      `json:"uris,omitempty" structs:"-"`
	Metadata      reno.InterfaceMap  `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 Audience

type Audience struct {
	ID              ID                   `json:"id" db:"id"`
	Name            string               `json:"name" db:"name"`
	Slug            string               `json:"slug" db:"slug"`
	Description     *string              `json:"description,omitempty" db:"description"`
	TokenSecrets    []oauth.TokenSecret  `json:"-" db:"-"`
	SessionKeys     []SessionKey         `json:"-" db:"-"`
	Secrets         []*Secret            `json:"secrets,omitempty" db:"-"`
	TokenAlgorithm  oauth.TokenAlgorithm `json:"token_algorithm" db:"token_algorithm"`
	TokenLifetime   time.Duration        `json:"token_lifetime" db:"token_lifetime"`
	SessionLifetime time.Duration        `json:"session_lifetime,omitempty" db:"session_lifetime"`
	CreatedAt       time.Time            `json:"created_at" db:"created_at"`
	UpdatedAt       *time.Time           `json:"updated_at,omitempty" db:"updated_at"`
	Permissions     oauth.Scope          `json:"permissions,omitempty" db:"-"`
	Metadata        reno.InterfaceMap    `json:"metadata,omitempty" db:"metadata"`
}

Audience is the database model for an audience

func (*Audience) FromProto

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

FromProto convert the proto audience to an api audience

func (Audience) ToProto

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

ToProto converts the audiece to its protobuf conterpart

type AudienceCountRoute

type AudienceCountRoute func(ctx context.Context, params *AudienceListInput) api.Responder

AudienceCountRoute is the audience count route definition

func (AudienceCountRoute) Methods

func (AudienceCountRoute) Methods() []string

Methods implements api.Route

func (AudienceCountRoute) Name

func (AudienceCountRoute) Name() string

Name implements api.Route

func (AudienceCountRoute) Path

func (AudienceCountRoute) Path() string

Path implements api.Route

func (AudienceCountRoute) RequireAuth

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

RequireAuth implements the api.AuthorizedRoute

func (AudienceCountRoute) Scopes

Scopes implements oauth.Route

type AudienceCreateInput

type AudienceCreateInput struct {
	Name            string               `json:"name"`
	Description     *string              `json:"description,omitempty"`
	TokenLifetime   time.Duration        `json:"token_lifetime"`
	TokenAlgorithm  oauth.TokenAlgorithm `json:"token_algorithm"`
	SessionLifetime time.Duration        `json:"session_lifetime,omitempty"`
	Permissions     oauth.Scope          `json:"permissions,omitempty"`
	Metadata        reno.InterfaceMap    `json:"metadata,omitempty"`
}

AudienceCreateInput is the audience create request

func (AudienceCreateInput) ValidateWithContext

func (a AudienceCreateInput) ValidateWithContext(ctx context.Context) error

ValidateWithContext handles validation of the AudienceCreateInput struct

type AudienceCreateRoute

type AudienceCreateRoute func(ctx context.Context, params *AudienceCreateInput) api.Responder

AudienceCreateRoute is the audience create route definition

func (AudienceCreateRoute) Methods

func (AudienceCreateRoute) Methods() []string

Methods implements api.Route

func (AudienceCreateRoute) Name

func (AudienceCreateRoute) Name() string

Name implements api.Route

func (AudienceCreateRoute) Path

func (AudienceCreateRoute) Path() string

Path implements api.Route

func (AudienceCreateRoute) RequireAuth

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

RequireAuth implements the api.AuthorizedRoute

func (AudienceCreateRoute) Scopes

Scopes implements oauth.Route

type AudienceDeleteInput

type AudienceDeleteInput struct {
	AudienceID ID `json:"audience_id"`
}

AudienceDeleteInput is the audience delete request input

func (AudienceDeleteInput) ValidateWithContext

func (a AudienceDeleteInput) ValidateWithContext(ctx context.Context) error

ValidateWithContext handles validation of the ApplicationDeleteInput

type AudienceDeleteRoute

type AudienceDeleteRoute func(ctx context.Context, params *AudienceDeleteInput) api.Responder

AudienceDeleteRoute is the audience create route definition

func (AudienceDeleteRoute) Methods

func (AudienceDeleteRoute) Methods() []string

Methods implements api.Route

func (AudienceDeleteRoute) Name

func (AudienceDeleteRoute) Name() string

Name implements api.Route

func (AudienceDeleteRoute) Path

func (AudienceDeleteRoute) Path() string

Path implements api.Route

func (AudienceDeleteRoute) RequireAuth

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

RequireAuth implements the api.AuthorizedRoute

func (AudienceDeleteRoute) Scopes

Scopes implements oauth.Route

type AudienceGetInput

type AudienceGetInput struct {
	AudienceID ID      `json:"audience_id,omitempty"`
	Name       *string `json:"name,omitempty"`
}

AudienceGetInput is used to get an audience for the id

func (AudienceGetInput) ValidateWithContext

func (a AudienceGetInput) ValidateWithContext(ctx context.Context) error

ValidateWithContext handles validation of the AudienceGetInput struct

type AudienceGetRoute

type AudienceGetRoute func(ctx context.Context, params *AudienceGetInput) api.Responder

AudienceGetRoute is the audience create route definition

func (AudienceGetRoute) Methods

func (AudienceGetRoute) Methods() []string

Methods implements api.Route

func (AudienceGetRoute) Name

func (AudienceGetRoute) Name() string

Name implements api.Route

func (AudienceGetRoute) Path

func (AudienceGetRoute) Path() string

Path implements api.Route

func (AudienceGetRoute) RequireAuth

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

RequireAuth implements the api.AuthorizedRoute

func (AudienceGetRoute) Scopes

func (AudienceGetRoute) Scopes() oauth.ScopeList

Scopes implements oauth.Route

type AudienceInitializeInput

type AudienceInitializeInput struct {
	Name            string                `json:"name"`
	Description     *string               `json:"description,omitempty"`
	TokenLifetime   *time.Duration        `json:"token_lifetime"`
	TokenAlgorithm  *oauth.TokenAlgorithm `json:"token_algorithm"`
	SessionLifetime *time.Duration        `json:"session_lifetime,omitempty"`
	Permissions     oauth.Scope           `json:"permissions,omitempty"`
	Metadata        reno.InterfaceMap     `json:"metadata,omitempty"`
	Roles           oauth.ScopeSet        `json:"roles,omitempty"`
}

AudienceInitializeInput is the input to the audience initialization

func (AudienceInitializeInput) ValidateWithContext

func (a AudienceInitializeInput) ValidateWithContext(ctx context.Context) error

ValidateWithContext handles validation of the AudienceInitializeInput struct

type AudienceListInput

type AudienceListInput struct {
	Limit  *uint64 `json:"limit,omitempty"`
	Offset *uint64 `json:"offset,omitempty"`
	Count  *uint64 `json:"count,omitempty"`
}

AudienceListInput is the audience list request

func (AudienceListInput) ValidateWithContext

func (a AudienceListInput) ValidateWithContext(context.Context) error

ValidateWithContext handles validation of the AudienceListInput struct

type AudienceListRoute

type AudienceListRoute func(ctx context.Context, params *AudienceListInput) api.Responder

AudienceListRoute is the audience count route definition

func (AudienceListRoute) Methods

func (AudienceListRoute) Methods() []string

Methods implements api.Route

func (AudienceListRoute) Name

func (AudienceListRoute) Name() string

Name implements api.Route

func (AudienceListRoute) Path

func (AudienceListRoute) Path() string

Path implements api.Route

func (AudienceListRoute) RequireAuth

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

RequireAuth implements the api.AuthorizedRoute

func (AudienceListRoute) Scopes

Scopes implements oauth.Route

type AudiencePermissionsUpdate

type AudiencePermissionsUpdate struct {
	Add       oauth.Scope `json:"add,omitempty"`
	Remove    oauth.Scope `json:"remove,omitempty"`
	Overwrite bool        `json:"overrite"`
}

AudiencePermissionsUpdate is used to update audience permissions

type AudienceUpdateInput

type AudienceUpdateInput struct {
	AudienceID      ID                         `json:"audience_id" structs:"-"`
	Name            *string                    `json:"name" structs:"name,omitempty"`
	Description     *string                    `json:"description,omitempty" structs:"description,omitempty"`
	TokenAlgorithm  *oauth.TokenAlgorithm      `json:"token_algorithm,omitempty" structs:"token_algorithm,omitempty"`
	TokenLifetime   *time.Duration             `json:"token_lifetime" structs:"token_lifetime,omitempty"`
	SessionLifetime *time.Duration             `json:"session_lifetime,omitempty" structs:"session_lifetime,omitempty"`
	Permissions     *AudiencePermissionsUpdate `json:"permissions,omitempty" structs:"-"`
	Metadata        reno.InterfaceMap          `json:"metadata,omitempty" structs:"-"`
}

AudienceUpdateInput is the audience update request

func (AudienceUpdateInput) ValidateWithContext

func (a AudienceUpdateInput) ValidateWithContext(ctx context.Context) error

ValidateWithContext handles validation of the AudienceUpdateInput struct

type AudienceUpdateRoute

type AudienceUpdateRoute func(ctx context.Context, params *AudienceUpdateInput) api.Responder

AudienceUpdateRoute is the audience create route definition

func (AudienceUpdateRoute) Methods

func (AudienceUpdateRoute) Methods() []string

Methods implements api.Route

func (AudienceUpdateRoute) Name

func (AudienceUpdateRoute) Name() string

Name implements api.Route

func (AudienceUpdateRoute) Path

func (AudienceUpdateRoute) Path() string

Path implements api.Route

func (AudienceUpdateRoute) RequireAuth

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

RequireAuth implements the api.AuthorizedRoute

func (AudienceUpdateRoute) Scopes

Scopes implements oauth.Route

type Backend

type Backend struct {
	// contains filtered or unexported fields
}

Backend is the hiro api backend implementation

func FromContext

func FromContext(ctx context.Context) *Backend

FromContext returns a hiro from the context

func New

func New(opts ...BackendOption) (*Backend, error)

New returns a new hiro backend

func (*Backend) ApplicationCreate

func (b *Backend) ApplicationCreate(ctx context.Context, params ApplicationCreateInput) (*Application, error)

ApplicationCreate create a new permission object

func (*Backend) ApplicationDelete

func (b *Backend) ApplicationDelete(ctx context.Context, params ApplicationDeleteInput) error

ApplicationDelete deletes an application by id

func (*Backend) ApplicationGet

func (b *Backend) ApplicationGet(ctx context.Context, params ApplicationGetInput) (*Application, error)

ApplicationGet gets an application by id and optionally preloads child objects

func (*Backend) ApplicationList

func (b *Backend) ApplicationList(ctx context.Context, params ApplicationListInput) ([]*Application, error)

ApplicationList returns a listing of applications

func (*Backend) ApplicationUpdate

func (b *Backend) ApplicationUpdate(ctx context.Context, params ApplicationUpdateInput) (*Application, error)

ApplicationUpdate updates an application by id, including child objects

func (*Backend) AudienceCreate

func (b *Backend) AudienceCreate(ctx context.Context, params AudienceCreateInput) (*Audience, error)

AudienceCreate create a new permission object

func (*Backend) AudienceDelete

func (b *Backend) AudienceDelete(ctx context.Context, params AudienceDeleteInput) error

AudienceDelete deletes an audience by id

func (*Backend) AudienceGet

func (b *Backend) AudienceGet(ctx context.Context, params AudienceGetInput) (*Audience, error)

AudienceGet gets an audience by id and optionally preloads child objects

func (*Backend) AudienceInitialize

func (b *Backend) AudienceInitialize(ctx context.Context, params AudienceInitializeInput) (*Audience, error)

AudienceInitialize will create or update and audience, intialize a default application and secrets

func (*Backend) AudienceList

func (b *Backend) AudienceList(ctx context.Context, params AudienceListInput) ([]*Audience, error)

AudienceList returns a listing of audiences

func (*Backend) AudienceUpdate

func (b *Backend) AudienceUpdate(ctx context.Context, params AudienceUpdateInput) (*Audience, error)

AudienceUpdate updates an application by id, including child objects

func (*Backend) Context

func (b *Backend) Context(ctx context.Context) context.Context

Context returns the context with hiro

func (*Backend) DB

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

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

func (*Backend) Log

func (b *Backend) Log(ctx context.Context) log.Interface

Log returns the log from the context or from the server

func (*Backend) OAuthController

func (b *Backend) OAuthController() oauth.Controller

OAuthController returns an oauth controller from a hiro.Backend

func (*Backend) OptionGet

func (b *Backend) OptionGet(ctx context.Context, params *OptionGetInput) (Option, error)

OptionGet returns a named option from the backend

func (*Backend) OptionRemove

func (b *Backend) OptionRemove(ctx context.Context, params *OptionRemoveInput) error

OptionRemove removes the named option from the backend

func (*Backend) OptionUpdate

func (b *Backend) OptionUpdate(ctx context.Context, params *OptionUpdateInput) (Option, error)

OptionUpdate stores a named option in the backend data store

func (*Backend) PasswordManager

func (b *Backend) PasswordManager() PasswordManager

PasswordManager returns the current password manager for the instance

func (*Backend) RoleCreate

func (b *Backend) RoleCreate(ctx context.Context, params RoleCreateInput) (*Role, error)

RoleCreate create a new permission object

func (*Backend) RoleDelete

func (b *Backend) RoleDelete(ctx context.Context, params RoleDeleteInput) error

RoleDelete deletes an role by id

func (*Backend) RoleGet

func (b *Backend) RoleGet(ctx context.Context, params RoleGetInput) (*Role, error)

RoleGet gets an role by id and optionally preloads child objects

func (*Backend) RoleList

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

RoleList returns a listing of roles

func (*Backend) RoleUpdate

func (b *Backend) RoleUpdate(ctx context.Context, params RoleUpdateInput) (*Role, error)

RoleUpdate updates an role by id, including child objects

func (*Backend) SecretCreate

func (b *Backend) SecretCreate(ctx context.Context, params SecretCreateInput) (*Secret, error)

SecretCreate creates a new secret, generating the key if not is provided

func (*Backend) SecretDelete

func (b *Backend) SecretDelete(ctx context.Context, params SecretDeleteInput) error

SecretDelete deletes an audience by id

func (*Backend) SessionController

func (b *Backend) SessionController() session.Controller

SessionController returns an oauth controller from a hiro.Backend

func (*Backend) Transact

func (b *Backend) 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 (*Backend) UserCreate

func (b *Backend) UserCreate(ctx context.Context, params UserCreateInput) (*User, error)

UserCreate create a new permission object

func (*Backend) UserDelete

func (b *Backend) UserDelete(ctx context.Context, params UserDeleteInput) error

UserDelete deletes an user by id

func (*Backend) UserGet

func (b *Backend) UserGet(ctx context.Context, params UserGetInput) (*User, error)

UserGet gets an user by id and optionally preloads child objects

func (*Backend) UserList

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

UserList returns a listing of users

func (*Backend) UserUpdate

func (b *Backend) UserUpdate(ctx context.Context, params UserUpdateInput) (*User, error)

UserUpdate updates an user by id, including child objects

type BackendOption

type BackendOption func(b *Backend)

BackendOption defines a backend option

func Automigrate

func Automigrate(m ...Migration) BackendOption

Automigrate will perform the database initialization, creating tables and indexes.

func Initialize

func Initialize(a ...AudienceInitializeInput) BackendOption

Initialize will create the default hiro audience and application to use for management

func WithDB

func WithDB(db *sql.DB) BackendOption

WithDB sets the database instance

func WithDBSource

func WithDBSource(source string) BackendOption

WithDBSource sets the database source string

func WithLog

func WithLog(l log.Interface) BackendOption

WithLog sets the log for the backend

type Controller

type Controller interface {
	// Audience interface
	AudienceCreate(ctx context.Context, params AudienceCreateInput) (*Audience, error)
	AudienceGet(ctx context.Context, params AudienceGetInput) (*Audience, error)
	AudienceList(ctx context.Context, params AudienceListInput) ([]*Audience, error)
	AudienceUpdate(ctx context.Context, params AudienceUpdateInput) (*Audience, error)
	AudienceDelete(ctx context.Context, params AudienceDeleteInput) error

	// Secrets interface
	SecretCreate(ctx context.Context, params SecretCreateInput) (*Secret, error)
	SecretDelete(ctx context.Context, params SecretDeleteInput) error

	// Application 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

	// Role 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

	// User 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

	// Returns the log from the context
	Log(ctx context.Context) log.Interface

	// Starts a database transaction
	Transact(ctx context.Context, handler TxHandler, ignore ...error) error

	// Gets a handle to the database
	DB(ctx context.Context) DB

	// Return the OAuth Controller
	OAuthController() oauth.Controller

	// SessionController return the session controller
	SessionController() session.Controller
}

Controller is the hiro API controller interface

type DB

type DB interface {
	sqlx.Ext
	sqlx.ExtContext
	SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
	GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
}

DB is an aggregate interface for sqlx transactions

type Daemon

type Daemon struct {
	// contains filtered or unexported fields
}

Daemon is the core hiro service object Platoform projects use the hiro.Daemon to provide services

func NewDaemon

func NewDaemon(opts ...DaemonOption) (*Daemon, error)

NewDaemon creates a new daemon object

func (*Daemon) APIServer

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

APIServer returns the api server that services can register with

func (*Daemon) AddJob

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

AddJob adds a job to the daemon scheduler

func (*Daemon) RPCServer

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

RPCServer returns the rpc server services can register with

func (*Daemon) Run

func (d *Daemon) Run() error

Run starts the service, blocks and handle interrupts

func (*Daemon) Serve

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

Serve starts the dameon server

func (*Daemon) Shutdown

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

Shutdown terminates the daemon services

type DaemonOption

type DaemonOption func(d *Daemon)

DaemonOption is a daemon option

func WithAPIOptions

func WithAPIOptions(o ...api.Option) DaemonOption

WithAPIOptions sets api server options; mutally exclusive with WithAPIServer

func WithAPIServer

func WithAPIServer(s *api.Server) DaemonOption

WithAPIServer sets the daemon api server; mutally exclusive with WithAPIOptions

func WithBackendOptions

func WithBackendOptions(o []BackendOption) DaemonOption

WithBackendOptions sets backend options

func WithController

func WithController(c Controller) DaemonOption

WithController sets the daemon controller

func WithName

func WithName(name string) DaemonOption

WithName sets the daemon name

func WithOAuthController

func WithOAuthController(o oauth.Controller) DaemonOption

WithOAuthController set the daemon oauth controller

func WithRPCServer

func WithRPCServer(s *grpc.Server) DaemonOption

WithRPCServer sets the daemon rpc server

func WithServerAddr

func WithServerAddr(addr string) DaemonOption

WithServerAddr sets the daemon listening address

func WithSessionController

func WithSessionController(s session.Controller) DaemonOption

WithSessionController set the daemon session controller

type ID

type ID string

ID is the hiro uuid implementation wrapper that base58 encodes/decodes the values as text or json

func NullID

func NullID(id ...interface{}) ID

NullID will parse or generate a value to make a new ID

func (ID) Hex

func (id ID) Hex() string

Hex encode 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 Job

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

Job is a job handler that the daemon will schedule

type Migration

type Migration struct {
	*migrate.AssetMigrationSource
	Schema string
}

Migration is a db migration

type Option

type Option interface {
	Name() string
	SetName(string)
	Audience() string
	SetAudience(string)
}

Option An instance configuration option

func UnmarshalOption

func UnmarshalOption(reader io.Reader, name ...string) (Option, error)

UnmarshalOption unmarshals polymorphic Option

func UnmarshalOptionSlice

func UnmarshalOptionSlice(reader io.Reader) ([]Option, error)

UnmarshalOptionSlice unmarshals polymorphic slices of Option

type OptionController

type OptionController interface {
	// OptionUpdate stores a named option in the backend data store, the value should be created if it does not exist
	OptionUpdate(ctx context.Context, params *OptionUpdateInput) (Option, error)

	// OptionGet returns a named option from the backend, an error should be returned if the option does not exist
	OptionGet(ctx context.Context, params *OptionGetInput) (Option, error)

	// OptionRemove removes the named option from the backend, and error should not be returned if the option does not exist
	OptionRemove(ctx context.Context, params *OptionRemoveInput) error
}

OptionController provides instance configuration

type OptionGetInput

type OptionGetInput struct {
	Name  string      `json:"name"`
	Value interface{} `json:"-"`
}

OptionGetInput is the option get input

func (OptionGetInput) Validate

func (o OptionGetInput) Validate() error

Validate validates OptionGetInput

type OptionRemoveInput

type OptionRemoveInput struct {
	Name string `json:"name"`
}

OptionRemoveInput is the option get input

func (OptionRemoveInput) Validate

func (o OptionRemoveInput) Validate() error

Validate validates OptionRemoveInput

type OptionUpdateHandler

type OptionUpdateHandler func(context.Context, Option) error

OptionUpdateHandler is called when options are updated

type OptionUpdateInput

type OptionUpdateInput struct {
	AudienceID ID     `json:"audience_id"`
	Name       string `json:"name"`
	Option     Option `json:"-"`
	// contains filtered or unexported fields
}

OptionUpdateInput is the option update input

func (OptionUpdateInput) Validate

func (o OptionUpdateInput) Validate() error

Validate validates OptionUpdateInput

type PasswordManager

type PasswordManager interface {
	HashPassword(password string) (string, error)
	CheckPasswordHash(password, hash string) bool
	EnforcePasswordPolicy(enabled bool)
	ValidatePassword(password string) error
	PasswordExpiry() time.Duration
	MaxLoginAttempts() int
	AccountLockoutPeriod() time.Duration
}

PasswordManager is an interface for hashing and validation of passwords

type PermissionsUpdate

type PermissionsUpdate struct {
	Add       oauth.ScopeSet `json:"add,omitempty"`
	Remove    oauth.ScopeSet `json:"remove,omitempty"`
	Overwrite bool           `json:"overwrite"`
}

PermissionsUpdate is used to modify permissions

type RPCServer

type RPCServer struct {
	Controller
	pb.UnimplementedHiroServer
}

RPCServer is a hiro rpc server

func NewRPCServer

func NewRPCServer(c Controller) *RPCServer

NewRPCServer returns a new hiro rpc Server

func (*RPCServer) ApplicationCreate

func (s *RPCServer) ApplicationCreate(ctx context.Context, params *pb.ApplicationCreateRequest) (*pb.Application, error)

ApplicationCreate implements the pb.HiroServer interface

func (*RPCServer) ApplicationDelete

func (s *RPCServer) ApplicationDelete(ctx context.Context, params *pb.ApplicationDeleteRequest) (*empty.Empty, error)

ApplicationDelete implements the pb.HiroServer interface

func (*RPCServer) ApplicationGet

func (s *RPCServer) ApplicationGet(ctx context.Context, params *pb.ApplicationGetRequest) (*pb.Application, error)

ApplicationGet implements the pb.HiroServer interface

func (*RPCServer) ApplicationList

func (s *RPCServer) ApplicationList(req *pb.ApplicationListRequest, stream pb.Hiro_ApplicationListServer) error

ApplicationList implements the pb.HiroServer interface

func (*RPCServer) ApplicationUpdate

func (s *RPCServer) ApplicationUpdate(ctx context.Context, params *pb.ApplicationUpdateRequest) (*pb.Application, error)

ApplicationUpdate implements the pb.HiroServer interface

func (*RPCServer) AudienceCreate

func (s *RPCServer) AudienceCreate(ctx context.Context, params *pb.AudienceCreateRequest) (*pb.Audience, error)

AudienceCreate implements the pb.HiroServer interface

func (*RPCServer) AudienceDelete

func (s *RPCServer) AudienceDelete(ctx context.Context, params *pb.AudienceDeleteRequest) (*empty.Empty, error)

AudienceDelete implements the pb.HiroServer interface

func (*RPCServer) AudienceGet

func (s *RPCServer) AudienceGet(ctx context.Context, params *pb.AudienceGetRequest) (*pb.Audience, error)

AudienceGet implements the pb.HiroServer interface

func (*RPCServer) AudienceList

func (s *RPCServer) AudienceList(req *pb.AudienceListRequest, stream pb.Hiro_AudienceListServer) error

AudienceList implements the pb.HiroServer interface

func (*RPCServer) AudienceUpdate

func (s *RPCServer) AudienceUpdate(ctx context.Context, params *pb.AudienceUpdateRequest) (*pb.Audience, error)

AudienceUpdate implements the pb.HiroServer interface

func (*RPCServer) SecretCreate

func (s *RPCServer) SecretCreate(ctx context.Context, params *pb.SecretCreateRequest) (*pb.Secret, error)

SecretCreate implements the pb.HiroServer interface

func (*RPCServer) SecreteDelete

func (s *RPCServer) SecreteDelete(ctx context.Context, params *pb.SecretDeleteRequest) (*empty.Empty, error)

SecreteDelete implements the pb.HiroServer interface

type RequestToken

type RequestToken struct {
	ID                  ID                        `json:"id" db:"id"`
	Type                oauth.RequestTokenType    `json:"type" db:"type"`
	CreatedAt           oauth.Time                `json:"created_at" db:"created_at"`
	Audience            ID                        `json:"audience_id" db:"audience_id"`
	ApplicationID       ID                        `json:"application_id" db:"application_id"`
	UserID              ID                        `json:"user_id,omitempty" db:"user_id"`
	Scope               oauth.Scope               `json:"scope,omitempty" db:"scope"`
	Passcode            *string                   `json:"passcode,omitempty" db:"passcode"`
	ExpiresAt           oauth.Time                `json:"expires_at" db:"expires_at"`
	CodeChallenge       oauth.PKCEChallenge       `json:"code_challenge,omitempty" db:"code_challenge"`
	CodeChallengeMethod oauth.PKCEChallengeMethod `json:"code_challenge_method,omitempty" db:"code_challenge_method"`
	LoginAttempts       *int                      `json:"login_attempts,omitempty" db:"login_attempts"`
	AppURI              *oauth.URI                `json:"app_uri,omitempty" db:"app_uri"`
	RedirectURI         *oauth.URI                `json:"redirect_uri,omitempty" db:"redirect_uri"`
	State               *string                   `json:"state,omitempty" db:"state"`
}

RequestToken is the backend representation of an oauth.RequestToken

type Role

type Role struct {
	ID          ID                `json:"id" db:"id"`
	Name        string            `json:"name" db:"name"`
	Slug        string            `json:"slug" db:"slug"`
	Description *string           `json:"description,omitempty" db:"description"`
	Permissions oauth.ScopeSet    `json:"permissions,omitempty" db:"-"`
	CreatedAt   time.Time         `json:"created_at" db:"created_at"`
	UpdatedAt   *time.Time        `json:"updated_at,omitempty" db:"updated_at"`
	Metadata    reno.InterfaceMap `json:"metadata,omitempty" db:"metadata"`
}

Role is the database model for an role

type RoleCreateInput

type RoleCreateInput struct {
	Name        string            `json:"name"`
	Description *string           `json:"description,omitempty"`
	Permissions oauth.ScopeSet    `json:"permissions,omitempty"`
	Metadata    reno.InterfaceMap `json:"metadata,omitempty"`
}

RoleCreateInput is the role create request

func (RoleCreateInput) ValidateWithContext

func (a RoleCreateInput) ValidateWithContext(ctx context.Context) error

ValidateWithContext handles validation of the RoleCreateInput struct

type RoleDeleteInput

type RoleDeleteInput struct {
	RoleID ID `json:"role_id"`
}

RoleDeleteInput is the role delete request input

func (RoleDeleteInput) ValidateWithContext

func (a RoleDeleteInput) ValidateWithContext(ctx context.Context) error

ValidateWithContext handles validation of the RoleDeleteInput

type RoleGetInput

type RoleGetInput struct {
	RoleID  *ID     `json:"role_id,omitempty"`
	Name    *string `json:"name,omitempty"`
	Preload *bool   `json:"preload,omitempty"`
}

RoleGetInput is used to get an role for the id

func (RoleGetInput) ValidateWithContext

func (a RoleGetInput) ValidateWithContext(ctx context.Context) error

ValidateWithContext handles validation of the RoleGetInput struct

type RoleListInput

type RoleListInput struct {
	Limit  *uint64 `json:"limit,omitempty"`
	Offset *uint64 `json:"offset,omitempty"`
}

RoleListInput is the role list request

func (RoleListInput) ValidateWithContext

func (a RoleListInput) ValidateWithContext(context.Context) error

ValidateWithContext handles validation of the RoleListInput struct

type RoleType

type RoleType string

RoleType defines an role type

type RoleUpdateInput

type RoleUpdateInput struct {
	RoleID      ID                 `json:"id" structs:"-"`
	Name        *string            `json:"name" structs:"name,omitempty"`
	Description *string            `json:"description,omitempty" structs:"description,omitempty"`
	Permissions *PermissionsUpdate `json:"permissions,omitempty" structs:"-"`
	Metadata    reno.InterfaceMap  `json:"metadata,omitempty" structs:"metadata,omitempty"`
}

RoleUpdateInput is the role update request

func (RoleUpdateInput) ValidateWithContext

func (a RoleUpdateInput) ValidateWithContext(ctx context.Context) error

ValidateWithContext handles validation of the RoleUpdateInput struct

type Secret

type Secret struct {
	ID         ID                    `json:"id" db:"id"`
	Type       SecretType            `json:"type"`
	AudienceID ID                    `json:"audience_id" db:"audience_id"`
	Algorithm  *oauth.TokenAlgorithm `json:"algorithm,omitempty" db:"algorithm"`
	Key        string                `json:"key" db:"key"`
	CreatedAt  time.Time             `json:"created_at" db:"created_at"`
	ExpiresAt  *time.Time            `json:"expires_at,omitempty" db:"expires_at"`
}

Secret is a secret key implemenation of oauth.TokenSecret

func (*Secret) FromProto

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

FromProto convert the proto Secret to an api Secret

func (Secret) ToProto

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

ToProto converts the Secret to its protobuf conterpart

type SecretCreateInput

type SecretCreateInput struct {
	AudienceID ID                    `json:"audience_id"`
	Type       SecretType            `json:"type"`
	Algorithm  *oauth.TokenAlgorithm `json:"algorithm,omitempty"`
	Key        *string               `json:"key,omitempty"`
	ExpiresAt  *time.Time            `json:"expires_at,omitempty"`
}

SecretCreateInput is the params used to create a secret

func (SecretCreateInput) ValidateWithContext

func (s SecretCreateInput) ValidateWithContext(ctx context.Context) error

ValidateWithContext handles validation of the AudienceCreateInput struct

type SecretCreateRoute

type SecretCreateRoute func(ctx context.Context, params *SecretCreateInput) api.Responder

SecretCreateRoute is the secret create route definition

func (SecretCreateRoute) Methods

func (SecretCreateRoute) Methods() []string

Methods implements api.Route

func (SecretCreateRoute) 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 {
	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 Session

type Session struct {
	ID         ID         `json:"id" db:"id"`
	AudienceID ID         `json:"audience_id" db:"audience_id"`
	UserID     ID         `json:"user_id" db:"user_id"`
	Data       string     `json:"data" db:"data"`
	CreatedAt  time.Time  `json:"created_at" db:"created_at"`
	ExpiresAt  time.Time  `json:"expires_at" db:"expires_at"`
	RevokedAt  *time.Time `json:"revoked_at,omitempty" db:"revoked_at"`
}

Session is the backend store representation of session.Session

type 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 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 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"`
	Password          *string           `json:"-" db:"-"`
	PasswordHash      *string           `json:"-" db:"password_hash,omitempty"`
	PasswordExpiresAt *time.Time        `json:"password_expires_at,omitempty" db:"password_expires_at"`
	LockedUntil       *time.Time        `json:"locked_until,omitempty" db:"locked_until,omitempty"`
	Roles             []string          `json:"roles,omitempty"`
	Permissions       oauth.ScopeSet    `json:"permissions,omitempty" db:"-"`
	Profile           *openid.Profile   `json:"profile,omitempty" db:"profile"`
	Metadata          reno.InterfaceMap `json:"metadata,omitempty" db:"metadata"`
}

User is a hiro user

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 {
	Login             string            `json:"login"`
	Password          *string           `json:"password,omitempty"`
	Roles             []string          `json:"roles,omitempty"`
	Profile           *openid.Profile   `json:"profile,omitempty"`
	PasswordExpiresAt *time.Time        `json:"password_expires_at,omitempty" `
	Metadata          reno.InterfaceMap `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 {
	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 {
	UserID ID      `json:"user_id,omitempty"`
	Login  *string `json:"login,omitempty"`
}

UserGetInput is used to get an user for the id

func (UserGetInput) ValidateWithContext

func (u UserGetInput) ValidateWithContext(ctx context.Context) error

ValidateWithContext handles validation of the UserGetInput struct

type UserGetRoute

type UserGetRoute func(ctx context.Context, params *UserGetInput) api.Responder

UserGetRoute is the user create route definition

func (UserGetRoute) 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 {
	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 UserUpdateInput

type UserUpdateInput struct {
	UserID            ID                `json:"user_id" structs:"-"`
	Login             *string           `json:"login,omitempty"`
	Password          *string           `json:"password,omitempty" structs:"-"`
	Profile           *openid.Profile   `json:"profile,omitempty" structs:"profile,omitempty"`
	PasswordExpiresAt *time.Time        `json:"-" structs:"password_expires_at,omitempty"`
	LockedUntil       *time.Time        `json:"locked_until,omitempty" structs:"-"`
	Roles             []string          `json:"roles,omitempty" structs:"-"`
	Metadata          reno.InterfaceMap `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