Skip to content
Snippets Groups Projects
Commit 35c218ac authored by Christian Pointner's avatar Christian Pointner
Browse files

added arguments for new oidc session request to in future accept access_tokens

parent 95513371
No related branches found
No related tags found
No related merge requests found
......@@ -97,7 +97,7 @@ func newSession() http.Handler {
sendHTTPErrorResponse(w, http.StatusConflict, "OIDC authentication is not enabled")
return
}
s, err := auth.oidc.NewOIDCSession()
s, err := auth.oidc.NewOIDCSession(request.Arguments)
if err != nil {
sendHTTPErrorResponse(w, http.StatusBadRequest, "Error creating session: "+err.Error())
return
......
......@@ -26,6 +26,7 @@ package auth
import (
"context"
"encoding/json"
"errors"
"net/http"
"time"
......@@ -105,11 +106,17 @@ func (b *OIDCBackend) String() string {
// TODO: implement session refresh go-routine
// see: https://github.com/golang/oauth2/issues/84
func (b *OIDCBackend) NewOIDCSession() (s *Session, err error) {
func (b *OIDCBackend) NewOIDCSession(arguments json.RawMessage) (s *Session, err error) {
os := &OIDCSession{backend: b}
if os.nonce, err = generateRandomString(16); err != nil {
return
}
if arguments != nil {
os.token = &oauth2.Token{}
if err = json.Unmarshal(arguments, os.token); err != nil {
return nil, errors.New("failed to parse Oauth2 Token: " + err.Error())
}
}
if s, err = NewSession(); err != nil {
return
......@@ -119,6 +126,11 @@ func (b *OIDCBackend) NewOIDCSession() (s *Session, err error) {
return nil, err
}
if os.token != nil {
// TODO: get fetch OIDC UserInfo and set the session state to logged-in!
return
}
time.AfterFunc(b.loginTimeout, func() {
if s.updateState(SessionStateNew, SessionStateLoginTimeout) {
return
......
......@@ -51,7 +51,8 @@ type AuthBackendInfo struct {
}
type NewSessionRequest struct {
Backend string `json:"backend"`
Backend string `json:"backend"`
Arguments json.RawMessage `json:"arguments"`
}
type NewSessionResponse struct {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment