Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Perl Dancer Auth Solution that Supports API Keys?

I have a dancer web application that is part web-site and part web-service; certain routes on my application should have auth on them.

All the auth solutions I've found for a Dancer web app require the redirection to a login page; while this is okay for interactive use, this isn't optimal for a restful web service.

Is there an auth solution that would allow for something like api keys?

like image 898
Blaskovicz Avatar asked Nov 04 '22 02:11

Blaskovicz


1 Answers

You should have look at Dancer::Plugin::Auth::Extensible to build this. The most simple way it to send credentials in each request. On the client, you'd be calling your REST service like this:

$ua->post('http://example.com/rest/getStuff?cred=foobar1234567, $search_criteria);

If you do it like this, you could provide a cookie, but you do not have to, and the customer would not necessarily need to care about the cookie.

Edit: If you want Basic Authentication, take a look at Plack::Builder. You can use it to add the auth to certain requests.

like image 68
simbabque Avatar answered Nov 15 '22 11:11

simbabque