Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added cookie security #44

Merged
merged 6 commits into from
Jan 31, 2018
Merged

added cookie security #44

merged 6 commits into from
Jan 31, 2018

Conversation

bhoriuchi
Copy link
Contributor

Issue #38

@slnode
Copy link

slnode commented Nov 22, 2016

Can one of the admins verify this patch?

@slnode
Copy link

slnode commented Nov 22, 2016

Can one of the admins verify this patch? To accept patch and trigger a build add comment ".ok\W+to\W+test."

objects would not have been parsed
handle the case where the header for set-cookie is a string and not an array
@ritch
Copy link

ritch commented Nov 29, 2016

@slnode ok to test

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
constructor(cookie, options) {
super(options);

cookie = _.get(cookie, 'set-cookie', cookie)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing semi-colon

super(options);

cookie = _.get(cookie, 'set-cookie', cookie)
var cookies = _.map(_.isArray(cookie) ? cookie : [cookie], function (c) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like this would be better I think. Less dependency on lodash

this.cookie = (Array.isArray(cookie) ? cookie : [cookie])
  .map(c => c.split(';')[0])
  .join('; ');


describe('CookieSecurity', function() {
var CookieSecurity = require('../../').CookieSecurity;
var cookie = "cookie-value";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

single quotes

var instance2 = new CookieSecurity(headers);

it('is accepted with cookie string', function () {
instance1.should.have.property("cookie", cookie);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

single quotes


describe('defaultOption param', function() {
it('is accepted as the second param', function() {
new CookieSecurity(cookie, {});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks like it is missing the test part.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just copied and modified the existing BearerSecurity test. I'm not sure what is missing since nether bearer or cookie security tests look any different.

var defaultOptions = { foo: 2 };
var instance = new CookieSecurity(cookie, defaultOptions);
instance.addOptions(options);
options.should.have.property("foo", 2);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

single quote

changed double to single quotes in tests
Copy link

@eddiemonge eddiemonge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that was fast!

var Security = require('./security');

function hasCookieHeader (cookie) {
return typeof cookie === 'object' && cookie.hasOwnProperty('set-cookie')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing semi-colon

constructor(cookie, options) {
super(options);

cookie = hasCookieHeader(cookie) ? cookie['set-cookie'] : cookie

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing semi-colon

@raymondfeng
Copy link
Contributor

@bhoriuchi Please sign the CLA.

@slnode
Copy link

slnode commented Jan 2, 2018

Can one of the admins verify this patch?

@bhoriuchi
Copy link
Contributor Author

Signed

@raymondfeng raymondfeng merged commit 8c8ba62 into loopbackio:master Jan 31, 2018
@dhmlau dhmlau mentioned this pull request Apr 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants