Sessions in etcd KV store instead of cookies
This commit is contained in:
@@ -19,6 +19,7 @@ func (p *IdentificationProvider) GroupsMiddleware(next http.Handler) http.Handle
|
||||
|
||||
o, ok := session.Values["organization"]
|
||||
if !ok || o == nil {
|
||||
fmt.Println("no organization")
|
||||
http.Redirect(w, r, "/auth/groups/", http.StatusFound)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"net/http"
|
||||
|
||||
"git.coopgo.io/coopgo-apps/parcoursmob/services"
|
||||
"git.coopgo.io/coopgo-apps/parcoursmob/utils/storage"
|
||||
"github.com/coreos/go-oidc"
|
||||
"github.com/gorilla/sessions"
|
||||
"github.com/spf13/viper"
|
||||
@@ -28,7 +29,7 @@ type IdentificationProvider struct {
|
||||
Services *services.ServicesHandler
|
||||
}
|
||||
|
||||
func NewIdentificationProvider(cfg *viper.Viper, services *services.ServicesHandler) (*IdentificationProvider, error) {
|
||||
func NewIdentificationProvider(cfg *viper.Viper, services *services.ServicesHandler, kv storage.KVHandler) (*IdentificationProvider, error) {
|
||||
var (
|
||||
providerURL = cfg.GetString("identification.oidc.provider")
|
||||
clientID = cfg.GetString("identification.oidc.client_id")
|
||||
@@ -54,7 +55,7 @@ func NewIdentificationProvider(cfg *viper.Viper, services *services.ServicesHand
|
||||
Scopes: []string{oidc.ScopeOpenID, "groups", "first_name", "last_name", "display_name"},
|
||||
}
|
||||
|
||||
var store = sessions.NewCookieStore([]byte(sessionsSecret))
|
||||
store := storage.NewSessionStore(kv, []byte(sessionsSecret))
|
||||
verifier := provider.Verifier(&oidc.Config{ClientID: oauth2Config.ClientID})
|
||||
|
||||
return &IdentificationProvider{
|
||||
|
||||
Reference in New Issue
Block a user