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

Custom login with json #135

Closed
anssirantanen opened this issue Jun 3, 2015 · 1 comment
Closed

Custom login with json #135

anssirantanen opened this issue Jun 3, 2015 · 1 comment

Comments

@anssirantanen
Copy link

Hi i have playframework project and i need to implement authorization for it.
I have copied basic example structure and experimented with it, so far i havent found answer for my problem. I have predefined specs for handling requests and results.
Login controller takes in username and account in json format after that code will authenticate posted username and will return acount object if password matches (just like in basic example). After that problem arises. I have no idea how to offer authentication cookie as response. so far i have tried to use
gotoLoginSucceeded method but because my lack of knowledge i haven't configured StartNewSession and it will throw Assertionerror (as it should). Every example returns webpage in controller, but my specs forces frontend and back end to be separated so i cant redirect as response. How i should send the cookie in this case?

@gakuzzzz
Copy link
Member

gakuzzzz commented Jun 4, 2015

Default implementation use cookie.
However you can change this behavior by creating custom TokenAccessor.

There is an example of HTTP Basic authentication.
https://github.com/t2v/play2-auth/blob/09a08e2877df34b16afe032a0a05450bcf34ee03/sample/app/controllers/basic/BasicAuthTokenAccessor.scala
(It does not add auth token into response, your TokenAccessor can add auth token into response header)

@gakuzzzz gakuzzzz closed this as completed Jul 6, 2015
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