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

Update hapi to v16 and fix breaking changes #56

Merged
merged 1 commit into from
Jan 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const appSessionCookieSchema = Joi.object().keys({
ephemeral: Joi.boolean().optional(),
httpOnly: Joi.boolean().optional(),
path: Joi.string().optional(),
sameSite: Joi.string().valid(['Lax', 'Strict', 'None']).optional(),
sameSite: Joi.string().valid('Lax', 'Strict', 'None').optional(),
secure: Joi.boolean().optional()
}).unknown(false);

Expand All @@ -41,7 +41,7 @@ const paramsSchema = Joi.object().keys({
// Array of keys to allow for rotation.
Joi.array().items(Joi.string()),
// False to stop client session from being created.
Joi.boolean().valid([false])
Joi.boolean().valid(false)
]).required(),
auth0Logout: Joi.boolean().optional().default(false),
authorizationParams: Joi.object().optional(),
Expand All @@ -50,8 +50,8 @@ const paramsSchema = Joi.object().keys({
clientSecret: Joi.string().optional(),
clockTolerance: Joi.number().optional().default(60),
errorOnRequiredAuth: Joi.boolean().optional().default(false),
getUser: Joi.func().optional().default(getUser),
handleCallback: Joi.func().optional().default(handleCallback),
getUser: Joi.function().optional().default(() => getUser),
handleCallback: Joi.function().optional().default(() => handleCallback),
httpOptions: Joi.object().optional(),
identityClaimFilter: Joi.array().optional().default(['aud', 'iss', 'iat', 'exp', 'nonce', 'azp', 'auth_time']),
idpLogout: Joi.boolean().optional().default(false).when(
Expand All @@ -63,7 +63,7 @@ const paramsSchema = Joi.object().keys({
loginPath: Joi.string().uri({relativeOnly: true}).optional().default('/login'),
logoutPath: Joi.string().uri({relativeOnly: true}).optional().default('/logout'),
redirectUriPath: Joi.string().uri({relativeOnly: true}).optional().default('/callback'),
required: Joi.alternatives([ Joi.func(), Joi.boolean()]).optional().default(true),
required: Joi.alternatives([ Joi.function(), Joi.boolean()]).optional().default(true),
routes: Joi.boolean().optional().default(true),
postLogoutRedirectUri: Joi.string().uri({allowRelative: true}).optional().default('/')
});
Expand All @@ -86,7 +86,7 @@ If the user provides authorizationParams then
authorizationParams.scope = defaultAuthorizeParams.scope;
}

const authParamsValidation = Joi.validate(authorizationParams, authorizationParamsSchema);
const authParamsValidation = authorizationParamsSchema.validate(authorizationParams);

if(authParamsValidation.error) {
throw new Error(authParamsValidation.error.details[0].message);
Expand All @@ -99,7 +99,7 @@ function buildAppSessionCookieConfig(cookieConfig) {

cookieConfig = cookieConfig && Object.keys(cookieConfig).length ? cookieConfig : {};
cookieConfig = Object.assign({}, defaultAppSessionCookie, cookieConfig);
const cookieConfigValidation = Joi.validate(cookieConfig, appSessionCookieSchema);
const cookieConfigValidation = appSessionCookieSchema.validate(cookieConfig);

if(cookieConfigValidation.error) {
throw new Error(cookieConfigValidation.error.details[0].message);
Expand All @@ -113,7 +113,7 @@ module.exports.get = function(params) {

loadEnvs(config);

const paramsValidation = Joi.validate(config, paramsSchema);
const paramsValidation = paramsSchema.validate(config);

if(paramsValidation.error) {
throw new Error(paramsValidation.error.details[0].message);
Expand Down
28 changes: 17 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"test": "mocha"
},
"dependencies": {
"@hapi/joi": "^15.1.1",
"@hapi/joi": "^16.1.8",
"cb": "^0.1.0",
"clone": "^2.1.2",
"cookie": "^0.4.0",
Expand Down
4 changes: 2 additions & 2 deletions test/invalid_params.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('invalid parameters', function() {
issuerBaseURL: '__invalid_url__',
clientID: '__test_client_id__'
});
}, '"issuerBaseURL" must be a valid uri');
}, '"issuerBaseURL" does not match any of the allowed types');
});

it('should fail when the baseURL is invalid', function() {
Expand Down Expand Up @@ -94,7 +94,7 @@ describe('invalid parameters', function() {
it('should fail when app session secret is invalid', function() {
assert.throws(() => {
expressOpenid.auth(getTestConfig({appSessionSecret: {key: '__test_session_secret__'}}));
}, '"appSessionSecret" must be a string');
}, '"appSessionSecret" must be one of [string, array, false]');
});

it('should fail when app session cookie httpOnly is not a boolean', function() {
Expand Down