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

Authentication with headers without login screen #77

Open
mark-00 opened this issue May 29, 2017 · 1 comment
Open

Authentication with headers without login screen #77

mark-00 opened this issue May 29, 2017 · 1 comment

Comments

@mark-00
Copy link

mark-00 commented May 29, 2017

In test setups we use Dancer2::Plugin::Auth::Extensible::Provider::Config and access the Dancerapp directly

In production enviroments we run Dancer2 behind an apche server. Authentication is also done by the apache server. For instance using Shibboleth. Typically the apache server sets some headers like X-Forwarded-User or X-Auth-User.

I wrote a Dancer2::Plugin::Auth::Extensible::Provider::Header that can pick up the username and roles from the headers in the request. The problem is that I don't find an entry point in the authentication code without going through a login screen. Standard a redirect to /login is done. It 's possible to change it to a post using "login_without_redirect". But I want no login screen. I just need to creat a session based on the header values

I now set the login login in the beforehook of my dancer app. But this is something that has to be added going from test to production. I want this functionality in the Dancer2::Plugin::Auth::Extensible::Provider::Header plugin. How can I implement this ?

hook 'before' => sub {
session logged_in_user => 'myusername'; # is picked up from a header.
session logged_in_user_realm => 'shibboleth';
};

get '/secure' => require_login sub {
return logged_in_user;
};

@bigpresh
Copy link
Member

Wow, this didn't get responded to for a horribly long time - sorry :(

DPAE/D2PAE were pretty much built around "the session is in a cookie" and I don't think there's anything that would be useful to you for your requirement currently; I suspect the best approach to make your kind of setup work would be a "find a session" hook, or provider method we'd check for and call if provided, which would do whatever would be reasonable to look for a session - of course the default implementation would just be "look for a session cookie", but custom providers could add other stuff, like in your instance "look for a HTTP header set by the webserver".

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

No branches or pull requests

2 participants