我使用基本的HTTP身份验证通过基本的LDAP授权改进了我的GWT/GXT应用程序.当我启动新浏览器时,它运行良好 - 我得到提示并获得对公司LDAP的授权.我的问题 - 除非我关闭/重新打开浏览器,否则我无法注销.我可以调试并查看如何SecurityContextLogoutHandler#logout调用以及执行以下代码
if (invalidateHttpSession) {
HttpSession session = request.getSession(false);
if (session != null) {
session.invalidate();
}
}
SecurityContextHolder.clearContext();
Run Code Online (Sandbox Code Playgroud)
然而,它似乎没有影响,因为网站被重新加载,我永远不会得到另一个HTTP身份验证提示,除非我重新启动浏览器(甚至清除缓存/ cookie将无济于事).这是applicationContext.xml的相关部分
<security:http auto-config='true'>
<security:intercept-url pattern="/reports/**" access="ROLE_USER" />
<security:http-basic />
<security:logout logout-url="/reports/logout"
logout-success-url="/reports/Application.html" />
</security:http>
Run Code Online (Sandbox Code Playgroud)
我试图定义自定义LogoutSuccessHandler,做authentication.setAuthenticated(false);,但也没有任何影响
这里有什么东西我在这里不见了?非常感谢您的帮助
最近,我一直致力于为我的Web应用程序实现安全性,在Glassfish v3上运行.我通过设置如下基本身份验证成功地设法保护了一些资源:
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>vcards-admin</realm-name>
</login-config>
Run Code Online (Sandbox Code Playgroud)
现在我想知道如何在登录提示符上引入用户名来定义用户的实际数据.我认为可能有一个会话属性来获取该数据,但我不知道它是哪一个.
我对会话属性有误吗?有没有其他方法来访问该登录信息?
提前致谢.
是否可以像在Apache中一样在Node.js中执行基本身份验证?
http://doc.norang.ca/apache-basic-auth.html
我知道如果使用Express或Connect我可以添加中间件功能并进行用户验证,但我试图限制整个区域(我不需要从数据库中验证用户只是几个已定义的用户) - 我正在使用Ubuntu.
https://github.com/kaero/node-http-digest
这是我能做的,但我不确定"暴露"或直接在代码中写入用户和密码是否足够安全.
非常感谢.
javascript authentication ubuntu basic-authentication node.js
我想在我的asmx Web服务中使用用户名和密码验证来实现基本身份验证.
我不想使用WCF,我知道这不是安全的方式,但我需要使用基本身份验证而不使用https.
我的网络服务是这样的:
[WebService(Namespace = "http://www.mywebsite.com/")]
public class Service1
{
[WebMethod]
public string HelloWorld()
{
return "Hello world";
}
}
Run Code Online (Sandbox Code Playgroud)
我使用这个自定义HttpModule:
public class BasicAuthHttpModule : IHttpModule
{
void IHttpModule.Init(HttpApplication context)
{
context.AuthenticateRequest += new EventHandler(OnAuthenticateRequest);
}
void OnAuthenticateRequest(object sender, EventArgs e)
{
string header = HttpContext.Current.Request.Headers["Authorization"];
if (header != null && header.StartsWith("Basic")) //if has header
{
string encodedUserPass = header.Substring(6).Trim(); //remove the "Basic"
Encoding encoding = Encoding.GetEncoding("iso-8859-1");
string userPass = encoding.GetString(Convert.FromBase64String(encodedUserPass));
string[] credentials = userPass.Split(':');
string username …Run Code Online (Sandbox Code Playgroud) 这是我到目前为止所实现的:
$('#btnSignIn').click(function () {
var username = $("#username").val();
var password = $("#password").val();
function make_base_auth(user, password) {
var tok = user + ':' + password;
var final = "Basic " + $.base64.encode(tok);
console.log("FINAL---->" + final);
alert("FINAL---->" + final);
return final;
}
$.ajax({
type: "GET",
contentType: "application/json",
url: "http://localhost:8080/SesameService/webresources/users/secured/login",
crossDomain: true,
dataType: "text",
async: false,
data: {},
beforeSend: function (xhr) {
xhr.setRequestHeader('authorization', make_base_auth(username, password));
},
success: function () {
alert('Thanks for your signin in! '); …Run Code Online (Sandbox Code Playgroud) 所以我一直在使用DotNetOpenAuth一段时间,今天我需要添加对提供程序的支持,迫使我发送带有基本身份验证的密钥(我一直在使用旧版本,只有Post参数)
我试过用ClientCredentialApplicator.NetworkCredential,它没用.然后根据这里的建议,我已经做了我自己的ClientCredentialApplicator.
我仍然没有工作,我把断点放进去ApplyClientCredential,他们从来没有打过.
我升级到最新版本(4.3.0.0),应该有这个修复.
一切正常,但没有Authorization标题,远程服务器回答301错误(这让我认为它与提交相同的问题 - 授权信息未添加到请求,直到服务器回答Unauthorized和我正在使用的提供程序当没有Authorization标题时回答301
c# basic-authentication dotnetopenauth networkcredentials oauth-2.0
如果包含Basic auth,预检HTTP请求会如何?喜欢以下对话?我无法理解哪些标头需要发送到哪里,也因为无法使用Firebug正确调试它
客户:
OPTIONS /api/resource HTTP/1.1
Access-Control-Request-Method: GET
Origin: http://jsconsole.com
Run Code Online (Sandbox Code Playgroud)
服务器:
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, GET, PUT, DELETE
Access-Control-Allow-Headers: Authorization
Access-Control-Max-Age: 1728000
Access-Control-Allow-Credentials: true
Run Code Online (Sandbox Code Playgroud)
客户:
GET /api/resource HTTP/1.1
Access-Control-Request-Method: GET
Access-Control-Allow-Credentials: true
Origin: http://jsconsole.com
Run Code Online (Sandbox Code Playgroud)
服务器:
HTTP/1.1 401 Unauthorized
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, GET, PUT, DELETE
Access-Control-Allow-Headers: Authorization
Access-Control-Max-Age: 1728000
Access-Control-Allow-Credentials: true
WWW-Authenticate: Basic realm="Authorisation Required"
Run Code Online (Sandbox Code Playgroud)
客户:
GET /api/resource HTTP/1.1
Access-Control-Allow-Credentials: true
Authorization: Basic base64encodedUserAndPassword
Access-Control-Request-Method: GET
Origin: http://jsconsole.com
Run Code Online (Sandbox Code Playgroud)
服务器:
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, GET, …Run Code Online (Sandbox Code Playgroud) web-applications http basic-authentication cors asp.net-web-api
我正在使用基本身份验证来保护仅在公司网络内部公开的一组WCF Web服务,我想知道当Web服务返回401时,是否有办法触发浏览器的凭据对话框从AJAX调用中显示错误?
目前,我的AJAX调用将401作为常规失败请求接收,并且不会提示浏览器执行任何操作.但是,如果我使用相同的URI并将其复制粘贴到浏览器的URL栏中,则返回的401会正确触发"基本身份验证"对话框.
有没有办法让AJAX回调告诉浏览器弹出该对话框?
我试图在开发的早期阶段从休闲窥探的眼睛保护网站.通过HTTPS的基本身份验证似乎是一个合理的解决方案,但服务工作者的存在似乎阻止它在Chrome中工作.如果已经安装了serviceworker,但浏览器没有对所需领域的主动授权,则会发生这种情况.
Chrome显示网络时间轴中的响应为401
并且还显示浏览器选项卡正在接收正确的响应标头:
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Basic realm="My realm"
Date: Tue, 21 Jun 2016 03:09:35 GMT
Connection: close
Cache-Control: no-cache
Run Code Online (Sandbox Code Playgroud)
但它没有提示登录,它只显示401响应的内容正文.
这是Chrome错误,还是我的ServiceWorker可能有问题?
javascript google-chrome basic-authentication service-worker
我们构建了一个非常"纯粹"的RESTful服务器,它使用HTTP BASIC AUTHENTICATION.这意味着客户端需要在每个请求时发送用户名/密码.它简单而安全(通过HTTPS).REST当然是无状态的并且不使用会话,因此API中没有"登录"方法.每个请求都需要再次授权.
在这个REST服务器上,我们构建了一个AngularJS客户端.这是一个单页面应用程序.当用户登录到客户端时,客户端将存储凭据并确保设置了正确的HTTP标头.
"问题"是当用户刷新浏览器时,应用程序将失去其状态,包括身份验证凭据.
处理这个问题的最佳方法是什么?AngularJS应用程序如何让用户登录/记住凭据?无论解决方案是什么,它都必须是安全的,因为它是一个银行应用程序.
javascript ×3
http ×2
java ×2
ajax ×1
angularjs ×1
asmx ×1
c# ×1
cors ×1
html5 ×1
http-headers ×1
logout ×1
node.js ×1
oauth-2.0 ×1
rest ×1
servlets ×1
ubuntu ×1
wcf ×1
wcf-security ×1
web-services ×1