Skip to content

Commit fd754c2

Browse files
committed
fix(package): store cookies securely when using https
1 parent abdec8e commit fd754c2

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/AspnetAuth.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,13 @@ class AspnetAuth {
104104
}
105105

106106
saveAuth(result) {
107+
let secure = false;
108+
// save secure cookies for https requests
109+
if (window.location.protocol === 'https:') {
110+
secure = true;
111+
}
107112
cookies.set(this.cookieName, stringify(result), {
108-
secure: true,
113+
secure,
109114
});
110115
}
111116

test/aspnet-authSpec.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ sinonStubPromise(sinon);
2121

2222
describe('AspnetAuth', () => {
2323
let aspnetAuth;
24-
24+
global.window = {
25+
location: {
26+
protocol: 'http:',
27+
},
28+
};
2529
beforeEach(() => {
2630
sinon.stub(cookies, 'get').returns(null);
2731
sinon.stub(cookies, 'set');

0 commit comments

Comments
 (0)