This repository was archived by the owner on Jun 6, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Gh-521: Document Gremlin integration in the REST API #522
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
546f3ef
document the new gremlin integration into rest api
tb06904 b6e191b
Apply suggestions from code review
tb06904 f2a9d8a
address comments
tb06904 90b163d
Update docs/administration-guide/security/user-control.md
tb06904 4a748e8
Apply suggestions from code review
tb06904 4e1c8b6
Merge branch 'v2docs' into gh-521-gremlin-in-restapi
cn337131 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,50 @@ | ||
# User Authentication | ||
|
||
!!! info "Work in Progress" | ||
|
||
This page is under construction. | ||
This page is under construction. | ||
|
||
The user authentication layer for Gaffer is currently only enforced by the REST | ||
API. We recommend restricting users such that they do not have access to the | ||
underlying Java API so that all queries are authenticated and executed via the | ||
REST API. | ||
|
||
In the REST API the `User` object is constructed via a [`UserFactory`](https://gchq.github.io/Gaffer/uk/gov/gchq/gaffer/rest/factory/UserFactory.html). | ||
In the Spring REST API an abstract implementation of this class is used, | ||
`AbstractUserFactory`, which is then used in the passing of HTTP headers for | ||
authentication. | ||
|
||
Currently, there is a single default implementation of this; the | ||
`UnknownUserFactory` which simply returns a new `User` with `UNKNOWN` as the | ||
user ID. To specify the user | ||
factory class define the `gaffer.user.factory.class` [REST property](../gaffer-config/config.md#application-properties). | ||
|
||
## Writing a User Factory | ||
|
||
To authenticate your users you will need to extend the `AbstractUserFactory` class | ||
to add your chosen authentication mechanism. The hooks will already be in the REST API | ||
to pass the current HTTP headers for each request. Your factory will need to parse these | ||
to construct a new `User` object via the `createUser()` method that reflects the user | ||
making the request. This could involve making a call to an LDAP server or similar | ||
authentication service. | ||
|
||
For example, you could use the authorisation header in the request: | ||
|
||
```java | ||
public class LdapUserFactory extends AbstractUserFactory { | ||
|
||
public User createUser() { | ||
final String authHeaderValue = this.httpHeaders.get(HttpHeaders.AUTHORIZATION); // add logic to fetch userId | ||
final String userId = null; // extract from authHeaderValue | ||
final List<String> opAuths = null; // fetch op auths for userId | ||
final List<String> dataAuths = null; // fetch op auths for userId | ||
|
||
// Create and return the Gaffer user | ||
return new User.Builder() | ||
.userId(userId) | ||
.opAuths(opAuths) | ||
.dataAuths(dataAuths) | ||
.build(); | ||
} | ||
} | ||
``` |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.