utils

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckHtaccessUser added in v0.1.1

func CheckHtaccessUser(username string, password string) bool

func GeneralResponseTemplate

func GeneralResponseTemplate(w http.ResponseWriter, error string, code int)

func GenerateRandomBytes

func GenerateRandomBytes(n int) []byte

func GenerateRandomString

func GenerateRandomString(s int) string

func RenderTemplate

func RenderTemplate(w http.ResponseWriter, tmpl string, data interface{})

func RenderTemplateWithResultCode

func RenderTemplateWithResultCode(w http.ResponseWriter, tmpl string, data interface{}, code int)

Types

type Config

type Config struct {
	Server struct {
		Port     string `yaml:"port" envconfig:"PORT"`
		Uri      string `yaml:"uri" envconfig:"URI"`
		Loglevel int    `yaml:"loglevel" envconfig:"LOGLEVEL"`
	} `yaml:"server"`
	AdminBackend struct {
		BaseUrl string `yaml:"base_url" envconfig:"BASEURL"`
	} `yaml:"adminbackend"`
	OAuthServer struct {
		Duration         int              `yaml:"duration" envconfig:"DURATION"`
		InternalDuration int              `yaml:"internal_duration" envconfig:"INTERNALDURATION"`
		DefaultAudience  string           `yaml:"default_audience" envconfig:"DEFAULTAUDIENCE"`
		StaticAudiences  []StaticAudience `yaml:"static_audience" envconfig:"STATICAUDIENCE"`
		Signing          Signing          `yaml:"signing" envconfig:"SIGNING"`
		Issuer           string           `yaml:"issuer" envconfig:"ISSUER"`
		RedirectDomain   string           `yaml:"redirect_domain" envconfig:"REDIRECTDOMAIN"`
	} `yaml:"oauthserver"`
	Aad struct {
		ClientId     string   `yaml:"clientid" envconfig:"CLIENTID"`
		ClientSecret string   `yaml:"clientsecret" envconfig:"CLIENTSECRET"`
		TenantId     string   `yaml:"tenantid" envconfig:"TENANTID"`
		CallbackUrl  string   `yaml:"callback_url" envconfig:"CALLBACKURL"`
		JwksUri      string   `yaml:"jwksuri" envconfig:"JWKSURI"`
		Issuers      []string `yaml:"issuers"`
	} `yaml:"aad"`
	Google struct {
		ClientId     string   `yaml:"clientid" envconfig:"CLIENTID"`
		ClientSecret string   `yaml:"clientsecret" envconfig:"CLIENTSECRET"`
		CallbackUrl  string   `yaml:"callback_url" envconfig:"CALLBACKURL"`
		Issuers      []string `yaml:"issuers"`
	} `yaml:"google"`
	BasicAuth struct {
		Enabled bool   `yaml:"enabled" envconfig:"ENABLED"`
		Users   string `yaml:"users" envconfig:"USERS"`
	} `yaml:"basicauth"`
}

func ReadConfig

func ReadConfig() *Config

type Hs256

type Hs256 struct {
	Secret string `yaml:"secret" envconfig:"OAUTHSERVER_SIGNING_HS256_SECRET"`
}

type Rs256

type Rs256 struct {
	PrivateKeyPath string `yaml:"private_key_path" envconfig:"OAUTHSERVER_SIGNING_RS256_PRIVATEKEY"`
	PublicKeyPath  string `yaml:"public_key_path" envconfig:"OAUTHSERVER_SIGNING_RS256_PUBLICKEY"`
	JwkId          string `yaml:"jwk_id" envconfig:"OAUTHSERVER_SIGNING_RS256_JWKID"`
}

type Signing

type Signing struct {
	Method string `yaml:"method" envconfig:"METHOD"`
	Rs256  Rs256  `yaml:"rs256" envconfig:"RS256"`
	Hs256  Hs256  `yaml:"hs256" envconfig:"HS256"`
}

type StaticAudience

type StaticAudience struct {
	Name         string `yaml:"name" envconfig:"NAME"`
	Redirect     string `yaml:"redirect" envconfig:"REDIRECT"`
	Authorize    bool   `yaml:"authorize" envconfig:"AUTHORIZE"`
	AuthorizeUrl string `yaml:"authorizeUrl" envconfig:"AUTHORIZEURL"`
}

func FindStaticAudience

func FindStaticAudience(config Config, audience string) *StaticAudience

Jump to

Keyboard shortcuts

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