Skip to content

Commit

Permalink
fix(package): store cookies securely when using https
Browse files Browse the repository at this point in the history
  • Loading branch information
Halceyon committed Mar 7, 2018
1 parent abdec8e commit fd754c2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/AspnetAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,13 @@ class AspnetAuth {
}

saveAuth(result) {
let secure = false;
// save secure cookies for https requests
if (window.location.protocol === 'https:') {
secure = true;
}
cookies.set(this.cookieName, stringify(result), {
secure: true,
secure,
});
}

Expand Down
6 changes: 5 additions & 1 deletion test/aspnet-authSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ sinonStubPromise(sinon);

describe('AspnetAuth', () => {
let aspnetAuth;

global.window = {
location: {
protocol: 'http:',
},
};
beforeEach(() => {
sinon.stub(cookies, 'get').returns(null);
sinon.stub(cookies, 'set');
Expand Down

0 comments on commit fd754c2

Please sign in to comment.