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

fix(postgraphql): Throw an error if jwtSecret is provided without jwtPgTypeIndentifer being provided #466

Merged
merged 8 commits into from
Jun 6, 2017
Merged

fix(postgraphql): Throw an error if jwtSecret is provided without jwtPgTypeIndentifer being provided #466

merged 8 commits into from
Jun 6, 2017

Conversation

mikeburgh
Copy link

Throws an error if a secret and no token identifier is provided in the options.

Copy link
Member

@benjie benjie left a comment

Choose a reason for hiding this comment

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

This has tripped up a number of people so it's a very welcome addition!

Could you add a test for it so we don't accidentally remove it at a later date whilst refactoring? It would be nice to have tests for all 4 cases: jwtSecret or not ⨉ jwtPgTypeIdentifier or not.

// Check for a jwtSecret without a jwtPgTypeIdentifier
// a secret without a token identifier prevents JWT creation
if (options.jwtSecret && !options.jwtPgTypeIdentifier) {
throw new Error(`jwtSecret provided, however jwtPgTypeIdentifier (token identifier) not provided.\n`);
Copy link
Member

Choose a reason for hiding this comment

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

Why the \n on the error message?

Copy link
Member

@benjie benjie left a comment

Choose a reason for hiding this comment

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

Tests would still be welcome

Copy link
Member

@benjie benjie left a comment

Choose a reason for hiding this comment

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

LGTM!

@benjie
Copy link
Member

benjie commented May 30, 2017

Apparently I can't merge this on mobile; sorry for delay.

@mikeburgh
Copy link
Author

No problems, I am in no rush :)

@benjie benjie merged commit f68056c into graphile:master Jun 6, 2017
@benjie
Copy link
Member

benjie commented Jun 6, 2017

🙏

@benjie
Copy link
Member

benjie commented Jul 7, 2017

So... It turns out that I am actually using jwtSecret without jwtPgTypeIdentifier - deliberately! I had totally forgotten that.

Reason is: I generate the JWT token outside of PostGraphQL, PostGraphQL just uses the jwtSecret to validate the incoming token.

I'm going to change this to a warning.

Belline pushed a commit to Belline/postgraphql that referenced this pull request Dec 18, 2017
graphile#466)

* fix(postgraphql): Throw an error if jwtSecret is provided without jwtPgTypeIndentifer being provided

* Tweaks

* Remove semicolon

* Adding test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants