config

package
v0.0.0-...-00f2437 Latest Latest
Warning

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

Go to latest
Published: May 24, 2021 License: MIT Imports: 3 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthConfig

type AuthConfig struct {
	// ServiceName is the name of the GH Gantt server used in the AuthToken Issuer and Audience field
	ServiceName string `required:"true" envconfig:"service_name"`

	// SigningSecret is used to sign JWTs
	SigningSecret string `required:"true" envconfig:"signing_secret"`

	// GHStateSigningPrivKey is the ed25519 key used to sign the state field in a GH authentication request.
	// Not in the normal OpenSSH key format. Instead the first 32 bits are the private key and the last 32 bits are the
	// public key.
	GHStateSigningKey string `validate:"len=64" required:"true" envconfig:"gh_state_signing_key"`
}

AuthConfig holds user authentication configuration

func (AuthConfig) GetGHStateSigningPrivKey

func (c AuthConfig) GetGHStateSigningPrivKey() []byte

GetGHStateSigningPrivKey extracts the private key from the GHStateSigningKey field. In the Go ed25519 library the private key and public key are considered the "private key". So this method simply coverts the entire field to bytes.

func (AuthConfig) GetGHStateSigningPubKey

func (c AuthConfig) GetGHStateSigningPubKey() []byte

GetGHStateSigningPubKey extracts the public key from the GHStateSigningKey field

type Config

type Config struct {
	// HTTPConfig holds HTTP related application configuration
	HTTPConfig

	// GitHubConfig holds GitHub related application configuration
	GitHubConfig

	// AuthConfig holds user authentication related application configuration
	AuthConfig
}

Config holds application configuration

func NewConfig

func NewConfig() (*Config, error)

NewConfig loads Config values from environment variables. Variables names will be capitalized field names from the Config struct, prefixed with APP.

type GitHubConfig

type GitHubConfig struct {
	// GitHubClientID is the server's GitHub application's client ID
	// Set via the APP_GITHUB_CLIENT_ID environment variable
	GitHubClientID string `required:"true" envconfig:"github_client_id"`

	// GitHubClientSecret is the server's GitHub application's client secret
	// Set via the APP_GITHUB_CLIENT_SECRET environment variable
	GitHubClientSecret string `required:"true" envconfig:"github_client_secret"`
}

GitHubConfig holds GitHub related application configuration

type HTTPConfig

type HTTPConfig struct {
	// Port to listen for HTTP requests on
	// Set by APP_PORT environment variable
	Port int `required:"true"`
}

HTTPConfig holds HTTP related application configuration

Jump to

Keyboard shortcuts

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