refactor(session): move session id generator to relevant pkg

This commit is contained in:
Trong Huu Nguyen
2022-06-17 12:19:44 +02:00
parent debf97efda
commit d73a5f24bb
3 changed files with 5 additions and 5 deletions

View File

@@ -79,7 +79,7 @@ func (h *Handler) getSessionLifetime(tokenExpiry time.Time) time.Duration {
}
func (h *Handler) createSession(w http.ResponseWriter, r *http.Request, tokens *jwt.Tokens, rawTokens *oauth2.Token, params url.Values) error {
externalSessionID, err := NewSessionID(h.Provider.GetOpenIDConfiguration(), tokens.IDToken, params)
externalSessionID, err := session.NewSessionID(h.Provider.GetOpenIDConfiguration(), tokens.IDToken, params)
if err != nil {
return fmt.Errorf("generating session ID: %w", err)
}

View File

@@ -1,4 +1,4 @@
package router
package session
import (
"crypto/rand"

View File

@@ -1,4 +1,4 @@
package router_test
package session_test
import (
"net/url"
@@ -10,7 +10,7 @@ import (
"github.com/nais/wonderwall/pkg/jwt"
"github.com/nais/wonderwall/pkg/openid"
"github.com/nais/wonderwall/pkg/router"
"github.com/nais/wonderwall/pkg/session"
)
func TestSessionID(t *testing.T) {
@@ -98,7 +98,7 @@ func TestSessionID(t *testing.T) {
exactMatch: true,
},
} {
actual, err := router.NewSessionID(test.config, test.idToken, test.params)
actual, err := session.NewSessionID(test.config, test.idToken, test.params)
t.Run(test.name, func(t *testing.T) {
if test.expectErr {