Skip to content

Commit

Permalink
Merge pull request auth0-extensions#64 from auth0-extensions/issues/I…
Browse files Browse the repository at this point in the history
…UM-812-redux

[IUM-812] Samesite Cookies
  • Loading branch information
ademartini authored Jan 29, 2020
2 parents 6634715 + 7831c8e commit 81f35c0
Show file tree
Hide file tree
Showing 13 changed files with 83 additions and 62 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ server/config.json
server/config.test.json
coverage
.env
dist/*
!dist/.gitkeep
dist/*.js
dist/assets/*.css
tags
TAGS
data.json
Expand Down
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ with an existing registered with the same email address from a different provide

## Running in Development


Update the configuration file under `./server/config.json`:

```json
Expand All @@ -32,6 +31,7 @@ Update the configuration file under `./server/config.json`:
Then you can run the extension:

```bash
nvm use 8
yarn install
yarn run build
yarn run serve:dev
Expand All @@ -45,3 +45,24 @@ Then, you can run the tests running:
```bash
yarn test
```

## Release Process

Deployment is currently done using this tool: https://auth0-extensions.us8.webtask.io/extensions-deploy

First bump the version in `package.json` and in `webtask.json`

Then build the extension:

```bash
nvm use 8
yarn install
yarn run build
```

Bundle file (`auth0-account-link.extension.VERSION.js` is found in `/dist`
Asset CSS files are found in `/dist/assets`

Before continuing, if you want to quickly test backend-only changes in your production tenant, you can use the webtask editor: https://github.com/auth0-extensions/auth0-webtask-editor-opener. Copy and paste the bundle file file contents into the tab that corresponds with the existing extension to override the backend code.

Follow the instructions in the deployment tool. This tool will also automatically generate a PR in the `auth0-extensions` repo. Only after the PR is merged will the extension be available in production. Before merging the PR you can use this tool to test the upgrade: https://github.com/auth0-extensions/auth0-extension-update-tester by overriding the `extensions.json` file that is fetched by the dashboard. You will need to clone this repo: https://github.com/auth0/auth0-extensions, update `extensions.json` locally and then run `npx http-server --port 3000 --cors` to serve up the file. Then configure the extension with `http://localhost:3000/extensions.json` as the path.
11 changes: 5 additions & 6 deletions api/get_index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { decode } = require('jsonwebtoken');
const _ = require('lodash');
const config = require('../lib/config');
const findUsersByEmail = require('../lib/findUsersByEmail');
const indexTemplate = require('../templates/index');
Expand Down Expand Up @@ -31,12 +32,10 @@ module.exports = () => ({
auth: false
},
handler: (req, reply) => {
const linkingState = req.state['account-linking-admin-state'];
if (typeof linkingState !== 'undefined' && linkingState !== '') {
reply.redirect(`${config('PUBLIC_WT_URL')}/admin`).state('account-linking-admin-state', '');
return;
}

if (_.isEmpty(req.query)) {
reply.redirect(`${config('PUBLIC_WT_URL')}/admin`);
return;
}
const stylesheetHelper = stylesheet(config('NODE_ENV') === 'production');
const stylesheetTag = stylesheetHelper.tag('link');
const customCSSTag = stylesheetHelper.tag(config('CUSTOM_CSS'));
Expand Down
2 changes: 1 addition & 1 deletion build/bundle.js

Large diffs are not rendered by default.

Empty file added dist/assets/.gitkeep
Empty file.
4 changes: 2 additions & 2 deletions lib/stylesheet.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const version = require('../package.json').version;

const CDN_BASE = `https://cdn.auth0.com/extensions/auth0-account-link-extension/${version}`;
const CDN_BASE = 'https://cdn.auth0.com/extensions/auth0-account-link/assets';
const LOCAL_BASE = '/css';

const getBase = useCDN => (useCDN ? CDN_BASE : LOCAL_BASE);

const generateHelper = (useCDN = false) => {
const extension = useCDN ? 'min.css' : 'css';
const extension = useCDN ? `${version}.min.css` : 'css';
const link = (filename) => {
const name = (filename || '').trim();

Expand Down
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "auth0-account-link-extension",
"version": "2.3.4",
"version": "2.4.0",
"description": "Auth0 Account Link Extension",
"main": "index.js",
"engines": {
Expand All @@ -12,7 +12,7 @@
"test:integration": "mocha integration --recursive --timeout 50000",
"lint": "eslint .",
"serve:dev": "gulp run",
"client:build": "minify --clean public/css/link.css && minify --clean public/css/admin.css",
"client:build": "minify --clean --output dist/assets/link.$npm_package_version.min.css public/css/link.css && minify --clean --output dist/assets/admin.$npm_package_version.min.css public/css/admin.css",
"extension:build": "a0-ext build:server ./webtask.js ./dist && cp ./dist/auth0-account-link.extension.$npm_package_version.js ./build/bundle.js",
"build": "yarn run client:build && yarn run extension:build"
},
Expand All @@ -22,7 +22,7 @@
"nodeTarget": "4.2.0",
"bundleModules": true,
"externals": [
"auth0-extension-hapi-tools@1.2.2",
"auth0-extension-hapi-tools@1.3.1",
"[email protected]",
"[email protected]",
"[email protected]",
Expand All @@ -37,7 +37,7 @@
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected].0",
"@auth0/[email protected].1",
"[email protected]",
"[email protected]",
"[email protected]",
Expand Down Expand Up @@ -68,16 +68,17 @@
]
},
"dependencies": {
"@auth0/hapi": "13.5.1",
"auth0": "^2.8.0",
"auth0-extension-hapi-tools": "1.2.2",
"auth0-extension-hapi-tools": "1.3.1",
"auth0-extension-tools": "1.3.1",
"boom": "3.2.2",
"hapi": "13.5.0",
"hapi-auth-jwt2": "7.0.1",
"inert": "4.0.1",
"joi": "9.0.4",
"jsonwebtoken": "^8.1.0",
"jwks-rsa": "1.1.1",
"lodash": "^3.10.1",
"nconf": "^0.8.4",
"open": "^0.0.5",
"request": "^2.81.0",
Expand Down
1 change: 0 additions & 1 deletion public/css/admin.min.css

This file was deleted.

2 changes: 0 additions & 2 deletions public/css/link.min.css

This file was deleted.

2 changes: 1 addition & 1 deletion server/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable global-require */

const path = require('path');
const Hapi = require('hapi');
const Hapi = require('@auth0/hapi');
const Inert = require('inert');
const jwt = require('hapi-auth-jwt2');
const config = require('../lib/config');
Expand Down
2 changes: 1 addition & 1 deletion test/acceptance/failures_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('Requesting the linking route', function() {
});

it('returns a 400 with an invalid token', function() {
return server.inject({ method: 'GET', url: '/', payload: {} }).then(res => {
return server.inject({ method: 'GET', url: '/?foo=bar', payload: {} }).then(res => {
expect(res.statusCode).to.eq(400);
});
});
Expand Down
2 changes: 1 addition & 1 deletion webtask.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"title": "Auth0 Account Link",
"name": "auth0-account-link",
"version": "2.3.4",
"version": "2.4.0",
"preVersion": "2.1.1",
"author": "auth0",
"description":
Expand Down
79 changes: 41 additions & 38 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,43 @@
# yarn lockfile v1


"@auth0/[email protected]":
version "13.5.1"
resolved "https://a0us.jfrog.io/a0us/api/npm/npm/@auth0/hapi/-/hapi-13.5.1.tgz#21859f0948bc56b96300ccbfbc58b4a1b647ecc6"
integrity sha1-IYWfCUi8VrljAMy/vFi0obZH7MY=
dependencies:
"@auth0/statehood" "^4.1.1"
accept "2.x.x"
ammo "2.x.x"
boom "3.x.x"
call "3.x.x"
catbox "7.x.x"
catbox-memory "2.x.x"
cryptiles "3.x.x"
heavy "4.x.x"
hoek "4.x.x"
iron "4.x.x"
items "2.x.x"
joi "8.x.x"
kilt "2.x.x"
mimos "3.x.x"
peekaboo "2.x.x"
shot "3.x.x"
subtext "4.x.x"
topo "2.x.x"

"@auth0/statehood@^4.1.1":
version "4.1.1"
resolved "https://a0us.jfrog.io/a0us/api/npm/npm/@auth0/statehood/-/statehood-4.1.1.tgz#d1642a5146e27c0da8c3209d58237f43a1e2cba7"
integrity sha1-0WQqUUbifA2owyCdWCN/Q6Hiy6c=
dependencies:
boom "3.x.x"
cryptiles "3.x.x"
hoek "4.x.x"
iron "4.x.x"
items "2.x.x"
joi "9.x.x"

"@babel/[email protected]":
version "7.0.0-beta.44"
resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.0.0-beta.44.tgz#2a02643368de80916162be70865c97774f3adbd9"
Expand Down Expand Up @@ -965,9 +1002,10 @@ atob@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.0.tgz#ab2b150e51d7b122b9efc8d7340c06b6c41076bc"

[email protected]:
version "1.2.2"
resolved "https://registry.yarnpkg.com/auth0-extension-hapi-tools/-/auth0-extension-hapi-tools-1.2.2.tgz#188c138c1cb0039f4b87e665d82029f9ae21843a"
[email protected]:
version "1.3.1"
resolved "https://a0us.jfrog.io/a0us/api/npm/npm/auth0-extension-hapi-tools/-/auth0-extension-hapi-tools-1.3.1.tgz#28515f176dd495c90044c643e67eaae2485e30e4"
integrity sha1-KFFfF23UlckARMZD5n6q4kheMOQ=
dependencies:
auth0-extension-tools "^1.3.0"
boom "3.2.2"
Expand Down Expand Up @@ -3427,30 +3465,6 @@ [email protected]:
cookie "^0.3.1"
jsonwebtoken "^7.0.0"

[email protected]:
version "13.5.0"
resolved "https://registry.yarnpkg.com/hapi/-/hapi-13.5.0.tgz#a5ffbcac57d370c733c81b1ac074c4f13767ecb3"
dependencies:
accept "2.x.x"
ammo "2.x.x"
boom "3.x.x"
call "3.x.x"
catbox "7.x.x"
catbox-memory "2.x.x"
cryptiles "3.x.x"
heavy "4.x.x"
hoek "4.x.x"
iron "4.x.x"
items "2.x.x"
joi "8.x.x"
kilt "2.x.x"
mimos "3.x.x"
peekaboo "2.x.x"
shot "3.x.x"
statehood "4.x.x"
subtext "4.x.x"
topo "2.x.x"

har-schema@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-1.0.5.tgz#d263135f43307c02c602afc8fe95970c0151369e"
Expand Down Expand Up @@ -6805,17 +6819,6 @@ [email protected]:
version "0.0.10"
resolved "https://registry.yarnpkg.com/stack-trace/-/stack-trace-0.0.10.tgz#547c70b347e8d32b4e108ea1a2a159e5fdde19c0"

[email protected]:
version "4.1.0"
resolved "https://registry.yarnpkg.com/statehood/-/statehood-4.1.0.tgz#8a2877d13d9850aab6ce877a54b778df0f43acdb"
dependencies:
boom "3.x.x"
cryptiles "3.x.x"
hoek "4.x.x"
iron "4.x.x"
items "2.x.x"
joi "9.x.x"

static-extend@^0.1.1:
version "0.1.2"
resolved "https://registry.yarnpkg.com/static-extend/-/static-extend-0.1.2.tgz#60809c39cbff55337226fd5e0b520f341f1fb5c6"
Expand Down

0 comments on commit 81f35c0

Please sign in to comment.