Files
ca/Documentation/api/server_appcontainer.md
c28383ed14 Worktree findings batch 2 (#17)
* Fix issues F-003, 006, 001, 022

* Fix issues F-025, 026, 010, 008

- Login tokens name their identity provider in the `provider` claim;
  SelectOrg and GetUserToken read it with pb.IDPFromString, which also
  takes the number older tokens carry, and AuthenticateAPIKey answers
  Provider Undefined.
- A login that fails after the callback decodes its state lands on the
  redirect URI of the client, in its response mode, with `error` and
  `error_description` (RFC 6749 section 4.1.2.1); a server-side failure
  is described by its status text only. The calls to an IdP take the
  request context and a client with a timeout, and the answer of the IdP
  stays in the server log.
- The platform bootstrap reads its ca-config with ca.LoadBootstrapConfig,
  which refuses an issuer URL template with `${ISSUER_ID}` or
  `$ISSUER_ID`: the loader expands them to an empty string. The proto,
  README and CLI help name `:ISSUER_ID`.
- CaDb.RegisterIssuer takes the trust anchor of a root issuer and writes
  both in one transaction; the backend service and the bootstrap pass it,
  and an anchor registered in another scope is AlreadyExists.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Address PR review comments

- Invite acceptance deletes the invite in its transaction
  (query.TakeInvite, DELETE ... RETURNING) and grants from the deleted
  row: a withdrawn or already accepted invite grants nothing, a re-issued
  one grants its current role, and an email mismatch, an expired invite or
  a failed grant rolls the delete back.
- CaDb.RegisterIssuer requires the anchor of a root issuer and refuses one
  for any other issuer; the service always builds it for a root.
- The OAuth response is merged into the query of a redirect URI that has
  one, and replaces its fragment in fragment mode.
- The codemap describes the transactions of RegisterOrg and the invite
  acceptance.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
2026-10-23 19:59:28 -05:00

14 KiB

appcontainer

import "github.com/effective-security/trustyca/server/appcontainer"

Index

type CloseRegistrator

CloseRegistrator provides interface to release resources on close

type CloseRegistrator interface {
    OnClose(closer io.Closer)
}

type Closer

Closer provides a closer interface

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

func NewCloser

func NewCloser(capacity int) *Closer

NewCloser returns new instance of a closer

func (*Closer) Close

func (a *Closer) Close() error

Close implements Closer interface to clean up resources

func (*Closer) OnClose

func (a *Closer) OnClose(closer io.Closer)

OnClose adds a closer to be called when application exists

type ContainerFactory

ContainerFactory is default implementation

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

func NewContainerFactory

func NewContainerFactory(closer CloseRegistrator) *ContainerFactory

NewContainerFactory returns an instance of ContainerFactory

func (*ContainerFactory) CreateContainerWithDependencies

func (f *ContainerFactory) CreateContainerWithDependencies() (*dig.Container, error)

CreateContainerWithDependencies returns an instance of Container

func (*ContainerFactory) WithAuthorizerProvider

func (f *ContainerFactory) WithAuthorizerProvider(p ProvideAuthorizerFn) *ContainerFactory

WithAuthorizerProvider allows to specify custom RoleChecker provider

func (*ContainerFactory) WithCAProvider

func (f *ContainerFactory) WithCAProvider(p ProvideCAFn) *ContainerFactory

WithCAProvider allows to specify a custom provider of the CA issuer registry

func (*ContainerFactory) WithCacheProvider

func (f *ContainerFactory) WithCacheProvider(p ProvideCacheFn) *ContainerFactory

WithCacheProvider allows to specify Cache provider

func (*ContainerFactory) WithClientFactoryProvider

func (f *ContainerFactory) WithClientFactoryProvider(p ProvideClientFactoryFn) *ContainerFactory

WithClientFactoryProvider allows to specify custom client.Factory provider

func (*ContainerFactory) WithConfigurationProvider

func (f *ContainerFactory) WithConfigurationProvider(p ProvideConfigurationFn) *ContainerFactory

WithConfigurationProvider allows to specify configuration

func (*ContainerFactory) WithCryptoProvider

func (f *ContainerFactory) WithCryptoProvider(p ProvideCryptoFn) *ContainerFactory

WithCryptoProvider allows to specify custom Crypto loader

func (*ContainerFactory) WithDataprotectionProvider

func (f *ContainerFactory) WithDataprotectionProvider(p ProvideDataprotectionFn) *ContainerFactory

WithDataprotectionProvider allows to specify Data protection provider

func (*ContainerFactory) WithDbProvider

func (f *ContainerFactory) WithDbProvider(p ProvideDbFn) *ContainerFactory

WithDbProvider allows to specify custom DB provider

func (*ContainerFactory) WithDiscoveryProvider

func (f *ContainerFactory) WithDiscoveryProvider(p ProvideDiscoveryFn) *ContainerFactory

WithDiscoveryProvider allows to specify Discovery

func (*ContainerFactory) WithJwtProvider

func (f *ContainerFactory) WithJwtProvider(p ProvideJwtFn) *ContainerFactory

WithJwtProvider allows to specify custom JWT provider

func (*ContainerFactory) WithOAuth2ClientsProvider

func (f *ContainerFactory) WithOAuth2ClientsProvider(p ProvideOAuth2ClientsFn) *ContainerFactory

WithOAuth2ClientsProvider allows to specify custom OAuth2 clients provider

func (*ContainerFactory) WithSchedulerProvider

func (f *ContainerFactory) WithSchedulerProvider(p ProvideSchedulerFn) *ContainerFactory

WithSchedulerProvider allows to specify custom Scheduler

type ContainerFactoryFn

ContainerFactoryFn defines an app container factory interface

type ContainerFactoryFn func() (*dig.Container, error)

type ProvideAuthorizerFn

ProvideAuthorizerFn defines role checker provider

type ProvideAuthorizerFn func(trustycaDb db.OrgsDb) authctx.Authorizer

type ProvideCAFn

ProvideCAFn defines the provider of the CA issuer registry

type ProvideCAFn func(cfg *config.Configuration, crypto *cryptoprov.Crypto, dp dataprotection.Provider, caDb db.CaDb) (*ca.Registry, error)

type ProvideCacheFn

ProvideCacheFn defines Cache provider

type ProvideCacheFn func(cfg *config.Configuration, closer CloseRegistrator) (cache.Provider, error)

type ProvideClientFactoryFn

ProvideClientFactoryFn defines client.Facroty provider

type ProvideClientFactoryFn func(cfg *config.Configuration) (client.Factory, error)

type ProvideConfigurationFn

ProvideConfigurationFn defines Configuration provider

type ProvideConfigurationFn func() (*config.Configuration, error)

type ProvideCryptoFn

ProvideCryptoFn defines Crypto provider

type ProvideCryptoFn func(cfg *config.Configuration) (*cryptoprov.Crypto, error)

type ProvideDataprotectionFn

ProvideDataprotectionFn defines data protection provider

type ProvideDataprotectionFn func() (dataprotection.Provider, error)

type ProvideDbFn

ProvideDbFn defines DB provider

type ProvideDbFn func(cfg *config.Configuration) (db.Provider, db.OrgsDb, db.OrgsReadonlyDb, db.CaDb, db.CaReadonlyDb, error)

type ProvideDiscoveryFn

ProvideDiscoveryFn defines Discovery provider

type ProvideDiscoveryFn func() (discovery.Discovery, error)

type ProvideJwtFn

ProvideJwtFn defines JWT provider

type ProvideJwtFn func(cfg *config.Configuration, dp dataprotection.Provider, cache cache.Provider) (jwt.Parser, jwt.Signer, error)

type ProvideOAuth2ClientsFn

ProvideOAuth2ClientsFn defines OAuth2 clients provider

type ProvideOAuth2ClientsFn func(cfg *config.Configuration) (*oauth2client.Provider, error)

type ProvideSchedulerFn

ProvideSchedulerFn defines Scheduler provider

type ProvideSchedulerFn func() (tasks.Scheduler, error)

Generated by gomarkdoc