-
Notifications
You must be signed in to change notification settings - Fork 13
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
Support user defined jwt auth and sdk functions #405
Support user defined jwt auth and sdk functions #405
Conversation
Just a note about the prod workflow comment:
That's fine for now, but we'll want to change this soon when we add endpoint configuration to the manifest, such that if an endpoint is configured for authentication, and it's running in a non-dev environment without keys supplied, that we log a fatal error and exit - because such a configuration should not be allowed. Alternatively, we could not exit, but just not start that endpoint. We'll have to see which makes the most sense. |
Also a note about:
Agreed. And this should already be mitigated by #439 |
Description
This PR adds jwt auth support for the modus runtime. This works by specifying a golang deserializable map of RSA PEMs as environment variables, named
MODUS_RSA_PEMS
. When available, the runtime will force any incoming api request to be verified by one of the specified RSA keys. Then the claims from the jwt are stored in the environment variables, to be accessed by the user via sdk functions. However, the dev and production flows are different.Dev Flow
If in Dev mode, and no RSA keys are provided, but a JWT is provided, we will assume the user is attempting to test their jwt claims, without going through the process of verification & refreshing the tokens (however if this turns out to be a problem we can remove this functionality easily). Therefore we will run a ParseUnverified. to retrieve the claims and store.
WARNING: Please do not run your runtime in dev mode in a production environment.
Prod Flow
If in Prod mode, and no RSA keys are provided, no matter what the request will be allowed through, and the JWT will NOT be stored.
SDK Functions
the user is provided with
auth.GetJWTClaims<T>
as the function to retrieve the claims. It allows the user to pass in structure to deserialize the claims json string into, or just pass string for T to get the raw claims string.