upd(internal):

- option to disable OIDC via config
- extend TokenEncoder with SetCookie
This commit is contained in:
Tit Petric
2018-11-26 16:58:19 +01:00
parent 256a45bdb6
commit 1c9b1d2d7f
2 changed files with 10 additions and 1 deletions
+5
View File
@@ -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)
}
)
+5 -1
View File
@@ -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")