Skip to content
This repository has been archived by the owner on Jan 26, 2025. It is now read-only.

Middleware okta logout #379

Merged
merged 3 commits into from
Jan 31, 2019
Merged

Middleware okta logout #379

merged 3 commits into from
Jan 31, 2019

Conversation

swiftone
Copy link
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Adding Tests
  • Build related changes
  • CI related changes
  • Documentation changes
  • Other... Please describe:

What is the current behavior?

/logout is GET-based and only destroys the local session

Issue Number: #162

What is the new behavior?

/logout is POST-based and performs an Okta logout and revokes related tokens.

Does this PR introduce a breaking change?

  • Yes
  • No

See 'Upgrading' in README

Other information

Reviewers

@manueltanzi-okta @vijetmahabaleshwar-okta

Copy link
Contributor

@manueltanzi-okta manueltanzi-okta left a comment

Choose a reason for hiding this comment

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

Few small things, overall looks good!


Optional config:

* **loginRedirectUri** - The URI for your app that Okta will redirect users to after sign in to create the local session. Locally, this is usually `http://localhost:3000/authorization-code/callback`. When deployed, this should be `https://{yourProductionDomain}/authorization-code/callback`. This will default to `{baseUrl}{routes.loginCallback.path}` if `appBaseUrl` is provided, or the (deprecated) `redirect_uri` if appBaseUrl is not provided. Unless your redirect is to a different application, it is recommended to NOT set this parameter and instead set `appBaseUrl` and (if different than the default of `/authorization-code/callback`) `routes.loginCallback.path`.
* **loginRedirectUri** - The URI for your app that Okta will redirect users to after sign in to create the local session. Locally, this is usually `http://localhost:3000/authorization-code/callback`. When deployed, this should be `https://{yourProductionDomain}/authorization-code/callback`. This will default to `{appBaseUrl}{routes.loginCallback.path}` if `appBaseUrl` is provided, or the (deprecated) `redirect_uri` if appBaseUrl is not provided. Unless your redirect is to a different application, it is recommended to NOT set this parameter and instead set `appBaseUrl` and (if different than the default of `/authorization-code/callback`) `routes.loginCallback.path`.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: *appBaseUrl is not provided. (missing `` around appBaseUrl)

@@ -291,6 +318,9 @@ const oidc = new ExpressOIDC({
* **`loginCallback.handler`** - A function that is called after a successful authentication callback, but before the final redirect within your application. Useful for requirements such as conditional post-authentication redirects, or sending data to logging systems.
* **`loginCallback.path`** - The URI that this library will host the login callback handler on. Defaults to `/authorization-code/callback`. Must match a value from the Login Redirect Uri list from the Okta console for this application.
* **`login.path`** - The URI that redirects the user to the Okta authorize endpoint. Defaults to `/login`.
* **`logout.path`** - The RUI that redirects the user to the Okta logout endpoint. Defaults to `/logout`.
Copy link
Contributor

Choose a reason for hiding this comment

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

*URI

connectUtil.createLogoutHandler = context => logout.forceLogoutAndRevoke(context);

connectUtil.createLogoutCallbackHandler = context => {
return (req, res, next) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

What is next used for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nothing here - removed

@@ -233,7 +234,7 @@ describe('new ExpressOIDC()', () => {


it('should set the HTTP timeout to 10 seconds', () => {
new ExpressOIDC({
new ExpressOIDC({
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: no need for trailing space

async performLogout() {
const logoutButton = $('#logout');
await logoutButton.click();
await browser.wait(EC.not(EC.presenceOf(logoutButton)), 10000);
Copy link
Contributor

Choose a reason for hiding this comment

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

Wondering, how was 10000 decided? (function above use 50000)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Those are Vijet questions - the 50000 is notably large because that's the initial page load and bacon had issues with it, and most of the rest are 5000. This got bumped when we were trying to figure out a core build issue, but I believe that ended up being something else, so I'll return this to 5000.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

@manueltanzi-okta manueltanzi-okta left a comment

Choose a reason for hiding this comment

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

🚀

BREAKING CHANGE:

Configurations now require appBaseUrl.
redirect_uri is deprecated
BREAKING CHANGE: adds POST-based /logout and /logout/callback routes
that will override existing matching routes defined by the user (if
any).  See `Upgrading` in the README for more info.
@swiftone swiftone force-pushed the middleware-okta-logout branch from dd889ec to 37e5dbd Compare January 31, 2019 18:20
@swiftone swiftone merged commit a4b54f7 into master Jan 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants