DEVELOPMENT ENVIRONMENT

~liljamo/tixe

313b905edc5fb82b56f0aecde376b7468416e117 — Jonni Liljamo 1 year, 1 month ago 08cdeb9
feat: oidc option for issuer trailing slash
2 files changed, 13 insertions(+), 4 deletions(-)

M auth/oidc.go
M config/config.go
M auth/oidc.go => auth/oidc.go +8 -1
@@ 16,7 16,14 @@ import (
)

func NewProviderAndConfig() (*oidc.Provider, oauth2.Config, error) {
	provider, err := oidc.NewProvider(context.Background(), "https://" + config.TixeConfig.OidcDomain)
	var providerUrl string
	if config.TixeConfig.OidcIssuerTrailingSlash {
		providerUrl = "https://" + config.TixeConfig.OidcDomain + "/"
	} else {
		providerUrl = "https://" + config.TixeConfig.OidcDomain
	}

	provider, err := oidc.NewProvider(context.Background(), providerUrl)
	if err != nil {
		log.Printf("[tixe/auth] Failed to create new custom provider")
		return nil, oauth2.Config{}, err

M config/config.go => config/config.go +5 -3
@@ 29,9 29,10 @@ type Config struct {

	CookieSecret string

	OidcDomain   string
	OidcClientID string
	OidcSecret   string
	OidcDomain              string
	OidcIssuerTrailingSlash bool
	OidcClientID            string
	OidcSecret              string
	// What is written on the login button
	OidcLoginVisual string
}


@@ 52,6 53,7 @@ func ParseConfig() {
		CookieSecret: util.LoadVar("TIXE_COOKIE_SECRET", ""),

		OidcDomain: util.LoadVar("TIXE_OIDC_DOMAIN", ""),
		OidcIssuerTrailingSlash: util.LoadVarBool("TIXE_OIDC_ISSUER_TRAILING_SLASH", false),
		OidcClientID: util.LoadVar("TIXE_OIDC_CLIENTID", ""),
		OidcSecret: util.LoadVar("TIXE_OIDC_SECRET", ""),