Skip to content

Commit

Permalink
logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Facchetti committed Jul 7, 2023
1 parent 8e50469 commit f670deb
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/portal/middleware/aad.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ func (a *aad) AAD(h http.Handler) http.Handler {
}
http.SetCookie(w, cookie)
http.Redirect(w, r, "/api/login", http.StatusTemporaryRedirect)
a.log.Errorf("redirecting to login page")
} else {
a.internalServerError(w, err)
}
Expand Down Expand Up @@ -183,6 +184,8 @@ func (a *aad) CheckAuthentication(h http.Handler) http.Handler {
ctx := r.Context()
if ctx.Value(ContextKeyUsername) == nil {
if r.URL != nil {

Check failure on line 186 in pkg/portal/middleware/aad.go

View workflow job for this annotation

GitHub Actions / golangci-lint

unnecessary leading newline (whitespace)

a.log.Errorf("redirecting to login page from check auth")
http.Redirect(w, r, "/api/login", http.StatusTemporaryRedirect)
return
}
Expand Down Expand Up @@ -231,12 +234,14 @@ func (a *aad) redirect(w http.ResponseWriter, r *http.Request) {
sessionKeyState: state,
}

a.log.Error("saving session")
err = session.Save(r, w)
if err != nil {
a.internalServerError(w, err)
return
}

a.log.Errorf("login function redirecting to login page %s", a.oauther.AuthCodeURL(state))
http.Redirect(w, r, a.oauther.AuthCodeURL(state), http.StatusTemporaryRedirect)
}

Expand All @@ -257,6 +262,7 @@ func (a *aad) callback(w http.ResponseWriter, r *http.Request) {

delete(session.Values, sessionKeyState)

a.log.Error("saving session")
err = session.Save(r, w)
if err != nil {
a.internalServerError(w, err)
Expand All @@ -282,6 +288,7 @@ func (a *aad) callback(w http.ResponseWriter, r *http.Request) {
Transport: roundtripper.RoundTripperFunc(a.clientAssertion),
})

a.log.Error("getting the token from oauther")
token, err := a.oauther.Exchange(cliCtx, r.FormValue("code"))
if err != nil {
a.internalServerError(w, err)
Expand Down Expand Up @@ -316,6 +323,7 @@ func (a *aad) callback(w http.ResponseWriter, r *http.Request) {
session.Values[SessionKeyGroups] = groupsIntersect
session.Values[SessionKeyExpires] = a.now().Add(a.sessionTimeout).Unix()

a.log.Error("saving session")
err = session.Save(r, w)
if err != nil {
a.internalServerError(w, err)
Expand Down

0 comments on commit f670deb

Please sign in to comment.