From 1c9b1d2d7fb9464acdc64b3ceb3f932f0c5d0503 Mon Sep 17 00:00:00 2001 From: Tit Petric Date: Mon, 26 Nov 2018 16:58:19 +0100 Subject: [PATCH] upd(internal): - option to disable OIDC via config - extend TokenEncoder with SetCookie --- internal/auth/interfaces.go | 5 +++++ internal/config/oidc.go | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/internal/auth/interfaces.go b/internal/auth/interfaces.go index ad10152cc..f1179d34f 100644 --- a/internal/auth/interfaces.go +++ b/internal/auth/interfaces.go @@ -1,5 +1,9 @@ package auth +import ( + "net/http" +) + type ( Identifiable interface { Identity() uint64 @@ -8,5 +12,6 @@ type ( TokenEncoder interface { Encode(identity Identifiable) string + SetCookie(w http.ResponseWriter, r *http.Request, identity Identifiable) } ) diff --git a/internal/config/oidc.go b/internal/config/oidc.go index f16ba333f..5fa8af8d4 100644 --- a/internal/config/oidc.go +++ b/internal/config/oidc.go @@ -7,6 +7,7 @@ import ( type ( OIDC struct { + Enabled bool Issuer string ClientID string ClientSecret string @@ -24,7 +25,9 @@ func (c *OIDC) Validate() error { if c == nil { return nil } - + if c.Enabled == false { + return nil + } if c.Issuer == "" { return errors.New("OIDC Issuer not set for AUTH") } @@ -41,6 +44,7 @@ func (*OIDC) Init(prefix ...string) *OIDC { } oidc = new(OIDC) + flag.BoolVar(&oidc.Enabled, "auth-oidc-enabled", true, "OIDC enabled") flag.StringVar(&oidc.Issuer, "auth-oidc-issuer", "", "OIDC Issuer") flag.StringVar(&oidc.ClientID, "auth-oidc-client-id", "", "OIDC Client ID") flag.StringVar(&oidc.ClientSecret, "auth-oidc-client-secret", "", "OIDC Client Secret")