-
Notifications
You must be signed in to change notification settings - Fork 27
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
Integrate with oathkeeper via forward-auth
interface
#275
Integrate with oathkeeper via forward-auth
interface
#275
Conversation
Thanks Natalia, will review when I have time after/during the sprint (or probably next week we can go through it together if you like). |
In order to make it clear that the feature is untested and might be unstable/experimental, we should rename the endpoint to For now you'll have to do Secondly, we will only enable the experimental forward auth feature behind a feature flag. If you relate traefik to oathkeeper but |
Wouldn't it be enough to have the feature flag as a juju config? I'd prefer to avoid renaming the relation. |
We don't have to rename the interface, only the endpoint. That seems like a minor change. |
c8702ce
to
f080bed
Compare
915e008
to
9d3bbc4
Compare
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.
A couple of points regarding the API changes made to the Traefik class, but the rest looks good to me!
Tested successfully with the bundle below.
@natalian98 do we have issues open to capture the gaps currently addressed by:
bundle: kubernetes
applications:
ok:
# From https://github.com/canonical/oathkeeper-operator
# 1e23771 - (HEAD -> address-forward-auth-comments, origin/address-forward-auth-comments) refactor
charm: ./oathkeeper-operator/oathkeeper_ubuntu-22.04-amd64.charm
scale: 1
constraints: arch=amd64
trust: true
resources:
oci-image: "ghcr.io/canonical/oathkeeper:0.40.6"
options:
# until tls is impl'd dev mode would resort to http decisions url
dev: true
trfk:
# From https://github.com/canonical/traefik-k8s-operator/pull/275
# cc35a85 - (HEAD -> IAM-500-forward-auth-relation-implementation, natalian98/IAM-500-forward-auth-relation-implementation) refactor: add experimental_forward_auth_enabled as an init arg
charm: ./traefik-k8s-operator/traefik-k8s_ubuntu-20.04-amd64.charm
series: focal
scale: 1
constraints: arch=amd64
storage:
configurations: kubernetes,1,1024M
trust: true
resources:
traefik-image: "docker.io/ubuntu/traefik:2-22.04"
options:
enable_experimental_forward_auth: true
zinc:
# From https://github.com/natalian98/zinc-k8s-operator
# 0c19865 - (HEAD -> test-proxy-interfaces, origin/test-proxy-interfaces) fix: auth-proxy
charm: ./zinc-k8s-operator/zinc-k8s_ubuntu-22.04-amd64.charm
scale: 1
constraints: arch=amd64
storage:
data: kubernetes,1,1024M
trust: true
resources:
zinc-image: "ghcr.io/jnsgruk/zinc:0.4.9"
relations:
- - ok:forward-auth
- trfk:experimental-forward-auth
- - ok:auth-proxy
- zinc:auth-proxy
- - zinc:ingress
- trfk:ingress |
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.
Thanks @natalian98, this is looking great.
Just a few final questions mostly.
tests/integration/testers/forward-auth/lib/charms/oathkeeper/v0/auth_proxy.py
Outdated
Show resolved
Hide resolved
e149762
to
e50fc27
Compare
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.
Well done @natalian98, thank you for the stellar patience and persistence!
Issue
This PR adds integration with Oathkeeper - the policy decision point in Identity and Access Proxy architecture, by supporting a new
forwardAuth
middleware.In order to integrate Traefik into IAP, it must update routing rules for the applications that requested to be protected with the
ForwardAuth
middleware. Its definition must include headers and oathkeeper's decisions address.Solution
This PR integrates traefik with oathkeeper with the use of
forward-auth
interface.Oathkeeper provides Traefik with its decisions address, allowed return headers and application names that requested the IAP protection. This information is processed by Oathkeeper from
auth-proxy
relation.Traefik updates the relation databag with app names it provides ingress for, so that Oathkeeper can compare the app names and evaluate if they can be protected using forwardAuth.
If an app is related with
ingress-per-app/leader/unit
, Traefik will update its routes and add the middleware.Context
Traefik ForwardAuth upstream docs
IAP interfaces design
Testing Instructions
As
forward-auth
relies onauth-proxy
relation data, I'm using zinc-k8s from this branch as a dummy example to test that the relation data is then transferred to traefik.Oathkeeper is built from this branch.
At this point, if zinc was not related to ingress, oathkeeper will get blocked with message
zinc-k8s is not related via ingress
.After you relate zinc with ingress, oathkeeper will get active:
juju ssh --container traefik traefik-ingress/0 bash cd /opt/traefik/juju/
Zinc route should define and reference the middleware:
Release Notes
forward-auth
integration with oathkeeper