-
Notifications
You must be signed in to change notification settings - Fork 91
Add documentation and examples for user auth #1448
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
Open
kblum
wants to merge
3
commits into
aws:main
Choose a base branch
from
kblum:docs/auth
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,3 +4,4 @@ | |
| - [Development](./development.md) | ||
| - [SageMaker](./sagemaker) | ||
| - [ECS](./ecs) | ||
| - [Auth](./auth.md) | ||
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 |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| # Authentication and Authorization | ||
|
|
||
| The Graph Explorer UI does not have built-in support for any user authentication or authorization. | ||
|
|
||
| Anyone with access to the service URL can access the graph data (even if Neptune database instances are locked down, because the UI is not). This is a security issue if the data is sensitive. | ||
|
|
||
| Authentication can be added by putting Graph Explorer behind an Nginx reverse proxy server. The Graph Explorer route should only be accessible by Nginx. Nginx can then be configured to add authentication. | ||
|
|
||
|
|
||
| ## HTTP Basic Authentication | ||
|
|
||
| Nginx natively supports HTTP Basic Authentication. | ||
|
|
||
| Minimal example Nginx configuration: | ||
|
|
||
| ```nginx | ||
| server { | ||
|
|
||
| location / { | ||
| auth_basic "Graph Explorer Login"; | ||
| auth_basic_user_file /etc/nginx/auth/htpasswd; | ||
|
|
||
| set $upstream_graph_explorer graph_explorer.svc.cluster.local:8080; | ||
| proxy_pass http://$upstream_graph_explorer; | ||
| } | ||
|
|
||
| } | ||
| ``` | ||
|
|
||
| The example configuration assumes that Graph Explorer is running on `http://graph_explorer.svc.cluster.local:8080`, which is only accessible to Nginx. | ||
|
|
||
| Create and mount a `/etc/nginx/auth/htpasswd` file on the Nginx pod or server. Passwords can be generated using `pwgen` and encoded using `openssl passwd`. | ||
|
|
||
| Example `htpasswd` file contents: | ||
|
|
||
| ``` | ||
| # password file | ||
| # format USER:PASSWORD:COMMENT | ||
| admin:$1$OasDSiq8$E6lJaEHz0rjM5DXj2GwZv. | ||
| # username: admin; password: admin | ||
| ``` | ||
|
|
||
|
|
||
| ## LDAP and Active Directory Authentication | ||
|
|
||
| Nginx lacks built-in support for LDAP and Active Directory authentication. | ||
|
|
||
| The [`ngx_http_auth_request_module`](https://nginx.org/en/docs/http/ngx_http_auth_request_module.html) module for Nginx can be used to implement client authorization based on the result of a sub-request to another service. | ||
|
|
||
| An `nginx-ldap-auth-service` deployment (a project developed and used at Caltech) can be used to authenticate users against LDAP and Active Directory. | ||
|
|
||
| References for `nginx-ldap-auth-service`: | ||
|
|
||
| - [Documentation](https://nginx-ldap-auth-service.readthedocs.io) | ||
| - [Container registry](https://hub.docker.com/r/caltechads/nginx-ldap-auth-service) | ||
| - [Source code](https://github.com/caltechads/nginx-ldap-auth-service) | ||
|
|
||
| The `nginx-ldap-auth-service` service is configured using environment variables. Please the [environment documentation](https://nginx-ldap-auth-service.readthedocs.io/en/latest/configuration.html#environment) for details on configuring the service. | ||
|
|
||
| Minimal example Nginx configuration: | ||
|
|
||
| ```nginx | ||
| server { | ||
|
|
||
| location / { | ||
| auth_request /check-auth; | ||
|
|
||
| # If the auth service returns a 401, redirect to the login page. | ||
| error_page 401 =200 /auth/login?service=$request_uri; | ||
|
|
||
| set $upstream_app APP_SERVICE_NAME.APP_NAMESPACE.svc.cluster.local:8080; | ||
| proxy_pass http://$upstream_app; | ||
| } | ||
|
|
||
| location /auth { | ||
| set $upstream_graph_ldap LDAP_SERVICE_NAME.LDAP_SERVICE_NAMESPACE.svc.cluster.local:8888; | ||
| proxy_pass http://$upstream_ldap; | ||
|
|
||
| proxy_set_header X-Cookie-Name "nginxauth"; | ||
| proxy_set_header X-Cookie-Domain "NGINX_GATEWAY_DOMAIN"; | ||
| proxy_set_header X-Auth-Realm "Restricted Area"; | ||
| proxy_set_header Host $host; | ||
| proxy_set_header X-Real-IP $remote_addr; | ||
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
| proxy_set_header Cookie nginxauth_csrf=$cookie_nginxauth_csrf; | ||
| } | ||
|
|
||
| location /check-auth { | ||
| internal; | ||
|
|
||
| set $upstream_graph_ldap LDAP_SERVICE_NAME.LDAP_SERVICE_NAMESPACE.svc.cluster.local:8888; | ||
| proxy_pass http://$upstream_ldap/check; | ||
|
|
||
| proxy_pass_request_headers off; | ||
| proxy_pass_request_body off; | ||
| proxy_set_header Content-Length ""; | ||
|
|
||
| proxy_ignore_headers "Set-Cookie"; | ||
| proxy_hide_header "Set-Cookie"; | ||
|
|
||
| proxy_set_header X-Cookie-Name "nginxauth"; | ||
| proxy_set_header X-Cookie-Domain "NGINX_GATEWAY_DOMAIN"; | ||
| proxy_set_header Cookie nginxauth=$cookie_nginxauth; | ||
| } | ||
|
|
||
| } | ||
| ``` | ||
|
|
||
| The example configuration assumes that Graph Explorer on running on an internal `http://APP_SERVICE_NAME.APP_NAMESPACE.svc.cluster.local:8080` route and that the auth service is running on `http://LDAP_SERVICE_NAME.LDAP_SERVICE_NAMESPACE.svc.cluster.local:8888`. | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This depends. If deployed on a Neptune Notebook instance (the default customer experience for using Graph Explorer), the endpoint is protected behind the Neptune (SageMaker) Notebook endpoint (which requires IAM authentication). We use Jupyter Proxy to expose the Graph Explorer container as a path on the SageMaker Notebook endpoint (ex:
https://notebook-name.notebook.us-west-2.sagemaker.aws/proxy/9250/explorer/#/graph-explorer). Access to this only works if you pass a valid IAM SigV4 signature with the request to this endpoint.So this only becomes an issue for custom deployments that are not part of a Neptune Notebook deployment. We should call this out here, as we don't want to give the impression that Graph Explorer has no means of authentication regardless of deployment model.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@triggan Good point. I have changed the documentation to make it clear that this is only applicable for custom deployments.