wwwlicious / servicestack-authentication-identityserver

A plugin for ServiceStack and IdentityServer that provides OpenIDConnect / OAuth 2.0 Single Sign-On Authentication
Other
29 stars 15 forks source link

IdentityServerAuthProvider not implementing IAuthWithRequest? #21

Open stackedbitz opened 5 years ago

stackedbitz commented 5 years ago

It's convenient to have pre-authentication occur at the same time a secured request is made, especially when using a client like Postman, else one has to a call to /auth/IdentityServer before making another to the desired service call.

Is there any reason why you chose not to add IAuthWithRequest, which requires the implementation of PreAuthenticate(req, res), as an interface for IdentityServerAuthProvider?

stackedbitz commented 5 years ago

Furthermore, would you be open to a PR having IdentityServerAuthProvider implement IAuthWithRequest with:

public void PreAuthenticate(IRequest req, IResponse res)
        {
            var bearerToken = req.GetBearerToken();
            var authService = req.TryResolve<AuthenticateService>();
            authService.Request = req;

            Authenticate(authService, req.GetSession(), new Authenticate
            {
                provider = Name,
                oauth_token = bearerToken
            });
        }