Caddy-Security and Multiple OIDC #252
Unanswered
TreatnHerRight
asked this question in
Q&A
Replies: 2 comments 6 replies
|
@TreatnHerRight I may be confused, but are you referring to have multiple caddy-security portals and auth policies? The way i have done this is just to setup a separate portal/policy and provider for each service that want to be seperate. |
3 replies
|
After a bit of testing here is what I got working for me. I just posted this on reddit as well: https://www.reddit.com/r/selfhosted/comments/1jdq5xn/caddy_security_pocket_id_multiple_oidc_clients_my/ {
https_port 443
debug
order crowdsec first
order authenticate before respond
order authorize before basicauth
security {
oauth identity provider private {
realm private
driver generic
client_id client-id-from-pocket-id-private # Replace with your *PRIVATE* client ID
client_secret client-secret-from-pocket-id-private # Replace with your *PRIVATE* secret
scopes openid email profile
base_auth_url [https://login.example.net/authorize](https://login.example.net/authorize) # Your Pocket ID base auth URL
metadata_url [https://login.example.net/.well-known/openid-configuration](https://login.example.net/.well-known/openid-configuration) # Your Pocket ID metadata URL
}
oauth identity provider public {
realm public
driver generic
client_id client-id-from-pocket-id-public # Replace with your *PUBLIC* client ID
client_secret client-secret-from-pocket-id-public # Replace with your *PUBLIC* secret
scopes openid email profile
base_auth_url [https://login.example.net/authorize](https://login.example.net/authorize) # Your Pocket ID base auth URL (likely the same)
metadata_url [https://login.example.net/.well-known/openid-configuration](https://login.example.net/.well-known/openid-configuration) # Your Pocket ID metadata URL (likely the same)
}
authentication portal authportal {
crypto default token lifetime 86400
enable identity provider private
enable identity provider public
transform user {
match realm private
action add role private/user
}
transform user {
match realm public
action add role public/user
}
}
authorization policy private_access {
set auth url /caddy-security/oauth2/private
allow roles private/user
# IMPORTANT: Deny all other roles to prevent bypass
deny
}
authorization policy public_access {
set auth url /caddy-security/oauth2/public
allow roles public/user
# IMPORTANT: Deny all other roles to prevent bypass
deny
}
}
crowdsec {
api_url http://Enter.Your.IP.Address:Port # Replace with your CrowdSec API URL
api_key Enter-your-api-key # Replace with your CrowdSec API key
}
}
info.example.net {
crowdsec
@mygeofilter {
maxmind_geolocation {
db_path "/srv/GeoLite2-Country.mmdb" # Path to your GeoLite2 database
allow_countries US
}
}
@auth {
path /caddy-security/*
}
route @auth {
authenticate with authportal
}
route /* {
authorize with private_access
handle @mygeofilter {
reverse_proxy 127.0.0.1:3011 # Example reverse proxy
}
}
}
example.com {
crowdsec
@mygeofilter {
maxmind_geolocation {
db_path "/srv/GeoLite2-Country.mmdb" # Path to your GeoLite2 database
allow_countries US
}
}
@auth {
path /caddy-security/*
}
route @auth {
authenticate with authportal
}
route /* {
authorize with public_access
respond "Hello world!" 200 # Example public response
#reverse_proxy 127.0.0.1:7990
}
} |
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Im having trouble getting a working multi OIDC Client Caddyfile working. To work around this, I have two instances of Pocket ID and two instances of Caddy. This is working as I wanted, but I feel this is a workaround. I would like to combine this all into one instance.
My Caddyfile is below. How can I incorporate another OIDC Client on this file? Are there any examples?
I want to have two OIDC clients so i can manage the users for each.
All reactions