playframework 2.0 - How to access credentials passed in the authentication popup for a 401 response -
i need implement activedirectory based authentication on site developin gusing play framework. demo, created sample app
public static result index() { boolean isloggedin = false; string authorization = request().getheader(authorization); if(!isloggedin) { string usrnm = request().username(); response().setheader(www_authenticate, "basic realm=\"enter id , password\""); return unauthorized("you need login first"); } return ok("welcome nowhere"); }
this opens authentication popup on client. now, how access these credentials?
ok, found answer
string authorization = request().getheader(authorization);
the authorization header contains username:password in base64 encoded form.
authorization = "basic oa76dfexvdd3=="
here, if decode oa76dfexvdd3==
, "myusr:mypwd", can use authentication.
Comments
Post a Comment