-
Notifications
You must be signed in to change notification settings - Fork 453
Feature/auth docker setup docs #12459
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
Merged
Merged
Changes from 13 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
00ac342
add: ldap, keycloak oidc setup & sample configurations
mahesh-wor 74d2bee
docs: add auth-docker-setup for configuring ldap/keycloak
mahesh-wor 7384604
ref: docs to mention mapstore src url
mahesh-wor 862c570
removed insecure fallbacks, updated .env.sample and update docs
mahesh-wor bf78eda
support direct ldap, updated samples/envs
mahesh-wor c06f592
disable autocreate user that breaks callback if direct ldap is config…
mahesh-wor 739080a
infra: improve auth stack setup for LDAP, Keycloak, build, and docs
mahesh-wor 9cd7319
tests: Endpoint tests to include ldap properties & service
mahesh-wor 0397a71
fix: updated the sample data-dir & configurations for gs 2.6 related …
mahesh-wor 512e57b
add: sample configs for microsoft entra & updates to group configuration
mahesh-wor cdf04bc
add: sample configs for microsoft entra & lint issues
mahesh-wor 470a323
fix: ldap overides, ldifs in single sample, update docs
mahesh-wor 648fadb
docs: add quick start to docs and test compose stack
mahesh-wor ddec0cc
docs: related to test docker compose stack and profiles
mahesh-wor 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 |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| .git | ||
| node_modules |
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 |
|---|---|---|
|
|
@@ -39,4 +39,4 @@ services: | |
| profiles: | ||
| - test | ||
| networks: | ||
| - mapstore-network | ||
| - mapstore-network | ||
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 |
|---|---|---|
|
|
@@ -56,4 +56,3 @@ services: | |
|
|
||
| volumes: | ||
| pg_data: | ||
|
|
||
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,27 @@ | ||
| # Copy to .env and adjust if needed. | ||
| # The variables below are SAMPLE values for local development only. | ||
| # Do NOT use these credentials in production. | ||
| # The auth compose overlay provides sample defaults, but for any real deployment | ||
| # you should create a `.env` file with secure values and override defaults. | ||
|
|
||
| # LDAP sample values | ||
| LDAP_ORGANISATION=Acme | ||
| LDAP_DOMAIN=acme.org | ||
| LDAP_ADMIN_PASSWORD=changeme-ldap-admin-pw-123 | ||
| LDAP_CONFIG_PASSWORD=changeme-ldap-config-pw-123 | ||
| LDAP_READONLY_USER=true | ||
| LDAP_READONLY_USER_USERNAME=svc_mapstore_ldap | ||
| LDAP_READONLY_PASSWORD=changeme-ldap-bind-pw-123 | ||
| LDAP_TLS=false | ||
|
|
||
| # Keycloak dev admin (admin console at http://localhost/keycloak/admin/) | ||
| KEYCLOAK_ADMIN=admin | ||
| KEYCLOAK_ADMIN_PASSWORD=changeme-keycloak-admin-pw-123 | ||
| KEYCLOAK_HTTP_RELATIVE_PATH=/keycloak | ||
| KEYCLOAK_HOSTNAME=http://localhost/keycloak | ||
| KEYCLOAK_HOSTNAME_STRICT=false | ||
| KEYCLOAK_PROXY_HEADERS=xforwarded | ||
| KEYCLOAK_REALM_FILE=realm-mapstore.json | ||
| # The auth compose expects a realm file named `realm-mapstore.json` in `docker/keycloak/` by default. | ||
| # To use the shipped sample, copy `docker/keycloak/realm-mapstore.sample.json` to | ||
| # `docker/keycloak/realm-mapstore.json` or set `KEYCLOAK_REALM_FILE` to the sample filename. |
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,103 @@ | ||
| version: "3.8" | ||
| networks: | ||
| mapstore-network: | ||
| driver: bridge | ||
|
|
||
| services: | ||
| ldap: | ||
| build: | ||
| context: ./docker/openldap/ | ||
| image: geosolutions-mapstore/openldap | ||
| container_name: ldap | ||
| restart: on-failure | ||
| entrypoint: | ||
| - /bin/sh | ||
| - -lc | ||
| - > | ||
| rm -rf /container/service/slapd/assets/config/bootstrap/ldif/custom/* && | ||
| cp /ldif-src/ldap-init.ldif /container/service/slapd/assets/config/bootstrap/ldif/custom/ldap-init.ldif && | ||
| exec /container/tool/run | ||
| environment: | ||
| LDAP_ORGANISATION: "${LDAP_ORGANISATION:-Acme}" | ||
| LDAP_DOMAIN: "${LDAP_DOMAIN:-acme.org}" | ||
| LDAP_ADMIN_PASSWORD: "${LDAP_ADMIN_PASSWORD:-changeme-ldap-admin-pw-123}" | ||
| LDAP_CONFIG_PASSWORD: "${LDAP_CONFIG_PASSWORD:-changeme-ldap-config-pw-123}" | ||
| LDAP_READONLY_USER: "true" | ||
| LDAP_READONLY_USER_USERNAME: "${LDAP_READONLY_USER_USERNAME:-svc_mapstore_ldap}" | ||
| LDAP_READONLY_USER_PASSWORD: "${LDAP_READONLY_PASSWORD:-changeme-ldap-bind-pw-123}" | ||
| LDAP_TLS: "${LDAP_TLS:-false}" | ||
| volumes: | ||
| - ldap_data:/var/lib/ldap | ||
| - ldap_config:/etc/ldap/slapd.d | ||
| - ./docker/openldap/ldap-init.ldif:/ldif-src/ldap-init.ldif:ro | ||
| healthcheck: | ||
| test: ["CMD-SHELL", "ldapsearch -x -H ldap://localhost -b \"\" -s base \"(objectClass=*)\" namingContexts >/dev/null 2>&1"] | ||
| interval: 5s | ||
| timeout: 5s | ||
| retries: 30 | ||
| start_period: 20s | ||
| networks: | ||
| - mapstore-network | ||
|
|
||
| keycloak: | ||
| image: quay.io/keycloak/keycloak:26.0.7 | ||
| container_name: keycloak | ||
| restart: on-failure | ||
| environment: | ||
| KC_BOOTSTRAP_ADMIN_USERNAME: "${KEYCLOAK_ADMIN:-admin}" | ||
| KC_BOOTSTRAP_ADMIN_PASSWORD: "${KEYCLOAK_ADMIN_PASSWORD}" | ||
| KC_HTTP_ENABLED: "true" | ||
| KC_HTTP_RELATIVE_PATH: "${KEYCLOAK_HTTP_RELATIVE_PATH:-/keycloak}" | ||
| KC_HOSTNAME: "${KEYCLOAK_HOSTNAME:-http://localhost/keycloak}" | ||
| KC_HOSTNAME_STRICT: "${KEYCLOAK_HOSTNAME_STRICT:-false}" | ||
| KC_PROXY_HEADERS: "${KEYCLOAK_PROXY_HEADERS:-xforwarded}" | ||
| KC_HEALTH_ENABLED: "true" | ||
| KC_HTTP_MANAGEMENT_RELATIVE_PATH: / | ||
| command: start-dev --import-realm | ||
| volumes: | ||
| - ./docker/keycloak/realm-mapstore.json:/opt/keycloak/data/import/realm-mapstore.json:ro | ||
| - keycloak_data:/opt/keycloak/data | ||
| healthcheck: | ||
| test: ["CMD-SHELL", "{ printf 'HEAD /health/ready HTTP/1.0\\r\\n\\r\\n' >&0; grep 'HTTP/1.0 200'; } 0<>/dev/tcp/127.0.0.1/9000"] | ||
| interval: 5s | ||
| timeout: 3s | ||
| retries: 12 | ||
| start_period: 30s | ||
| networks: | ||
| - mapstore-network | ||
|
|
||
| proxy: | ||
| image: nginx | ||
| container_name: proxy | ||
| volumes: | ||
| - ./docker/mapstore.auth.conf:/etc/nginx/conf.d/default.conf:rw | ||
| ports: | ||
| - 80:80 | ||
| depends_on: | ||
| - mapstore | ||
| - keycloak | ||
| networks: | ||
| - mapstore-network | ||
|
|
||
| mapstore: | ||
| build: | ||
| context: . | ||
| dockerfile: Dockerfile | ||
| args: | ||
| MAPSTORE_WEBAPP_SRC: "mapstore.war" | ||
| depends_on: | ||
| ldap: | ||
| condition: service_healthy | ||
| keycloak: | ||
| condition: service_healthy | ||
| extra_hosts: | ||
| - "host.docker.internal:host-gateway" | ||
| volumes: | ||
| - "${DATADIR_PATH:-./datadir}:/usr/local/tomcat/datadir:ro" | ||
| networks: | ||
| - mapstore-network | ||
|
|
||
| volumes: | ||
| ldap_data: | ||
| ldap_config: | ||
| keycloak_data: |
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,102 @@ | ||
| { | ||
| "realm": "mapstore", | ||
| "enabled": true, | ||
| "registrationAllowed": false, | ||
| "loginWithEmailAllowed": true, | ||
| "duplicateEmailsAllowed": false, | ||
| "resetPasswordAllowed": false, | ||
| "editUsernameAllowed": false, | ||
| "sslRequired": "external", | ||
| "roles": { | ||
| "realm": [ | ||
| { | ||
| "name": "admin", | ||
| "description": "Mapped to MapStore ADMIN (see mapstore-ovr.properties roleMappings)" | ||
| }, | ||
| { | ||
| "name": "user", | ||
| "description": "Optional; default MapStore role is USER if unmapped" | ||
| } | ||
| ] | ||
| }, | ||
| "groups": [ | ||
| { | ||
| "name": "kc-admins", | ||
| "path": "/kc-admins" | ||
| }, | ||
| { | ||
| "name": "kc-users", | ||
| "path": "/kc-users" | ||
| } | ||
| ], | ||
| "users": [ | ||
| { | ||
| "username": "kcuser", | ||
| "enabled": true, | ||
| "emailVerified": true, | ||
| "firstName": "Keycloak", | ||
| "lastName": "User", | ||
| "email": "kcuser@acme.org", | ||
| "realmRoles": ["user"], | ||
| "groups": ["/kc-users"], | ||
| "credentials": [ | ||
| { | ||
| "type": "password", | ||
| "value": "changeme-kcuser-pw-123", | ||
| "temporary": false | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "username": "kcadmin", | ||
| "enabled": true, | ||
| "emailVerified": true, | ||
| "firstName": "Keycloak", | ||
| "lastName": "Admin", | ||
| "email": "kcadmin@acme.org", | ||
| "realmRoles": ["admin"], | ||
| "groups": ["/kc-admins"], | ||
| "credentials": [ | ||
| { | ||
| "type": "password", | ||
| "value": "changeme-kcadmin-pw-123", | ||
| "temporary": false | ||
| } | ||
| ] | ||
| } | ||
| ], | ||
| "clients": [ | ||
| { | ||
| "clientId": "mapstore-server", | ||
| "name": "MapStore OpenID (server)", | ||
| "enabled": true, | ||
| "protocol": "openid-connect", | ||
| "publicClient": false, | ||
| "clientAuthenticatorType": "client-secret", | ||
| "secret": "changeme-mapstore-oidc-client-secret-123", | ||
| "standardFlowEnabled": true, | ||
| "directAccessGrantsEnabled": false, | ||
| "serviceAccountsEnabled": false, | ||
| "redirectUris": ["http://localhost/mapstore/*"], | ||
| "webOrigins": ["http://localhost", "+"], | ||
| "protocolMappers": [ | ||
| { | ||
| "name": "groups", | ||
| "protocol": "openid-connect", | ||
| "protocolMapper": "oidc-group-membership-mapper", | ||
| "consentRequired": false, | ||
| "config": { | ||
| "claim.name": "groups", | ||
| "full.path": "false", | ||
| "id.token.claim": "true", | ||
| "access.token.claim": "true", | ||
| "userinfo.token.claim": "true" | ||
| } | ||
| } | ||
| ], | ||
| "attributes": { | ||
| "post.logout.redirect.uris": "http://localhost/mapstore/*" | ||
| } | ||
| } | ||
| ] | ||
| } |
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,115 @@ | ||
| server { | ||
| server_name localhost; | ||
|
|
||
| listen 80; | ||
| listen [::]:80; | ||
|
|
||
| server_tokens off; | ||
|
|
||
| root /usr/share/nginx/html; | ||
| index index.html; | ||
|
|
||
| gzip on; | ||
| gzip_disable "msie6"; | ||
|
|
||
| gzip_vary on; | ||
| gzip_proxied any; | ||
| gzip_comp_level 6; | ||
| gzip_buffers 16 8k; | ||
| gzip_http_version 1.1; | ||
| gzip_types | ||
| text/plain | ||
| text/css | ||
| application/json | ||
| application/javascript | ||
| application/x-javascript | ||
| text/xml application/xm | ||
| application/xml+rss | ||
| text/javascript; | ||
|
|
||
| underscores_in_headers on; | ||
| proxy_set_header HOST $host; | ||
| proxy_set_header X-Forwarded-Proto $scheme; | ||
| proxy_set_header X-Forwarded-Host $host; | ||
| proxy_set_header X-Real-IP $remote_addr; | ||
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
| proxy_buffering on; | ||
| proxy_buffer_size 1k; | ||
| proxy_buffers 24 4k; | ||
| proxy_busy_buffers_size 8k; | ||
| proxy_max_temp_file_size 2048m; | ||
| proxy_temp_file_write_size 32k; | ||
|
|
||
| location / { | ||
| deny all; | ||
| return 301 /mapstore; | ||
| } | ||
|
|
||
| # Keycloak (same host as MapStore — required for OIDC redirects and MapStore backend) | ||
| location /keycloak/ { | ||
| proxy_pass http://keycloak:8080/keycloak/; | ||
|
|
||
| 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 X-Forwarded-Proto $scheme; | ||
| proxy_set_header X-Forwarded-Host $host; | ||
| proxy_set_header X-Forwarded-Port $server_port; | ||
| proxy_set_header X-Forwarded-Prefix /keycloak; | ||
|
|
||
| # Keycloak auth responses set large Set-Cookie headers; default 1k buffers cause 502. | ||
| proxy_buffer_size 128k; | ||
| proxy_buffers 8 256k; | ||
| proxy_busy_buffers_size 256k; | ||
| proxy_temp_file_write_size 256k; | ||
| } | ||
|
|
||
| location /mapstore { | ||
| proxy_pass http://mapstore:8080/mapstore; | ||
|
|
||
| # OIDC callback returns 302 + Set-Cookie; large request Cookie headers are common too. | ||
| proxy_buffer_size 128k; | ||
| proxy_buffers 8 256k; | ||
| proxy_busy_buffers_size 256k; | ||
| proxy_temp_file_write_size 256k; | ||
|
|
||
| if ($request_method = 'OPTIONS') { | ||
| add_header 'Access-Control-Allow-Origin' '$http_origin'; | ||
| add_header 'Access-Control-Allow-Credentials' 'true'; | ||
| add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE'; | ||
| add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization'; | ||
| add_header 'Access-Control-Max-Age' 1728000; | ||
| add_header 'Content-Type' 'text/plain; charset=utf-8'; | ||
| add_header 'Content-Length' 0; | ||
| return 204; | ||
| } | ||
| if ($request_method = 'DELETE') { | ||
| add_header 'Access-Control-Allow-Origin' '$http_origin'; | ||
| add_header 'Access-Control-Allow-Credentials' 'true'; | ||
| add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE'; | ||
| add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range'; | ||
| add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range'; | ||
| } | ||
| if ($request_method = 'PUT') { | ||
| add_header 'Access-Control-Allow-Origin' '$http_origin'; | ||
| add_header 'Access-Control-Allow-Credentials' 'true'; | ||
| add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE'; | ||
| add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range'; | ||
| add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range'; | ||
| } | ||
| if ($request_method = 'POST') { | ||
| add_header 'Access-Control-Allow-Origin' '$http_origin'; | ||
| add_header 'Access-Control-Allow-Credentials' 'true'; | ||
| add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE'; | ||
| add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range'; | ||
| add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range'; | ||
| } | ||
| if ($request_method = 'GET') { | ||
| add_header 'Access-Control-Allow-Origin' '$http_origin'; | ||
| add_header 'Access-Control-Allow-Credentials' 'true'; | ||
| add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE'; | ||
| add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range'; | ||
| add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range'; | ||
| } | ||
| } | ||
| } |
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,4 @@ | ||
| FROM osixia/openldap:1.5.0 | ||
|
|
||
| # Bootstrap LDIF is baked into the image (runs once when ldap_data volume is empty). | ||
| COPY ldap-init.ldif /container/service/slapd/assets/config/bootstrap/ldif/custom/ldap-init.ldif | ||
Oops, something went wrong.
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.
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.
osixia/openldap is unmaintained
Alternatives:
We are using 3 different LDAP alternatives...
I'd suggest to use only one implemntation, probably based to a maintained one.
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.
bitnami/openldapis private only, there seems an option to usebitnamilegacy/openldapbut it's again legacy and no better thanosixia/openldap.osixia/openldapdoes have v2 but it's in beta.Writing a custom Dockerfile and init script for building image from scratch might be too much here. Maybe a seperate
geosolutions-it/openldapwould be nice, if we plan to use dockerized ldap setups.For now i kept is the same.