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

Gh-2991: Improve User Authorisation in GafferPop #3202

Merged
merged 8 commits into from May 7, 2024

Conversation

tb06904
Copy link
Member

@tb06904 tb06904 commented May 1, 2024

This adds the relevant hooks and framework for full user auth for gremlin server connections to GafferPop. It utilises the existing frameworks provided by Tinkerpop to ensure the authenticated user ID is passed on to the graph to use for the query. The way this works is by leveraging the custom GafferPopGraphStep to inject the userId via a with() step on the requested traversal, this is then passed onto the graph variables and used in the query. There are checks in place to prevent manually adding a with() step that sets the userId so that only the currently authorised user ID is used.

There is a example/default Authenticator class provided but this is intended to be used as a template for a specific implementation for a production environment's auth mechanism (for example tinkerpop provide a kerberos version here).

The way the authentication classes are activated is by adding the following config to the gremlin server yaml:

authentication: {
  authenticator: uk.gov.gchq.gaffer.tinkerpop.server.auth.DefaultGafferPopAuthenticator
}
authorization: {
  authorizer: uk.gov.gchq.gaffer.tinkerpop.server.auth.GafferPopAuthoriser
}

Related issue

@tb06904 tb06904 linked an issue May 1, 2024 that may be closed by this pull request
Copy link

codecov bot commented May 1, 2024

Codecov Report

Attention: Patch coverage is 84.12698% with 10 lines in your changes are missing coverage. Please review.

Project coverage is 66.80%. Comparing base (c0b950f) to head (27e8d3b).

Files Patch % Lines
...pop/server/auth/ExampleGafferPopAuthenticator.java 77.77% 4 Missing and 4 partials ⚠️
...fer/tinkerpop/server/auth/GafferPopAuthoriser.java 92.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop    #3202      +/-   ##
=============================================
+ Coverage      66.78%   66.80%   +0.02%     
+ Complexity      2558     2556       -2     
=============================================
  Files            910      912       +2     
  Lines          29217    29279      +62     
  Branches        3256     3269      +13     
=============================================
+ Hits           19512    19560      +48     
- Misses          8261     8268       +7     
- Partials        1444     1451       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@GCHQDeveloper314 GCHQDeveloper314 left a comment

Choose a reason for hiding this comment

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

To check my understanding, when these new classes are not used, the default user for GafferPop is used as the Gaffer user, and when they are used, the username is added using with.

I'm assuming a username still be supplied using with (as before) if these classes are not enabled in config?

p29876 added a commit that referenced this pull request May 2, 2024
@tb06904
Copy link
Member Author

tb06904 commented May 2, 2024

To check my understanding, when these new classes are not used, the default user for GafferPop is used as the Gaffer user, and when they are used, the username is added using with.

I'm assuming a username still be supplied using with (as before) if these classes are not enabled in config?

Correct, when you don't specify any auth classes the user ID in the gafferpop.properties file will be used to construct the Gaffer user and you can arbitrarily set it via a with("userId", "id") to anything for a given query.

When the GafferPopAuthoriser is used it will block any attempts at setting the ID via a with() and instead pass on the ID of the current authorised user (from the authenticator class) by injecting its own with() into the query.

@GCHQDeveloper314 GCHQDeveloper314 merged commit 0210c47 into develop May 7, 2024
26 checks passed
@GCHQDeveloper314 GCHQDeveloper314 deleted the gh-2991-improve-user-auth-in-gafferpop branch May 7, 2024 07:50
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.

Improve user auth in gafferpop
4 participants