Replies: 5 comments 3 replies
-
Hi @ieugen But because the OPA traefik plugin is also very popular, lots of people seem to use it so it might be a good idea to implement it directly. Sorry to mention you here @cdanis , but you also have a lot of opinions about this plugin. What do you think? Feel free to reply if you want 🙂 |
Beta Was this translation helpful? Give feedback.
-
@ieugen do you have a concrete use-case you want to use it for or was this just an idea? |
Beta Was this translation helpful? Give feedback.
-
It seems I get Microsoft EntraID group ID's in the IDToken but not Access Token. This is the config I use and adds group ID's to IDToken but not access tokens
This is the OPA plugin config I use with an echo service
and the traefik router config
|
Beta Was this translation helpful? Give feedback.
-
I got OPA authorization workgin with the following configuration: Declare plugins in traefik static config: traefik.yml experimental:
plugins:
traefik-maintenance:
moduleName: github.com/TRIMM/traefik-maintenance
version: v1.0.1
traefik-oidc-auth:
moduleName: "github.com/sevensolutions/traefik-oidc-auth"
version: "v0.12.0"
open-policy-agent:
moduleName: "github.com/unsoon/traefik-open-policy-agent"
version: "v1.2.0" Configure middlewares in traefik dynamic configuration: dynamic.yml entraid-auth:
plugin:
traefik-oidc-auth:
LogLevel: DEBUG
Secret: "REDACTED" # Please change this secret for your setup
Provider:
Url: https://login.microsoftonline.com/REDACTED/v2.0
ClientId: REDACTED
ClientSecret: REDACTED
UsePkce: true
Scopes: ["openid", "profile", "email"]
Headers:
- Name: "Authorization"
Value: "{{`Bearer {{ .accessToken }}`}}"
- Name: "X-Oidc-Username"
Value: "{{`{{ .claims.preferred_username }}`}}"
- Name: X-Oidc-Groups
# Value: '{{ `{{ .claims.groups }}` }}'
Value: '{{`{{with .claims.groups}}{{ range $i, $g := . }}{{if $i}},{{end}}{{js $g}}{{end}}{{end}}`}}'
echo-demo-opa:
plugin:
open-policy-agent:
url: "http://infra1.net.drevidence.com:8181/v1/data/example/echo"
allowField: "allow"
errorResponse:
statusCode: 403
contentType: "application/json"
headers:
X-Error-Type: "authorization_failed"
body:
error: "Access denied by policy" The rego policy echo-demo.rego package example.echo
default allow = false
result := {
"group_key": "aaa" in [
"aaa",
"bbb",
"ccc"
]
}
allow if {
input.path[0] == "InfraTeam"
# user is in InfraTeam group "b925b894-6583-5de0-9397-360ae587cda2"
contains(input.headers["X-Oidc-Groups"][0],"b925b894-6583-5de0-9397-360ae587cda2")
} Sample input for CLI testing (for testing with curl HTTP it needs to be inside an {"input": } ) entra-id-groups.json {
"path": ["InfraTeamUsers", "b"],
"method": "GET",
"headers": {
"X-Oidc-Groups": [
"e7ff4b27-d5b4-4d85-b966-5df7bbccea92,b925b894-6583-4de0-9397-360ae587cda3,f1c30196-9289-410c-b813-4c6cca9db70d,b6838d9b-f8aa-4629-8e99-082fd05f232d"
]
}
} Local rego testing: I think this can be closed, and people/you can use this as documentation. |
Beta Was this translation helpful? Give feedback.
-
Hi @ieugen If you think this example config can be helpful for others too i would very much appreciate it if you submit a PR for documenting it in the config samples area of the documentation page. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I would love to see support for OpenPolicyAgent policies https://www.openpolicyagent.org/ .
I'm currently trying to implement authentication and authorization via OpenID Connect to protect static web pages.
But for this I need a way to trigger OpenID Connect authentication AND OpenPolicyAgent policies in the same place.
Static pages don't do the OpenID Connect dance and don't send the token.
So I am exploring Oauth2 proxy to handle OIDC and a OPA plugin traefik plugin to handle the policies https://github.com/unsoon/traefik-open-policy-agent .
OPA would be really cool to be supported.
Looking forward to hear your thoughts on this.
Thanks,
Eugen
Beta Was this translation helpful? Give feedback.
All reactions