-
Notifications
You must be signed in to change notification settings - Fork 287
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'trunk' into feature/stripe-sca
- Loading branch information
Showing
36 changed files
with
4,575 additions
and
3,030 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
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,10 +1,21 @@ | ||
CANONICAL_URL=http://localhost:4000 | ||
ENABLE_SPA_ROUTING=true | ||
BUILD_GRAPHQL_URL=http://localhost:3000/graphql | ||
EXTERNAL_GRAPHQL_URL=http://localhost:3000/graphql | ||
INTERNAL_GRAPHQL_URL=http://api.reaction.localhost:3000/graphql | ||
OAUTH2_ADMIN_PORT=4445 | ||
OAUTH2_ADMIN_URL=http://hydra.reaction.localhost:4445 | ||
OAUTH2_AUTH_URL=http://localhost:4444/oauth2/auth | ||
OAUTH2_CLIENT_ID=example-storefront | ||
OAUTH2_CLIENT_SECRET=CHANGEME | ||
OAUTH2_PUBLIC_LOGOUT_URL=http://localhost:4444/oauth2/sessions/logout | ||
OAUTH2_HOST=hydra.reaction.localhost | ||
OAUTH2_IDP_PUBLIC_CHANGE_PASSWORD_URL=http://localhost:4100/account/change-password?email=EMAIL&from=FROM | ||
OAUTH2_IDP_HOST_URL=http://identity.reaction.localhost:4100 | ||
OAUTH2_TOKEN_URL=http://hydra.reaction.localhost:4444/oauth2/token | ||
PORT=4000 | ||
SEGMENT_ANALYTICS_SKIP_MINIMIZE=true | ||
SEGMENT_ANALYTICS_WRITE_KEY=ENTER_KEY_HERE | ||
SESSION_MAX_AGE_MS=2592000000 | ||
SESSION_SECRET=CHANGEME | ||
STRIPE_PUBLIC_API_KEY=ENTER_STRIPE_PUBLIC_KEY_HERE | ||
STRIPE_PUBLIC_API_KEY=ENTER_STRIPE_PUBLIC_KEY_HERE |
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,10 +1,21 @@ | ||
CANONICAL_URL=http://localhost:4000 | ||
ENABLE_SPA_ROUTING=true | ||
BUILD_GRAPHQL_URL=http://localhost:3000/graphql | ||
EXTERNAL_GRAPHQL_URL=http://localhost:3000/graphql | ||
INTERNAL_GRAPHQL_URL=http://api.reaction.localhost:3000/graphql | ||
OAUTH2_ADMIN_PORT=4445 | ||
OAUTH2_ADMIN_URL=http://hydra.reaction.localhost:4445 | ||
OAUTH2_AUTH_URL=http://localhost:4444/oauth2/auth | ||
OAUTH2_CLIENT_ID=example-storefront | ||
OAUTH2_CLIENT_SECRET=CHANGEME | ||
OAUTH2_PUBLIC_LOGOUT_URL=http://localhost:4444/oauth2/sessions/logout | ||
OAUTH2_HOST=hydra.reaction.localhost | ||
OAUTH2_IDP_PUBLIC_CHANGE_PASSWORD_URL=http://localhost:4100/account/change-password?email=EMAIL&from=FROM | ||
OAUTH2_IDP_HOST_URL=http://identity.reaction.localhost:4100 | ||
OAUTH2_TOKEN_URL=http://hydra.reaction.localhost:4444/oauth2/token | ||
PORT=4000 | ||
SEGMENT_ANALYTICS_SKIP_MINIMIZE=true | ||
SEGMENT_ANALYTICS_WRITE_KEY=ENTER_KEY_HERE | ||
SESSION_MAX_AGE_MS=2592000000 | ||
SESSION_SECRET=CHANGEME | ||
STRIPE_PUBLIC_API_KEY=ENTER_STRIPE_PUBLIC_KEY_HERE | ||
STRIPE_PUBLIC_API_KEY=ENTER_STRIPE_PUBLIC_KEY_HERE |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import OAuth2Strategy from "passport-oauth2"; | ||
import passport from "passport"; | ||
import sessions from "client-sessions"; | ||
import appConfig from "../config.js"; | ||
import redirect from "./redirect"; | ||
|
||
export { default as passport } from "passport"; | ||
|
||
let baseUrl = appConfig.CANONICAL_URL; | ||
if (!baseUrl.endsWith("/")) baseUrl = `${baseUrl}/`; | ||
|
||
const oauthRedirectUrl = `${baseUrl}callback`; | ||
|
||
// This is needed to allow custom parameters (e.g. loginActions) to be included | ||
// when requesting authorization. This is setup to allow only loginAction to pass through | ||
OAuth2Strategy.prototype.authorizationParams = function (options = {}) { | ||
return { loginAction: options.loginAction }; | ||
}; | ||
|
||
passport.use("oauth2", new OAuth2Strategy({ | ||
authorizationURL: appConfig.OAUTH2_AUTH_URL, | ||
tokenURL: appConfig.OAUTH2_TOKEN_URL, | ||
clientID: appConfig.OAUTH2_CLIENT_ID, | ||
clientSecret: appConfig.OAUTH2_CLIENT_SECRET, | ||
callbackURL: oauthRedirectUrl, | ||
state: true, | ||
scope: ["offline", "openid"] | ||
}, (accessToken, refreshToken, params, profile, cb) => { | ||
cb(null, { accessToken, refreshToken, idToken: params.id_token }); | ||
})); | ||
|
||
passport.serializeUser((user, done) => { | ||
done(null, JSON.stringify(user)); | ||
}); | ||
|
||
passport.deserializeUser((user, done) => { | ||
done(null, JSON.parse(user)); | ||
}); | ||
|
||
export default (handler) => (req, res) => { | ||
if (!res.redirect) { | ||
res.redirect = (location) => redirect(res, 302, location); | ||
} | ||
|
||
sessions({ | ||
cookieName: "session", // This name is required so passport picks it up correctly | ||
secret: appConfig.SESSION_SECRET, | ||
duration: appConfig.SESSION_MAX_AGE_MS | ||
})(req, res, () => | ||
passport.initialize()(req, res, () => | ||
passport.session()(req, res, () => | ||
handler(req, res)))); | ||
}; |
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
Oops, something went wrong.