Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OIDC Timeout and Web UI #911

Merged
merged 1 commit into from
Apr 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/defaults/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ const (
ActivePartyTTL = 30 * time.Second

// OIDCAuthRequestTTL is TTL of internally stored auth request created by client
OIDCAuthRequestTTL = 60 * time.Second
OIDCAuthRequestTTL = 10 * 60 * time.Second

// LogRotationPeriod defines how frequently to rotate the audit log file
LogRotationPeriod = (time.Hour * 24)
Expand Down
19 changes: 17 additions & 2 deletions lib/web/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import (
log "github.com/Sirupsen/logrus"
"github.com/gravitational/roundtrip"
"github.com/gravitational/trace"
"github.com/jonboulle/clockwork"
"github.com/julienschmidt/httprouter"
"github.com/mailgun/lemma/secret"
"github.com/mailgun/ttlmap"
Expand All @@ -64,6 +65,7 @@ type Handler struct {
auth *sessionCache
sites *ttlmap.TtlMap
sessionStreamPollPeriod time.Duration
clock clockwork.Clock
}

// HandlerOption is a functional argument - an option that can be passed
Expand Down Expand Up @@ -136,6 +138,10 @@ func NewHandler(cfg Config, opts ...HandlerOption) (*RewritingHandler, error) {
h.sessionStreamPollPeriod = sessionStreamPollPeriod
}

if h.clock == nil {
h.clock = clockwork.NewRealClock()
}

// a response indicates if the server is up and the response data
// indicates the type of authentication methods that are supported
// TODO(russjones): Where is /webapi, that was the old /ping?
Expand Down Expand Up @@ -442,6 +448,7 @@ func (m *Handler) getConfigurationSettings(w http.ResponseWriter, r *http.Reques

func (m *Handler) oidcLoginWeb(w http.ResponseWriter, r *http.Request, p httprouter.Params) (interface{}, error) {
log.Infof("oidcLoginWeb start")

query := r.URL.Query()
clientRedirectURL := query.Get("redirect_url")
if clientRedirectURL == "" {
Expand Down Expand Up @@ -496,10 +503,18 @@ func (m *Handler) oidcLoginConsole(w http.ResponseWriter, r *http.Request, p htt

func (m *Handler) oidcCallback(w http.ResponseWriter, r *http.Request, p httprouter.Params) (interface{}, error) {
log.Infof("oidcCallback start")

response, err := m.cfg.ProxyClient.ValidateOIDCAuthCallback(r.URL.Query())
if err != nil {
log.Infof("VALIDATE error: %v", err)
return nil, trace.Wrap(err)
log.Infof("[OIDC] Error while processing callback: %v", err)

// redirect to an error page
pathToError := url.URL{
Path: "/web/msg/error/login_failed",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets start using constants for UI route strings

RawQuery: url.Values{"details": []string{"Unable to process callback from OIDC provider."}}.Encode(),
}
http.Redirect(w, r, pathToError.String(), http.StatusFound)
return nil, nil
}
// if we created web session, set session cookie and redirect to original url
if response.Req.CreateWebSession {
Expand Down