Allow null to be passed for the ttl#124
Merged
jaw187 merged 1 commit intohapijs:masterfrom Aug 9, 2016
briandela:patch-1
Merged
Allow null to be passed for the ttl#124jaw187 merged 1 commit intohapijs:masterfrom briandela:patch-1
jaw187 merged 1 commit intohapijs:masterfrom
briandela:patch-1
Conversation
`null` is a valid default option for the `ttl` of the cookie but the schema isn't currently allowing it.
As an example, in our case the value for `ttl` is coming from an external place; from a configuration system which sets it on a per-env basis.
In test/development the `ttl` might be set to an explicit value whereas in production it might be `null`
```js
server.auth.strategy('session', 'cookie', 'try', {
password: options.cookieOptions.password,
cookie: 'ssosid',
ttl: options.cookieOptions.ttl,
domain: options.cookieOptions.domain,
redirectOnTry: false,
appendNext: true,
clearInvalid: true,
isSecure: true,
isHttpOnly: true,
validateFunc: validate
});
```
We can work around this easily by doing something like:
```js
const strategyOptions = {
password: options.cookieOptions.password,
cookie: 'ssosid',
domain: options.cookieOptions.domain,
redirectOnTry: false,
appendNext: true,
clearInvalid: true,
isSecure: true,
isHttpOnly: true,
validateFunc: validate
};
if(options.cookieOptions.ttl) {
strategyOptions.ttl = options.cookieOptions.ttl;
}
server.auth.strategy('session', 'cookie', 'try', strategyOptions);
```
However, it just felt a little cleaner to have the `ttl` schema accept a valid cookie ttl value.
Thoughts?
|
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
nullis a valid default option for thettlof the cookie but the schema isn't currently allowing it.As an example, in our case the value for
ttlis coming from an external place; from a configuration system which sets it on a per-env basis.In test/development the
ttlmight be set to an explicit value whereas in production it might benullWe can work around this easily by doing something like:
However, it just felt a little cleaner to have the
ttlschema accept a valid cookie ttl value.Thoughts?