You've already forked oauth2-proxy
mirror of
https://github.com/oauth2-proxy/oauth2-proxy.git
synced 2025-07-15 01:44:22 +02:00
Add Keycloak local testing environment (#604)
* Adding one more example - keycloak - alongside with dex IDP. * don't expose keycloak and proxy ports to the host * specify email-domain list option in documentation * get rid of nginx and socat to simplify the example as per https://github.com/oauth2-proxy/oauth2-proxy/pull/604#issuecomment-640054390 * get rid of the scripts - use static file for keycloak startup * changelog entry * Update CHANGELOG.md Co-authored-by: Joel Speed <Joel.speed@hotmail.co.uk>
This commit is contained in:
@ -55,6 +55,7 @@
|
|||||||
|
|
||||||
## Changes since v5.1.1
|
## Changes since v5.1.1
|
||||||
|
|
||||||
|
- [#604](https://github.com/oauth2-proxy/oauth2-proxy/pull/604) Add Keycloak local testing environment (@EvgeniGordeev)
|
||||||
- [#539](https://github.com/oauth2-proxy/oauth2-proxy/pull/539) Refactor encryption ciphers and add AES-GCM support (@NickMeves)
|
- [#539](https://github.com/oauth2-proxy/oauth2-proxy/pull/539) Refactor encryption ciphers and add AES-GCM support (@NickMeves)
|
||||||
- [#601](https://github.com/oauth2-proxy/oauth2-proxy/pull/601) Ensure decrypted user/email are valid UTF8 (@JoelSpeed)
|
- [#601](https://github.com/oauth2-proxy/oauth2-proxy/pull/601) Ensure decrypted user/email are valid UTF8 (@JoelSpeed)
|
||||||
- [#560](https://github.com/oauth2-proxy/oauth2-proxy/pull/560) Fallback to UserInfo is User ID claim not present (@JoelSpeed)
|
- [#560](https://github.com/oauth2-proxy/oauth2-proxy/pull/560) Fallback to UserInfo is User ID claim not present (@JoelSpeed)
|
||||||
|
@ -13,3 +13,11 @@ nginx-up:
|
|||||||
.PHONY: nginx-%
|
.PHONY: nginx-%
|
||||||
nginx-%:
|
nginx-%:
|
||||||
docker-compose -f docker-compose.yaml -f docker-compose-nginx.yaml $*
|
docker-compose -f docker-compose.yaml -f docker-compose-nginx.yaml $*
|
||||||
|
|
||||||
|
.PHONY: keycloak-up
|
||||||
|
keycloak-up:
|
||||||
|
docker-compose -f docker-compose-keycloak.yaml up -d
|
||||||
|
|
||||||
|
.PHONY: keycloak-%
|
||||||
|
keycloak-%:
|
||||||
|
docker-compose -f docker-compose-keycloak.yaml $*
|
||||||
|
70
contrib/local-environment/docker-compose-keycloak.yaml
Normal file
70
contrib/local-environment/docker-compose-keycloak.yaml
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
# This docker-compose file can be used to bring up an example instance of oauth2-proxy
|
||||||
|
# for manual testing and exploration of features.
|
||||||
|
# Alongside OAuth2-Proxy, this file also starts Keycloak to act as the identity provider,
|
||||||
|
# HTTPBin as an example upstream.
|
||||||
|
#
|
||||||
|
# This can either be created using docker-compose
|
||||||
|
# docker-compose -f docker-compose-keycloak.yaml <command>
|
||||||
|
# Or:
|
||||||
|
# make keycloak-<command> (eg. make keycloak-up, make keycloak-down)
|
||||||
|
#
|
||||||
|
# Access http://oauth2-proxy.localtest.me:4180 to initiate a login cycle using user=admin@example.com, password=password
|
||||||
|
# Access http://keycloak.localtest.me:9080 with the same credentials to check out the settings
|
||||||
|
version: '3.0'
|
||||||
|
services:
|
||||||
|
|
||||||
|
oauth2-proxy:
|
||||||
|
container_name: oauth2-proxy
|
||||||
|
image: quay.io/oauth2-proxy/oauth2-proxy:v5.1.1
|
||||||
|
command: --config /oauth2-proxy.cfg
|
||||||
|
hostname: oauth2-proxy
|
||||||
|
volumes:
|
||||||
|
- "./oauth2-proxy-keycloak.cfg:/oauth2-proxy.cfg"
|
||||||
|
restart: unless-stopped
|
||||||
|
networks:
|
||||||
|
keycloak: {}
|
||||||
|
httpbin: {}
|
||||||
|
oauth2-proxy: {}
|
||||||
|
depends_on:
|
||||||
|
- httpbin
|
||||||
|
- keycloak
|
||||||
|
ports:
|
||||||
|
- 4180:4180/tcp
|
||||||
|
|
||||||
|
httpbin:
|
||||||
|
container_name: httpbin
|
||||||
|
image: kennethreitz/httpbin:latest
|
||||||
|
hostname: httpbin
|
||||||
|
networks:
|
||||||
|
httpbin: {}
|
||||||
|
|
||||||
|
keycloak:
|
||||||
|
container_name: keycloak
|
||||||
|
image: jboss/keycloak:10.0.0
|
||||||
|
hostname: keycloak
|
||||||
|
command:
|
||||||
|
[
|
||||||
|
'-b',
|
||||||
|
'0.0.0.0',
|
||||||
|
'-Djboss.socket.binding.port-offset=1000',
|
||||||
|
'-Dkeycloak.migration.action=import',
|
||||||
|
'-Dkeycloak.migration.provider=dir',
|
||||||
|
'-Dkeycloak.migration.dir=/realm-config',
|
||||||
|
'-Dkeycloak.migration.strategy=IGNORE_EXISTING',
|
||||||
|
]
|
||||||
|
volumes:
|
||||||
|
- ./keycloak:/realm-config
|
||||||
|
environment:
|
||||||
|
KEYCLOAK_USER: admin@example.com
|
||||||
|
KEYCLOAK_PASSWORD: password
|
||||||
|
networks:
|
||||||
|
keycloak:
|
||||||
|
aliases:
|
||||||
|
- keycloak.localtest.me
|
||||||
|
ports:
|
||||||
|
- 9080:9080/tcp
|
||||||
|
|
||||||
|
networks:
|
||||||
|
httpbin: {}
|
||||||
|
keycloak: {}
|
||||||
|
oauth2-proxy: {}
|
1684
contrib/local-environment/keycloak/master-realm.json
Normal file
1684
contrib/local-environment/keycloak/master-realm.json
Normal file
File diff suppressed because it is too large
Load Diff
27
contrib/local-environment/keycloak/master-users-0.json
Normal file
27
contrib/local-environment/keycloak/master-users-0.json
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"realm" : "master",
|
||||||
|
"users" : [ {
|
||||||
|
"id" : "3356c0a0-d4d5-4436-9c5a-2299c71c08ec",
|
||||||
|
"createdTimestamp" : 1591297959169,
|
||||||
|
"username" : "admin@example.com",
|
||||||
|
"email" : "admin@example.com",
|
||||||
|
"enabled" : true,
|
||||||
|
"totp" : false,
|
||||||
|
"emailVerified" : true,
|
||||||
|
"credentials" : [ {
|
||||||
|
"id" : "a1a06ecd-fdc0-4e67-92cd-2da22d724e32",
|
||||||
|
"type" : "password",
|
||||||
|
"createdDate" : 1591297959315,
|
||||||
|
"secretData" : "{\"value\":\"6rt5zuqHVHopvd0FTFE0CYadXTtzY0mDY2BrqnNQGS51/7DfMJeGgj0roNnGMGvDv30imErNmiSOYl+cL9jiIA==\",\"salt\":\"LI0kqr09JB7J9wvr2Hxzzg==\"}",
|
||||||
|
"credentialData" : "{\"hashIterations\":27500,\"algorithm\":\"pbkdf2-sha256\"}"
|
||||||
|
} ],
|
||||||
|
"disableableCredentialTypes" : [ ],
|
||||||
|
"requiredActions" : [ ],
|
||||||
|
"realmRoles" : [ "offline_access", "admin", "uma_authorization" ],
|
||||||
|
"clientRoles" : {
|
||||||
|
"account" : [ "view-profile", "manage-account" ]
|
||||||
|
},
|
||||||
|
"notBefore" : 0,
|
||||||
|
"groups" : [ ]
|
||||||
|
} ]
|
||||||
|
}
|
20
contrib/local-environment/oauth2-proxy-keycloak.cfg
Normal file
20
contrib/local-environment/oauth2-proxy-keycloak.cfg
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
http_address="0.0.0.0:4180"
|
||||||
|
cookie_secret="OQINaROshtE9TcZkNAm-5Zs2Pv3xaWytBmc5W7sPX7w="
|
||||||
|
email_domains=["example.com"]
|
||||||
|
cookie_secure="false"
|
||||||
|
upstreams="http://httpbin"
|
||||||
|
cookie_domains=[".localtest.me"] # Required so cookie can be read on all subdomains.
|
||||||
|
whitelist_domains=[".localtest.me"] # Required to allow redirection back to original requested target.
|
||||||
|
|
||||||
|
# keycloak provider
|
||||||
|
client_secret="72341b6d-7065-4518-a0e4-50ee15025608"
|
||||||
|
client_id="oauth2-proxy"
|
||||||
|
redirect_url="http://oauth2-proxy.localtest.me:4180/oauth2/callback"
|
||||||
|
|
||||||
|
# in this case oauth2-proxy is going to visit
|
||||||
|
# http://keycloak.localtest.me:9080/auth/realms/master/.well-known/openid-configuration for configuration
|
||||||
|
oidc_issuer_url="http://keycloak.localtest.me:9080/auth/realms/master"
|
||||||
|
provider="oidc"
|
||||||
|
provider_display_name="Keycloak"
|
||||||
|
|
||||||
|
|
@ -44,7 +44,7 @@ An example [oauth2-proxy.cfg]({{ site.gitweb }}/contrib/oauth2-proxy.cfg.example
|
|||||||
| `--cookie-samesite` | string | set SameSite cookie attribute (ie: `"lax"`, `"strict"`, `"none"`, or `""`). | `""` |
|
| `--cookie-samesite` | string | set SameSite cookie attribute (ie: `"lax"`, `"strict"`, `"none"`, or `""`). | `""` |
|
||||||
| `--custom-templates-dir` | string | path to custom html templates | |
|
| `--custom-templates-dir` | string | path to custom html templates | |
|
||||||
| `--display-htpasswd-form` | bool | display username / password login form if an htpasswd file is provided | true |
|
| `--display-htpasswd-form` | bool | display username / password login form if an htpasswd file is provided | true |
|
||||||
| `--email-domain` | string | authenticate emails with the specified domain (may be given multiple times). Use `*` to authenticate any email | |
|
| `--email-domain` | string \| list | authenticate emails with the specified domain (may be given multiple times). Use `*` to authenticate any email | |
|
||||||
| `--extra-jwt-issuers` | string | if `--skip-jwt-bearer-tokens` is set, a list of extra JWT `issuer=audience` pairs (where the issuer URL has a `.well-known/openid-configuration` or a `.well-known/jwks.json`) | |
|
| `--extra-jwt-issuers` | string | if `--skip-jwt-bearer-tokens` is set, a list of extra JWT `issuer=audience` pairs (where the issuer URL has a `.well-known/openid-configuration` or a `.well-known/jwks.json`) | |
|
||||||
| `--exclude-logging-paths` | string | comma separated list of paths to exclude from logging, eg: `"/ping,/path2"` |`""` (no paths excluded) |
|
| `--exclude-logging-paths` | string | comma separated list of paths to exclude from logging, eg: `"/ping,/path2"` |`""` (no paths excluded) |
|
||||||
| `--flush-interval` | duration | period between flushing response buffers when streaming responses | `"1s"` |
|
| `--flush-interval` | duration | period between flushing response buffers when streaming responses | `"1s"` |
|
||||||
|
Reference in New Issue
Block a user