exposure-notifications-server: github.com/google/exposure-notifications-server/internal/authorizedapp Index | Files | Directories

package authorizedapp

import "github.com/google/exposure-notifications-server/internal/authorizedapp"

Package authorizedapp handles allowed applications.

Index

Package Files

config.go database_provider.go memory_provider.go provider.go

Variables

var ErrAppNotFound = errors.New("app not found")

ErrAppNotFound is the sentinel error returned when AppConfig fails to find an app with the given name.

type Config Uses

type Config struct {
    // CacheDuration is the amount of time AuthorizedApp should be cached before
    // being re-read from their provider.
    CacheDuration time.Duration `env:"AUTHORIZED_APP_CACHE_DURATION,default=5m"`
}

func (*Config) AuthorizedApp Uses

func (c *Config) AuthorizedApp() *Config

AuthorizedApp implements an interface for setup.

type DatabaseProvider Uses

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

DatabaseProvider is a Provider that pulls from the database and caches and refreshes values on failure.

func (*DatabaseProvider) Add Uses

func (p *DatabaseProvider) Add(ctx context.Context, app *model.AuthorizedApp) error

Add adds a new authorized app to the system.

func (*DatabaseProvider) AppConfig Uses

func (p *DatabaseProvider) AppConfig(ctx context.Context, name string) (*model.AuthorizedApp, error)

AppConfig returns the config for the given app package name.

type DatabaseProviderOption Uses

type DatabaseProviderOption func(*DatabaseProvider) *DatabaseProvider

DatabaseProviderOption is used as input to the database provider.

type MemoryProvider Uses

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

MemoryProvider is an Provider that stores values in-memory. It is primarily used for testing.

func (*MemoryProvider) Add Uses

func (p *MemoryProvider) Add(_ context.Context, app *model.AuthorizedApp) error

Add inserts the app. It returns an error if the app already exists.

func (*MemoryProvider) AppConfig Uses

func (p *MemoryProvider) AppConfig(_ context.Context, name string) (*model.AuthorizedApp, error)

AppConfig returns the config for the given app package name.

type Provider Uses

type Provider interface {
    // AppConfig returns the application-specific configuration for the given
    // name. An error is returned if the configuration fails to load. An error is
    // returned if no app with the given name is registered in the system.
    //
    // The name field is case-insensitive. Implementers should adjust accordingly
    // to handle mixed case. com.MyApp is the same as com.myapp.
    AppConfig(context.Context, string) (*model.AuthorizedApp, error)

    // Add inserts a model into the provider.
    Add(context.Context, *model.AuthorizedApp) error
}

Provider defines possible AuthorizedApp providers.

func NewDatabaseProvider Uses

func NewDatabaseProvider(ctx context.Context, db *database.DB, config *Config, opts ...DatabaseProviderOption) (Provider, error)

NewDatabaseProvider creates a new Provider that reads from a database.

func NewMemoryProvider Uses

func NewMemoryProvider(_ context.Context, _ *Config) (Provider, error)

NewMemoryProvider creates a new Provider that is in memory.

Directories

PathSynopsis
databasePackage database is a database interface to authorized apps.
modelPackage model is a model abstraction of authorized apps.

Package authorizedapp imports 11 packages (graph) and is imported by 4 packages. Updated 2020-09-27. Refresh now. Tools for package owners.