我需要在我的网站上实现基于ActiveDirectory的身份验证,我正在使用gusing框架开发。作为演示,我创建了一个示例应用程序
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 Your ID and password\"");
return unauthorized("You Need to Login first");
}
return ok("Welcome to nowhere");
}这将在客户端上打开一个身份验证弹出窗口。现在,我如何访问这些凭据?
发布于 2013-05-10 15:07:22
好了,我找到答案了
String authorization = request().getHeader(AUTHORIZATION);authorization头包含base64编码形式的用户名:密码。
AUTHORIZATION = "Basic oa76dfexvdd3=="在这里,如果您解码oa76dfexvdd3==,您将得到类似于"myusr:mypwd“的内容,然后您可以使用它进行身份验证。
https://stackoverflow.com/questions/16442928
复制相似问题