hyperioxx / frontman

Frontman is an open-source API gateway written in Go that allows you to manage your microservices and expose them as a single API endpoint. It acts as a reverse proxy and handles requests from clients, routing them to the appropriate backend service.
https://frontman-labs.github.io/frontman/
GNU General Public License v3.0
5 stars 0 forks source link

ISS-18: JWT support per backend #46

Closed nhaydel closed 1 year ago

nhaydel commented 1 year ago

Still need to add tests and documentation, but I wanted to get my thoughts out there:

This PR adds configurable JWT validation per backend specified in services.yaml or redis. Backend service config now takes the following options for specifying auth requirements:

  auth:
    type: "jwt"
    userDataHeader: <expected user data header from backend> # Note: I have so far been unable to propogate the context to the backend service, so I have opted to pass user data using a header.
    jwt:
      audience: <audience>
      issuer: <issuer>
      keysUrl: <jwk url>

This auth config is optional. If not provided, requests will be forwarded normally. Steps to test:

  1. Add an auth config to one or more of your services in your services.yaml file. Ex:

    auth:
    type: "jwt"
    userDataContextKey: "user"
    jwt:
      audience: "me"
      issuer: "keycloak"
      keysUrl: "http://localhost:8080/auth/realms/demo/protocol/openid-connect/certs"
  2. Get a token from the auth server specified in the auth config

  3. Run frontman and the backend(s) to test against

  4. Make a request through frontman with and without the appropriate token.

hyperioxx commented 1 year ago

@nhaydel could you do a rebase please :)

hyperioxx commented 1 year ago

@nhaydel Looks good! just rebase, fix that test and add some more and run go fmt! Thank you dude !

simonchapman1986 commented 1 year ago

LGTM as soon as what @hyperioxx has suggested has been actioned 🔥

nhaydel commented 1 year ago

Thanks for the quick review! Rebase seems to have fixed that test. I'll format and add tests probably tomorrow

certino-simonchapman commented 1 year ago

Thanks for the quick review! Rebase seems to have fixed that test. I'll format and add tests probably tomorrow

thats always handy 🤣👌🏻

nhaydel commented 1 year ago

Sorry for all of the commits. I've formatted and written tests. Also update the mongo service registry in the same way the yaml and redis registries were updated. Should be ready for final review

hyperioxx commented 1 year ago

@nhaydel Awesome work dude !!!!!!