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

feat(graphql): add allowUnauthenticated parameter to auth rules #355

Merged
merged 10 commits into from
Jul 28, 2021

Conversation

mathix420
Copy link
Contributor

@mathix420 mathix420 commented Jul 23, 2021

Description

Add allowUnauthenticated parameter in auth rules to avoid throwing exceptions if no auth is provided.

Changes:

  • Update documentation auth/authentication.
  • If paramValue is undefined inject false instead of the previous condition key = $param, as it should always be falsy
  • Fix a small issue: if a paramValue is null, apoc.validate raise an exception if the check is done like this value = null. So I just replaced the condition for it to be value IS null (more infos)
  • Fix the 4.3.0 Neo4J deprecation of EXISTS() with recommanded IS NOT NULL. (more infos)

Issue

#345

Checklist

  • Documentation has been updated
  • TCK tests have been updated
  • Integration tests have been updated
  • Example applications have been updated
  • New files have copyright header
  • CLA (https://neo4j.com/developer/cla/) has been signed

@mathix420 mathix420 marked this pull request as ready for review July 23, 2021 10:24
@darrellwarde
Copy link
Contributor

Hey @mathix420, thanks for the contribution!

This really needs some integration tests to prove that unexpected errors won't be thrown on execution of the Cypher.

@mathix420
Copy link
Contributor Author

mathix420 commented Jul 24, 2021

@darrellwarde Should I open 2 separate issues to explain more in details the EXISTS() change and apoc.validate behavior on null comparisons?

@darrellwarde
Copy link
Contributor

@darrellwarde Should I open 2 separate issues to explain more in details the EXISTS() change and apoc.validate behavior on null comparisons?

Hey @mathix420, sorry for the slow reply here! No need to open 2 PRs, happy to review as a batch - was just waiting on some integration tests but realise now I missed your commit!

@darrellwarde
Copy link
Contributor

It does look like you have some unit test failures though which will need reviewing.

@mathix420
Copy link
Contributor Author

It does look like you have some unit test failures though which will need reviewing.

Yup, sorry dumb mistake I was focalized on create-auth-and-params tests 😅
Everything should be fix now.

I'm not sure if I should replace all others occurences of EXISTS() in this PR, should I?

@danstarns
Copy link
Contributor

It does look like you have some unit test failures though which will need reviewing.

Yup, sorry dumb mistake I was focalized on create-auth-and-params tests 😅
Everything should be fix now.

I'm not sure if I should replace all others occurences of EXISTS() in this PR, should I?

Hey, no need to replace all other EXISTS we can do this in another PR. Thanks for pointing out its deprecation.

@mathix420
Copy link
Contributor Author

@danstarns great, have a nice day!

Copy link
Contributor

@darrellwarde darrellwarde left a comment

Choose a reason for hiding this comment

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

Thanks for PR, always grateful for contributions! 🙂

Please see code comments, and also, I would like to see some integration tests for more complex cases. For example, what happens with allow and allowUnauthenticated if there is one post which is published and one that isn't?

packages/graphql/src/schema/get-auth.ts Outdated Show resolved Hide resolved
docs/asciidoc/auth/authentication.adoc Outdated Show resolved Hide resolved
packages/graphql/src/translate/create-auth-and-params.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@darrellwarde darrellwarde left a comment

Choose a reason for hiding this comment

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

Literally just a single word documentation change, which I think can just be applied from my suggestion once I've finished this review!

docs/asciidoc/auth/authentication.adoc Outdated Show resolved Hide resolved
Copy link
Contributor

@darrellwarde darrellwarde left a comment

Choose a reason for hiding this comment

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

As expected, I was able to just apply my word change suggestion.

In which case, this all looks good! 🚀 Thanks for the improvement, and working through changes so quickly!

@danstarns
Copy link
Contributor

Thanks @mathix420

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.

3 participants