config

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: Apache-2.0 Imports: 11 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Secret   Secret
	Variable Variable

	SnowflakeNode  *snowflake.Node
	Logger         logging.Logger
	TokenEngine    token.Engine
	SessionManager *session.Manager
}

func Load

func Load(paths ...string) (*Config, error)

type FileVariable added in v0.7.0

type FileVariable struct {
	// MaxInMemory indicates the maximum number of bytes a file can store in
	// memory. If the file size exceeds this value, it will be stored in a
	// temporary file instead.
	MaxInMemory int64 `envconfig:"max_in_memory"`

	// UploadTokenExpiration is the duration during which the user can use the
	// upload_token to upload a file.
	UploadTokenExpiration int `envconfig:"upload_token_expiration"`

	// TokenExpiration is the duration during which the user can use the
	// file_token to interact with other APIs.
	TokenExpiration int `envconfig:"token_expiration"`

	StorageImageBucket string `envconfig:"storage_image_bucket"`
	StorageOtherBucket string `envconfig:"storage_other_bucket"`
}

func DefaultFileVariable added in v0.7.0

func DefaultFileVariable() FileVariable

type MinioSecret added in v0.7.0

type MinioSecret struct {
	AccessKey string `envconfig:"access_key"`
	SecretKey string `envconfig:"secret_key"`
}

type MinioVariable added in v0.7.0

type MinioVariable struct {
	Endpoint string `envconfig:"endpoint"`
}

func DefaultMinioVariable added in v0.7.0

func DefaultMinioVariable() MinioVariable

type OAuth2ClientVariable added in v0.4.2

type OAuth2ClientVariable struct {
	SecretLength int `envconfig:"secret_length"`
}

func DefaultOAuth2ClientVariable added in v0.4.2

func DefaultOAuth2ClientVariable() OAuth2ClientVariable

type OAuth2Secret

type OAuth2Secret struct {
	IdPSecret string `envconfig:"idp_secret"`

	// Using RSA key to sign and verify the token. If both RSAKey and SecretKey
	// are provided, RSAKey will be used.
	TokenRSAPrivateKey string `envconfig:"token_rsa_private_key"`
	TokenRSAPublicKey  string `envconfig:"token_rsa_public_key"`

	// Use HMAC to sign and verify the token. Not support verifying at client.
	TokenHMACSecretKey string `envconfig:"token_hmac_secret_key"`
}

type OAuth2Variable

type OAuth2Variable struct {
	IdPLoginURL string `envconfig:"idp_login_url"`

	TokenIssuer string `envconfig:"token_issuer"`

	AccessTokenExpiration  int `envconfig:"access_token_expiration"`  // in second
	RefreshTokenExpiration int `envconfig:"refresh_token_expiration"` // in second
	IDTokenExpiration      int `envconfig:"id_token_expiration"`      // in second

	// AuthorizationCodeFlowExpiration is the duration during which the code
	// must be exchanged.
	AuthorizationCodeFlowExpiration int `envconfig:"authorization_code_flow_expiration"` // in second

	// AuthenticationCallbackExpiration is the duration during which the IdP
	// must send the result to /auth/callback. Otherwise, the user must return
	// to the Client App to authenticate again.
	AuthenticationCallbackExpiration int `envconfig:"authentication_callback_expiration"` // in second

	// SessionUpdateExpiration is the duration during which the user must be
	// redirected to /session/update to update their session. Otherwise, the
	// user will be redirected to the IdP login page again.
	SessionUpdateExpiration int `envconfig:"session_update_expiration"` // in second

	// ConsentSessionExpiration is the duration during which the user must be
	// redirected to /oauth2/authorize to responds to Client about the consent
	// result. Otherwise, the user will be redirected to the consent page again.
	ConsentSessionExpiration int `envconfig:"consent_session_expiration"` // in second

	// ConsentExpiration is the duration during which every request to
	// /oauth2/authorize will be automatically consented to by the user. After
	// this period, the user will be redirected to the consent page again.
	ConsentExpiration int `envconfig:"consent_expiration"` // in second
}

func DefaultOAuth2Variable

func DefaultOAuth2Variable() OAuth2Variable

type PostgresSecret

type PostgresSecret struct {
	DSN string `envconfig:"dsn"`
}

type PostgresVariable

type PostgresVariable struct {
	LogLevel      int `envconfig:"loglevel"`
	RetryAttempts int `envconfig:"retry_attempts"`
	RetryInterval int `envconfig:"retry_interval"` // in second
}

func DefaultPostgresVariable

func DefaultPostgresVariable() PostgresVariable

type RedisSecret

type RedisSecret struct {
	Username string `envconfig:"username"`
	Password string `envconfig:"password"`
}

type RedisVariable

type RedisVariable struct {
	Addr string `envconfig:"addr"`
	DB   int    `envconfig:"db"`
}

func DefaultRedisVariable

func DefaultRedisVariable() RedisVariable

type Secret

type Secret struct {
	Postgres PostgresSecret `envconfig:"postgres"`
	OAuth2   OAuth2Secret   `envconfig:"oauth2"`
	Redis    RedisSecret    `envconfig:"redis"`
	Minio    MinioSecret    `envconfig:"minio"`
	Session  SessionSecret  `envconfig:"session"`
	Service  ServiceSecret  `envconfig:"service"`
}

type ServerVariable

type ServerVariable struct {
	Host           string `envconfig:"host"`
	Port           int    `envconfig:"port"`
	NodeID         int    `envconfig:"nodeid"`
	LogLevel       int    `envconfig:"loglevel"`
	RequestTimeout int    `envconfig:"request_timeout"` // The timeout of each request (in millisecond).
}

func DefaultServerVariable

func DefaultServerVariable() ServerVariable

type ServiceSecret added in v0.6.0

type ServiceSecret struct {
	ClientID     string `envconfig:"client_id"`
	ClientSecret string `envconfig:"client_secret"`
}

type ServiceVariable added in v0.3.0

type ServiceVariable struct {
	OAuth2TokenURL       string `envconfig:"oauth2_token_url"`
	UserGRPCAddr         string `envconfig:"user_grpc_addr"`
	OAuth2ClientGRPCAddr string `envconfig:"oauth2_client_grpc_addr"`
	FileGRPCAddr         string `envconfig:"file_grpc_addr"`
}

func DefaultServiceVariable added in v0.3.0

func DefaultServiceVariable() ServiceVariable

type SessionSecret

type SessionSecret struct {
	AuthenticationKey string `envconfig:"authentication_key"`
	EncryptionKey     string `envconfig:"encryption_key"`
}

type SessionVariable

type SessionVariable struct {
	Expiration int `envconfig:"expiration"`
}

func DefaultSessionVariable

func DefaultSessionVariable() SessionVariable

type UserVariable added in v0.7.0

type UserVariable struct {
	AvatarAllowedTypes           []string `envconfig:"avatar_allowed_types"`
	AvatarMaxSize                int64    `envconfig:"avatar_max_size"`
	AvatarPresignedURLExpiration int      `envconfig:"avatar_presigned_url_expiration"`
}

func DefaultUserVariable added in v0.7.0

func DefaultUserVariable() UserVariable

type Variable

type Variable struct {
	Server       ServerVariable       `envconfig:"server"`
	Postgres     PostgresVariable     `envconfig:"postgres"`
	Redis        RedisVariable        `envconfig:"redis"`
	Minio        MinioVariable        `envconfig:"minio"`
	OAuth2       OAuth2Variable       `envconfig:"oauth2"`
	OAuth2Client OAuth2ClientVariable `envconfig:"oauth2_client"`
	Session      SessionVariable      `envconfig:"session"`
	Service      ServiceVariable      `envconfig:"service"`
	File         FileVariable         `envconfig:"file"`
	User         UserVariable         `envconfig:"user"`
}

func DefaultVariable

func DefaultVariable() Variable

Jump to

Keyboard shortcuts

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