-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
89 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,28 @@ | ||
const express = require('express'); | ||
const createProxyMiddleware = require('./proxyMiddleware'); | ||
|
||
// Proxy should use different (from your SPA) port or domain to have different local/session storage. | ||
// SIW initially clears transaction storage, so state saved in SPA could not be readen on login callback | ||
// and `handleRedirect` would produce the error: | ||
// AuthSdkError: Could not load PKCE codeVerifier from storage. | ||
// This may indicate the auth flow has already completed or multiple auth flows are executing concurrently. | ||
// | ||
// Okta org setup: | ||
// - Proxy URL should be added to Trusted Origins. | ||
// - `<proxy>/login/callback` should be added to Redirect URIs of app with CLIENT_ID | ||
|
||
module.exports = function createProxyApp({ proxyPort }) { | ||
// Proxy should use another port or domain to have different local/session storage. | ||
// SIW initially clears transaction storage, so state could not be readen on login callback. | ||
// AuthSdkError: Could not load PKCE codeVerifier from storage. This may indicate the auth flow has already completed or multiple auth flows are executing concurrently. | ||
const proxyApp = express(); | ||
const { origin } = new URL(process.env.ISSUER); | ||
const proxyMiddleware = createProxyMiddleware({ | ||
origin, | ||
proxyPort | ||
}); | ||
proxyApp.use('/api', proxyMiddleware); // /api/v1/sessions/me | ||
proxyApp.use('/oauth2', proxyMiddleware); // /oauth2/v1 | ||
proxyApp.use('/idp/idx', proxyMiddleware); | ||
proxyApp.use('/login/token/redirect', proxyMiddleware); | ||
proxyApp.use('/app', proxyMiddleware); | ||
proxyApp.use('/.well-known', proxyMiddleware); | ||
return proxyApp; | ||
const proxyApp = express(); | ||
const { origin } = new URL(process.env.ISSUER); | ||
const proxyMiddleware = createProxyMiddleware({ | ||
origin, | ||
proxyPort | ||
}); | ||
proxyApp.use('/api', proxyMiddleware); // /api/v1/sessions/me | ||
proxyApp.use('/oauth2', proxyMiddleware); // /oauth2/v1 | ||
proxyApp.use('/idp/idx', proxyMiddleware); | ||
proxyApp.use('/login/token/redirect', proxyMiddleware); | ||
proxyApp.use('/app', proxyMiddleware); | ||
proxyApp.use('/.well-known', proxyMiddleware); | ||
return proxyApp; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters