Skip to content
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

Adding the option to use the 'response' attirbute of server.auth.scheme #140

Merged
merged 2 commits into from
Feb 4, 2016

Conversation

jppellerin
Copy link

http://hapijs.com/api#serverauthschemename-scheme

This addition will allow to use the hapi-auth-jwt2 plugin to leverage the response attribute of the hapi api (see link above).

Using this strategy something like so is now feasible :

...
server.auth.strategy('jwt', 'jwt', true,
{
    key: "sshhhh",
    validateFunc: validate,
    verifyOptions: {
        algorithms: [ 'HS256' ]
    },
    responseFunc: function(request, reply) {
        request.response.header('new-header', 'added here');
    }
});
...

@nelsonic
Copy link
Member

nelsonic commented Feb 1, 2016

@jppellerin did someone request this feature or are you planning on using it in your projects?
would you mind creating a test to exercise this new functionality and add it to your branch/PR ?

@jppellerin
Copy link
Author

@nelsonic Tests are added. Thoughts?

@nelsonic
Copy link
Member

nelsonic commented Feb 4, 2016

@jppellerin looks good.
this feature has not been requested by anyone in the issues or gitter,
but if you are going to use it in your projects we can merge it in. 👍

@nelsonic
Copy link
Member

nelsonic commented Feb 4, 2016

The most important thing is that existing users of the plugin will not have to make any modifications to their existing code. and unless their server calls the response method they will not even know this feature is available...

nelsonic added a commit that referenced this pull request Feb 4, 2016
Adding the option to use the 'response' attirbute of server.auth.scheme
@nelsonic nelsonic merged commit 7ed787f into dwyl:master Feb 4, 2016
@jppellerin
Copy link
Author

Thank you. Yes, that was the desired outcome. Where we can add that feature without affecting anything else. We are using it - and thus I implemented the feature. Thought I'd contribute it back in case anyone was in our situation.

The use case is that we are using tokens for our web app authentication. We are sending a refreshed version of the token back through the authorization header to keep the session alive if the user is still active. This was the cleanest way of doing it. If not we were stuck changing our response objects.

@nelsonic
Copy link
Member

nelsonic commented Feb 4, 2016

@jppellerin agreed.
I will be preparing the release notes tonight. 👍

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

Successfully merging this pull request may close these issues.

None yet

2 participants