Skip to content

Allow environment variables to configure cookie scheme#62

Merged
jaw187 merged 6 commits intohapijs:masterfrom
hofan41:master
Apr 20, 2015
Merged

Allow environment variables to configure cookie scheme#62
jaw187 merged 6 commits intohapijs:masterfrom
hofan41:master

Conversation

@hofan41
Copy link
Copy Markdown
Contributor

@hofan41 hofan41 commented Apr 14, 2015

Closes #61

hofan41 added 3 commits April 14, 2015 15:32
Updated hapi-auth-cookie to use Joi for input validation.
It will also use the Joi transformed result object for options so that
booleans and integers can be passed in as strings but interpreted as the
appropriate type.
Also added unit tests to ensure original functionality of the removed
asserts.
@hofan41 hofan41 changed the title Issue #61 - Allow environment variables to configure cookie scheme Allow environment variables to configure cookie scheme Apr 14, 2015
lib/index.js Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Domain should remain optional

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It is already optional, settings.domain will be set to undefined if the user did not provide a domain. This undefined value will be passed on to server.state() and it will behave as if it were not provided at all. I dug through the server.state() code and found the Joi schema :

hapi/node_modules/statehood/lib/index.js

    domain: Joi.string().allow(null),
    ttl: Joi.number().allow(null),

If you really want to, I can specify null to be the default value for ttl and domain, but it doesn't really change anything functionally as far as I can tell. Please advise.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Without doing any through testing, I figured it'd be more straight forward to maintain the original concepts used to create cookieOptions. You may be right, but I figured your enhancement could be accomplished with less changes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed, this could definitely be accomplished without introducing Joi and just adding a few more if-statements. I thought adding Joi input validation would make this plugin more similar/conventional to other hapi core plugins that I have examined.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You can leave the Joi validation. Keep the setting of cookieOptions.ttl as well as cookieOptions.domain the same and remove their respective default values from the schema.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok, done :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd still like to maintain the same process for adding ttl and domain to the cookieOptions object.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure thing, I have just submitted a new commit.

@jaw187 jaw187 added the feature New functionality or improvement label Apr 16, 2015
jaw187 added a commit that referenced this pull request Apr 20, 2015
Allow environment variables to configure cookie scheme
@jaw187 jaw187 merged commit 299ba05 into hapijs:master Apr 20, 2015
@hueniverse
Copy link
Copy Markdown
Contributor

Issue and PR both missing milestone info. Also need to assign to someone.

@jaw187 jaw187 added this to the 2.1.0 milestone Apr 22, 2015
@lock
Copy link
Copy Markdown

lock bot commented Jan 9, 2020

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

feature New functionality or improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to use environment variables to configure some scheme options

3 participants