Hi,
I have a requirement to implement a number of custom two-step authentication scenarios and would like to try and encapsulate them into a library for reuse between a number of different applications.
I am describing one below but there are several, all slightly different in formats/payloads and req/res requirements.
An incoming request contains a data payload. This data payload needs to be validated, any credentials in the payload authenticated or digital signatures verified.
A custom response needs to be serialised back to the client containing a pre-authenicated url
(no control over how that url is called in terms of verb, cookies or headers unfortunately so will be a GET request)
I’ve implemented a plugin which takes care of registering a service + some provider config options and dependencies, requestbinders for DTO custom deserialization and the validators for the incoming DTO’s
From the service, I can send an Authenicate { provider = "myprovider" Username="" Password="" }
request to my custom authprovider via the gateway.
The authprovider picks up various configuration options and defaults, combines with my services authentication request, the original incoming DTO containing the payload and populates a custom session.
I also have a JWTAuthProvider registered in my AppHost project (with allowqueryparam options set) so my authenticate request returns a bearer token for me to append to a url and therefore get a preauthenicated url.
The preauth url is picked up by the JWTAuthProvider, verified and authenicated first.
It then hits my custom auth service endpoint.
The token is the converted into a session token cookie ‘ss-tok’ before finally redirecting the client to the secure content or
serializing the response back into whatever format is required depending on the authprovider.
…
The incoming request using this preauth url is not certain to be the original caller so no cookies etc can be relied upon and it requires the information that was sent in the initial request.
…
It doesn’t feel right though and there are a number of issues.
First of all, am I missing a trick here … the why are you not just doing/using…
Second, if not, I have a few questions which I hoping some helpful soul can nudge me in the right direction.
Questions:
-
Is there are nice way to register a custom AuthProvider to the AuthFeature from with a plugin?
-
Ideally the token should be single use, invalidated once redeemed. How can I invalidate the JWT and either a) get a new one or b) reconnect to the session populated in the initial request? (could perhaps just stash it in the cache I suppose)
-
JWT sessions are rehydrated from the payload, the payload doesn’t contain the various different data payloads I need to support and some are quite large, I’m not sure it would be practical to have this information in the JWT and there are numerous different payloads required.
-
I’m fine with using sessions and throwing away the JWT after it has been redeemed but I cannot seem to reload/reconnect to the session that was created/populated in the AuthProvider and therefore the information sent in the initial request is lost.
-
I would prefer to use custom sessions or JWT payload rather than have to customise the custom userauth tables and the information is scoped per session rather than per user anyway.
Hope that makes some kind of sense…!
Thanks in advance.