Skip to content

Commit

Permalink
Merge branch 'master' into patch-2
Browse files Browse the repository at this point in the history
  • Loading branch information
BobrImperator authored Dec 23, 2024
2 parents c942566 + f751300 commit a963784
Show file tree
Hide file tree
Showing 9 changed files with 275 additions and 180 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
"@babel/preset-env": "7.26.0",
"@eslint/eslintrc": "3.1.0",
"@eslint/js": "9.14.0",
"@mermaid-js/mermaid-cli": "11.3.0",
"@mermaid-js/mermaid-cli": "11.4.0",
"@release-it-plugins/lerna-changelog": "7.0.0",
"eslint-config-simplabs": "0.4.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-ember": "12.3.1",
"eslint-plugin-n": "17.12.0",
"eslint-plugin-n": "17.13.1",
"eslint-plugin-prettier": "5.2.1",
"eslint-plugin-qunit": "8.1.2",
"globals": "15.11.0",
"globals": "15.12.0",
"lerna-changelog": "2.2.0",
"release-it": "17.10.0",
"release-plan": "0.10.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/classic-test-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"bootstrap": "5.3.3",
"broccoli-asset-rev": "3.0.0",
"cors": "2.8.5",
"ember-auto-import": "2.9.0",
"ember-auto-import": "2.10.0",
"ember-cli": "5.12.0",
"ember-cli-babel": "8.2.0",
"ember-cli-content-security-policy": "1.1.1",
Expand All @@ -51,7 +51,7 @@
"eslint": "8.57.1",
"express": "4.21.1",
"glob": "11.0.0",
"globals": "15.11.0",
"globals": "15.12.0",
"handlebars": "4.7.8",
"loader.js": "4.7.0",
"my-engine": "workspace:../classic-test-app/lib/my-engine",
Expand Down
6 changes: 3 additions & 3 deletions packages/ember-simple-auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@embroider/addon-shim": "^1.0.0",
"@embroider/macros": "^1.0.0",
"ember-cli-is-package-missing": "^1.0.0",
"ember-cookies": "^1.0.0",
"ember-cookies": "^1.2.0",
"silent-error": "^1.0.0"
},
"devDependencies": {
Expand All @@ -44,11 +44,11 @@
"@embroider/addon-dev": "5.0.0",
"@rollup/plugin-babel": "6.0.4",
"@rollup/plugin-node-resolve": "15.3.0",
"concurrently": "9.0.1",
"concurrently": "9.1.0",
"ember-template-lint": "6.0.0",
"eslint": "8.57.1",
"prettier": "3.3.3",
"rollup": "4.24.3",
"rollup": "4.25.0",
"rollup-plugin-copy": "3.5.0"
},
"publishConfig": {
Expand Down
21 changes: 20 additions & 1 deletion packages/ember-simple-auth/src/session-stores/adaptive.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,24 @@ export default Base.extend({
_sameSite: null,
sameSite: proxyToInternalStore(),

/**
Allows servers to assert that a cookie should opt in to partitioned storage,
i.e. use a separate cookie per top level site if the cookie is used in a
third party context
Available options:
- null
- true
@memberof AdaptiveStore
@property partitioned
@type Boolean
@default null
@public
*/
_partitioned: null,
partitioned: proxyToInternalStore(),

/**
The name of the cookie to use if `localStorage` is not available.
Expand Down Expand Up @@ -158,7 +176,8 @@ export default Base.extend({
'cookieName',
'cookieExpirationTime',
'cookiePath',
'sameSite'
'sameSite',
'partitioned'
);

cookieStorage.setProperties(options);
Expand Down
19 changes: 19 additions & 0 deletions packages/ember-simple-auth/src/session-stores/cookie.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,24 @@ export default BaseStore.extend({
}
}),

/**
Allows servers to assert that a cookie should opt in to partitioned storage,
i.e. use a separate cookie per top level site if the cookie is used in a
third party context
Available options:
- null
- true
@memberof CookieStore
@property partitioned
@type Boolean
@default null
@public
*/
_partitioned: null,
partitioned: persistingProperty(),

_cookies: service('cookies'),

_secureCookies() {
Expand Down Expand Up @@ -272,6 +290,7 @@ export default BaseStore.extend({
path: this.get('cookiePath'),
secure: this._secureCookies(),
sameSite: this.get('sameSite'),
partitioned: this.get('partitioned'),
};
if (this._oldCookieName) {
A([this._oldCookieName, `${this._oldCookieName}-expiration_time`]).forEach(oldCookie => {
Expand Down
2 changes: 1 addition & 1 deletion packages/test-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"bootstrap": "5.3.3",
"broccoli-asset-rev": "3.0.0",
"cors": "2.8.5",
"ember-auto-import": "2.9.0",
"ember-auto-import": "2.10.0",
"ember-cli": "5.12.0",
"ember-cli-babel": "8.2.0",
"ember-cli-content-security-policy": "1.1.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/test-esa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"bootstrap": "5.3.3",
"broccoli-asset-rev": "3.0.0",
"cors": "2.8.5",
"ember-auto-import": "2.9.0",
"ember-auto-import": "2.10.0",
"ember-cli": "5.12.0",
"ember-cli-babel": "8.2.0",
"ember-cli-content-security-policy": "1.1.1",
Expand All @@ -51,7 +51,7 @@
"ember-maybe-import-regenerator": "1.0.0",
"ember-qunit": "7.0.0",
"ember-resolver": "11.0.1",
"ember-simple-auth": "6.1.0",
"ember-simple-auth": "workspace:*",
"ember-source": "5.12.0",
"ember-source-channel-url": "3.0.0",
"ember-try": "3.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,14 @@ export default function (options) {
let cookieService = store.get('_cookies');
await store.persist({ key: 'value' });

assert.ok(
assert.true(
cookieService.write.calledWith('test:session', JSON.stringify({ key: 'value' }), {
domain: null,
expires: null,
path: '/',
sameSite: null,
secure: false,
partitioned: null,
})
);
});
Expand All @@ -65,13 +66,14 @@ export default function (options) {
});
await store.persist({ key: 'value' });

assert.ok(
assert.true(
cookieService.write.calledWith('session-cookie-domain', JSON.stringify({ key: 'value' }), {
domain: 'example.com',
expires: null,
path: '/',
sameSite: null,
secure: false,
partitioned: null,
})
);
});
Expand All @@ -85,13 +87,14 @@ export default function (options) {
let cookieService = store.get('_cookies');
await store.persist({ key: 'value' });

assert.ok(
assert.true(
cookieService.write.calledWith('session-cookie-domain', JSON.stringify({ key: 'value' }), {
domain: 'example.com',
expires: null,
path: '/hello-world',
sameSite: null,
secure: false,
partitioned: null,
})
);
});
Expand All @@ -104,17 +107,42 @@ export default function (options) {
});
let cookieService = store.get('_cookies');
await store.persist({ key: 'value' });
assert.ok(
assert.true(
cookieService.write.calledWith('session-cookie-domain', JSON.stringify({ key: 'value' }), {
domain: 'example.com',
expires: null,
path: '/',
sameSite: 'Strict',
secure: false,
partitioned: null,
})
);
});

test('respects the configured partitioned', async function (assert) {
run(() => {
store.set('cookieName', 'session-cookie-partitioned');
store.set('cookieDomain', 'example.com');
store.set('partitioned', true);
});
let cookieService = store.get('_cookies');
await store.persist({ key: 'value' });
assert.true(
cookieService.write.calledWith(
'session-cookie-partitioned',
JSON.stringify({ key: 'value' }),
{
domain: 'example.com',
expires: null,
path: '/',
sameSite: null,
secure: false,
partitioned: true,
}
)
);
});

test('sends a warning when `cookieExpirationTime` is less than 90 seconds', async function (assert) {
assert.expect(2);
run(() => {
Expand Down Expand Up @@ -155,7 +183,7 @@ export default function (options) {
});

test('stores the expiration time in a cookie named "test-session-expiration_time"', function (assert) {
assert.ok(
assert.true(
cookieService.write.calledWith(
'test-session-expiration_time',
60,
Expand Down Expand Up @@ -212,7 +240,7 @@ export default function (options) {
await new Promise(resolve => {
next(() => {
next(() => {
assert.ok(triggered);
assert.true(triggered);
resolve();
});
});
Expand Down Expand Up @@ -264,11 +292,11 @@ export default function (options) {
});
await store.persist({ key: 'value' });

assert.ok(cookieService.clear.calledWith('session-foo'));
assert.true(cookieService.clear.calledWith('session-foo'));

assert.ok(cookieService.clear.calledWith('session-foo-expiration_time'));
assert.true(cookieService.clear.calledWith('session-foo-expiration_time'));

assert.ok(
assert.true(
cookieService.write.calledWith(
'session-bar',
JSON.stringify({ key: 'value' }),
Expand All @@ -283,7 +311,7 @@ export default function (options) {
)
);

assert.ok(
assert.true(
cookieService.write.calledWith(
'session-bar-expiration_time',
1000,
Expand All @@ -307,11 +335,11 @@ export default function (options) {
});
await store.persist({ key: 'value' });

assert.ok(cookieService.clear.calledWith(defaultName));
assert.true(cookieService.clear.calledWith(defaultName));

assert.ok(cookieService.clear.calledWith(`${defaultName}-expiration_time`));
assert.true(cookieService.clear.calledWith(`${defaultName}-expiration_time`));

assert.ok(
assert.true(
cookieService.write.calledWith(
'session-bar',
JSON.stringify({ key: 'value' }),
Expand All @@ -336,11 +364,11 @@ export default function (options) {
});
await store.persist({ key: 'value' });

assert.ok(cookieService.clear.calledWith(defaultName));
assert.true(cookieService.clear.calledWith(defaultName));

assert.ok(cookieService.clear.calledWith(`${defaultName}-expiration_time`));
assert.true(cookieService.clear.calledWith(`${defaultName}-expiration_time`));

assert.ok(
assert.true(
cookieService.write.calledWith(
'session-bar',
JSON.stringify({ key: 'value' }),
Expand All @@ -364,7 +392,7 @@ export default function (options) {

await new Promise(resolve => {
next(() => {
assert.ok(cookieService.clear.calledWith('session-foo-expiration_time'));
assert.true(cookieService.clear.calledWith('session-foo-expiration_time'));
resolve();
});
});
Expand All @@ -379,7 +407,7 @@ export default function (options) {

await new Promise(resolve => {
next(() => {
assert.ok(cookieSpy.calledOnce);
assert.true(cookieSpy.calledOnce);
resolve();
});
});
Expand Down
Loading

0 comments on commit a963784

Please sign in to comment.