Skip to content

Commit

Permalink
fix: use sameSite: none for iframe compatibility (#334)
Browse files Browse the repository at this point in the history
  • Loading branch information
aarongranick-okta authored Feb 27, 2020
1 parent 9375193 commit d651361
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 35 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 2.13.1

### Bug Fixes

- [#334](https://github.com/okta/okta-auth-js/pull/334) - Setting 'SameSite=none' for all cookies (Fix for iFrame)

## 2.13.0

### Features
Expand Down
2 changes: 1 addition & 1 deletion packages/okta-auth-js/lib/browser/browserStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ storageUtil.getSessionStorage = function() {
storageUtil.getCookieStorage = function(options) {
options = options || {};
var secure = options.secure; // currently opt-in
var sameSite = options.sameSite || 'lax';
var sameSite = options.sameSite || 'none';
return {
getItem: storageUtil.storage.get,
setItem: function(key, value) {
Expand Down
6 changes: 3 additions & 3 deletions packages/okta-auth-js/lib/token.js
Original file line number Diff line number Diff line change
Expand Up @@ -644,17 +644,17 @@ function getWithRedirect(sdk, oauthOptions, options) {
urls: urls,
ignoreSignature: oauthParams.ignoreSignature
}), null, {
sameSite: 'lax'
sameSite: 'none'
});

// Set nonce cookie for servers to validate nonce in id_token
cookies.set(constants.REDIRECT_NONCE_COOKIE_NAME, oauthParams.nonce, null, {
sameSite: 'lax'
sameSite: 'none'
});

// Set state cookie for servers to validate state
cookies.set(constants.REDIRECT_STATE_COOKIE_NAME, oauthParams.state, null, {
sameSite: 'lax'
sameSite: 'none'
});

sdk.token.getWithRedirect._setLocation(requestUrl);
Expand Down
2 changes: 1 addition & 1 deletion packages/okta-auth-js/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@okta/okta-auth-js",
"description": "The Okta Auth SDK",
"version": "2.13.0",
"version": "2.13.1",
"homepage": "https://github.com/okta/okta-auth-js",
"license": "Apache-2.0",
"main": "lib/server/serverIndex.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/okta-auth-js/test/spec/cookies.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ describe('cookie', function () {

it('proxies JsCookie.set with "sameSite" setting', function () {
Cookies.set('foo', 'bar', null, {
sameSite: 'lax'
sameSite: 'none'
});
expect(JsCookie.set).toHaveBeenCalledWith('foo', 'bar', {
path: '/',
sameSite: 'lax'
sameSite: 'none'
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/okta-auth-js/test/spec/oauthUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ describe('getWellKnown', function() {
}),
'2200-01-01T00:00:00.000Z',
{
sameSite: 'lax'
sameSite: 'none'
}
);
}
Expand Down
42 changes: 21 additions & 21 deletions packages/okta-auth-js/test/spec/token.js
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,7 @@ describe('token.getWithRedirect', function() {
oauthUtil.mockedNonce,
null, // expiresAt
{
sameSite: 'lax'
sameSite: 'none'
}
];

Expand All @@ -1205,7 +1205,7 @@ describe('token.getWithRedirect', function() {
oauthUtil.mockedState,
null, // expiresAt
{
sameSite: 'lax'
sameSite: 'none'
}
];
});
Expand Down Expand Up @@ -1237,7 +1237,7 @@ describe('token.getWithRedirect', function() {
ignoreSignature: false
}),
null, {
sameSite: 'lax'
sameSite: 'none'
}
],
nonceCookie,
Expand Down Expand Up @@ -1276,7 +1276,7 @@ describe('token.getWithRedirect', function() {
ignoreSignature: false
}),
null, {
sameSite: 'lax'
sameSite: 'none'
}
],
nonceCookie,
Expand Down Expand Up @@ -1311,7 +1311,7 @@ describe('token.getWithRedirect', function() {
ignoreSignature: false
}),
null, {
sameSite: 'lax'
sameSite: 'none'
}
],
nonceCookie,
Expand Down Expand Up @@ -1352,7 +1352,7 @@ describe('token.getWithRedirect', function() {
ignoreSignature: false
}),
null, {
sameSite: 'lax'
sameSite: 'none'
}
],
nonceCookie,
Expand Down Expand Up @@ -1397,7 +1397,7 @@ describe('token.getWithRedirect', function() {
ignoreSignature: false
}),
null, {
sameSite: 'lax'
sameSite: 'none'
}
],
nonceCookie,
Expand Down Expand Up @@ -1435,7 +1435,7 @@ describe('token.getWithRedirect', function() {
ignoreSignature: false
}),
null, {
sameSite: 'lax'
sameSite: 'none'
}
],
nonceCookie,
Expand Down Expand Up @@ -1478,7 +1478,7 @@ describe('token.getWithRedirect', function() {
ignoreSignature: false
}),
null, {
sameSite: 'lax'
sameSite: 'none'
}
],
nonceCookie,
Expand Down Expand Up @@ -1515,7 +1515,7 @@ describe('token.getWithRedirect', function() {
ignoreSignature: false
}),
null, {
sameSite: 'lax'
sameSite: 'none'
}
],
nonceCookie,
Expand Down Expand Up @@ -1557,7 +1557,7 @@ describe('token.getWithRedirect', function() {
ignoreSignature: false
}),
null, {
sameSite: 'lax'
sameSite: 'none'
}
],
nonceCookie,
Expand Down Expand Up @@ -1594,7 +1594,7 @@ describe('token.getWithRedirect', function() {
ignoreSignature: false
}),
null, {
sameSite: 'lax'
sameSite: 'none'
}
],
nonceCookie,
Expand Down Expand Up @@ -1635,7 +1635,7 @@ describe('token.getWithRedirect', function() {
ignoreSignature: false
}),
null, {
sameSite: 'lax'
sameSite: 'none'
}
],
nonceCookie,
Expand Down Expand Up @@ -1678,7 +1678,7 @@ describe('token.getWithRedirect', function() {
ignoreSignature: false
}),
null, {
sameSite: 'lax'
sameSite: 'none'
}
],
nonceCookie,
Expand Down Expand Up @@ -1723,7 +1723,7 @@ null, {
ignoreSignature: false
}),
null, {
sameSite: 'lax'
sameSite: 'none'
}
],
nonceCookie,
Expand Down Expand Up @@ -1761,7 +1761,7 @@ null, {
ignoreSignature: false
}),
null, {
sameSite: 'lax'
sameSite: 'none'
}
],
nonceCookie,
Expand Down Expand Up @@ -1803,7 +1803,7 @@ null, {
ignoreSignature: false
}),
null, {
sameSite: 'lax'
sameSite: 'none'
}
],
nonceCookie,
Expand Down Expand Up @@ -1843,7 +1843,7 @@ null, {
ignoreSignature: false
}),
null, {
sameSite: 'lax'
sameSite: 'none'
}
],
nonceCookie,
Expand Down Expand Up @@ -1879,7 +1879,7 @@ null, {
ignoreSignature: false
}),
null, {
sameSite: 'lax'
sameSite: 'none'
}
],
nonceCookie,
Expand Down Expand Up @@ -1915,7 +1915,7 @@ null, {
ignoreSignature: false
}),
null, {
sameSite: 'lax'
sameSite: 'none'
}
],
nonceCookie,
Expand Down Expand Up @@ -1951,7 +1951,7 @@ null, {
ignoreSignature: false
}),
null, {
sameSite: 'lax'
sameSite: 'none'
}
],
nonceCookie,
Expand Down
12 changes: 6 additions & 6 deletions packages/okta-auth-js/test/spec/tokenManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ describe('TokenManager', function() {
'okta-token-storage',
JSON.stringify({'test-idToken': tokens.standardIdTokenParsed}),
'2200-01-01T00:00:00.000Z', {
sameSite: 'lax'
sameSite: 'none'
}
);
});
Expand All @@ -221,7 +221,7 @@ describe('TokenManager', function() {
'okta-token-storage',
JSON.stringify({'test-idToken': tokens.standardIdTokenParsed}),
'2200-01-01T00:00:00.000Z', {
sameSite: 'lax'
sameSite: 'none'
}
);
});
Expand Down Expand Up @@ -1242,7 +1242,7 @@ describe('TokenManager', function() {
'okta-token-storage',
JSON.stringify({'test-idToken': tokens.standardIdTokenParsed}),
'2200-01-01T00:00:00.000Z', {
sameSite: 'lax'
sameSite: 'none'
}
);
});
Expand All @@ -1256,7 +1256,7 @@ describe('TokenManager', function() {
JSON.stringify({'test-idToken': tokens.standardIdTokenParsed}),
'2200-01-01T00:00:00.000Z', {
secure: true,
sameSite: 'lax'
sameSite: 'none'
}
);
});
Expand Down Expand Up @@ -1295,7 +1295,7 @@ describe('TokenManager', function() {
'okta-token-storage',
JSON.stringify({anotherKey: tokens.standardIdTokenParsed}),
'2200-01-01T00:00:00.000Z', {
sameSite: 'lax'
sameSite: 'none'
}
);
});
Expand All @@ -1312,7 +1312,7 @@ describe('TokenManager', function() {
'okta-token-storage',
'{}',
'2200-01-01T00:00:00.000Z', {
sameSite: 'lax'
sameSite: 'none'
}
);
});
Expand Down

0 comments on commit d651361

Please sign in to comment.