Skip to content

Commit

Permalink
feat(token): forward access_token internally (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
portellaa authored Feb 22, 2023
1 parent 45424db commit 2a6889c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions internal/configurations/rest_controller_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type RESTControllerConfiguration struct {
LogoutURL string `envconfig:"LOGOUT_URL" default:"/logout"`
UserInfoURL string `envconfig:"USER_INFO_URL" default:"/userinfo"`
HTTPRequestTimeout time.Duration `envconfig:"HTTP_REQUEST_TIMEOUT" default:"30s"`
AccessTokenCookie string `envconfig:"ACCESS_TOKEN_COOKIE" default:"access_token"`
UserIDHeader string `envconfig:"USER_ID_HEADER" default:"userid"`
CookieMaxAge int `envconfig:"COOKIE_MAX_AGE" default:"86400"`
SkipURLs []string `envconfig:"SKIP_URLS" default:"/dex" split_words:"true"`
Expand Down
2 changes: 2 additions & 0 deletions internal/controllers/rest_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ func (rc RESTController) CheckForAuthentication(w http.ResponseWriter, r *http.R
rc.logger.Debugf("Valid Token: %s", token)
rc.logger.Infof("Authorizing request for UserID: %v", userInfo.Email)

http.SetCookie(w, &http.Cookie{Name: rc.configuration.AccessTokenCookie, Value: token})

// set UserID Header + 200 OK
w.Header().Set(rc.configuration.UserIDHeader, userInfo.Email)
w.WriteHeader(http.StatusOK)
Expand Down

0 comments on commit 2a6889c

Please sign in to comment.