Skip to content

Support multiple authenticators with path matching#52

Open
philipgough wants to merge 6 commits intorhobs-obs-api-konfluxfrom
multi-auth-safe
Open

Support multiple authenticators with path matching#52
philipgough wants to merge 6 commits intorhobs-obs-api-konfluxfrom
multi-auth-safe

Conversation

@philipgough
Copy link
Copy Markdown

What

Although the proxy allowed an end user to configure multiple authenticators, at runtime, only one was selected in order of preference.

This change allows support for multiple authenticators.
The default behaviour remains intact.
Optionally, users can specify paths which should not match for specific authenticators.
It also adds middleware that ensures that at least one authenticator has run in order to support users not mistakingly bypassing auth with their configuration.

Furthermore, this change sets up an environment similar to what we have in RHOBS Cell in a KinD cluster.
This utility was badly needed in any case to facilitate the testing of auth which was practically non-existent or difficult to hook into.

It generates a simple configuration that splits read and write for logs and metrics on oidc for read and mtls for write respectively.

Key points to note that if you want optional mtls the api needs to be passed the - --tls.client-auth-type=RequestClientCert flag that already existed prior to this change.

From the working test, here is a sample of what a tenants config for multi-auth will look like

tenants:
- name: auth-tenant
  id: "1610702597"
  oidc:
    clientID: observatorium-api
    clientSecret: ZXhhbXBsZS1hcHAtc2VjcmV0
    issuerURL: http://dex.proxy.svc.cluster.local:5556/dex
    redirectURL: http://localhost:8080/oidc/auth-tenant/callback
    usernameClaim: email
    paths:
    - operator: "!~"
      pattern: ".*(loki/api/v1/push|api/v1/receive).*"
  mTLS:
    caPath: /etc/certs/ca.crt
    paths:
    - operator: "=~"
      pattern: ".*(api/v1/receive).*"
    - operator: "=~"
      pattern: ".*(loki/api/v1/push).*"

// for the given list of tenants. Otherwise, it returns an error.
// It protects the Prometheus remote write and Loki push endpoints. The tracing endpoint is not protected because
// it goes through the gRPC middleware stack, which behaves differently from the HTTP one.
func EnforceAccessTokenPresentOnSignalWrite(oidcTenants map[string]struct{}) func(http.Handler) http.Handler {
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i really dont understand why this was here. it was enforcing oidc on all write requests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant