auth

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2026 License: MIT Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CognitoConfig added in v0.2.5

type CognitoConfig struct {
	UseLocal   bool   `env:"COGNITO_USE_LOCAL" yaml:"cognitoUseLocal" envDefault:"false" safe:"true"`
	Endpoint   string `env:"COGNITO_ENDPOINT" yaml:"cognitoEndpoint" safe:"true"`
	ClientId   string `env:"COGNITO_CLIENT_ID" json:"cognitoClientId" yaml:"cognitoClientId"`
	UserPoolId string `env:"COGNITO_USER_POOL_ID" json:"cognitoUserPoolId" yaml:"cognitoUserPoolId"`
}

CognitoConfig Struct meant to wrap configuration values to work alongside the https://github.com/project-init/terraform-aws-cognito terraform module. Usage would look similar to

type Config struct {
	// Cognito
	CognitoConfig auth.CognitoConfig `env:"COGNITO" yaml:"cognito" safe:"true"`
}

var (
	configuration *Config = &Config{}
	once          sync.Once
)

func GetConfig() *Config {
	once.Do(func() {
		opts := []cfg.Option{}

		if configFiles, ok := os.LookupEnv(EnvVarConfigFiles); ok && len(configFiles) > 0 {
			opts = append(opts, cfg.NewFileOption(configFiles))
		}

		if smSecrets, ok := os.LookupEnv(EnvVarConfigAWSSecretsManagerSecrets); ok && len(smSecrets) > 0 {
			opts = append(opts, cfg.NewAWSSecretsManagerOption(secretsmanager.NewFromConfig(aws.GetConfig()), strings.Split(smSecrets, ",")...))
		}

		opts = append(opts, cfg.NewEnvOption())

		if err := cfg.LoadConfigs(configuration, opts...); err != nil {
			sre.LogFatal(err)
		}
	})

	return configuration
}

type OauthHandler

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

func NewOauthHandler

func NewOauthHandler(clientId string, clientSecret string, redirectUrl string, issuerUrl string, scopes []string) (*OauthHandler, error)

NewOauthHandler creates a handler that is meant to operate between oidc and oauth to handle the necessary redirects and issuer interactions. This has been tested against Cognito specifically.

func (*OauthHandler) AuthCodeUrl

func (h *OauthHandler) AuthCodeUrl(state string, opts ...oauth2.AuthCodeOption) string

func (*OauthHandler) ExchangeCode

func (h *OauthHandler) ExchangeCode(ctx context.Context, code string) (*oauth2.Token, error)

func (*OauthHandler) Verifier

func (h *OauthHandler) Verifier() *oidc.IDTokenVerifier

Jump to

Keyboard shortcuts

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