我正在使用基本身份验证的网站.使用Chrome我使用基本身份验证登录.我现在想从浏览器中删除基本身份验证详细信息并尝试不同的登录.
使用Chrome时,如何清除当前的基本身份验证详细信息?
注销HTTP身份验证保护文件夹的正确方法是什么?
有一些解决方法可以实现这一点,但它们具有潜在的危险性,因为它们可能是错误的,或者在某些情况/浏览器中不起作用.这就是为什么我正在寻找正确和干净的解决方案.
php authentication .htaccess password-protection http-headers
存储HTTP基本身份验证凭据直到浏览器关闭,但有没有办法在浏览器关闭之前删除凭据?
我读了一个关于HTTP 401状态代码的技巧,但似乎工作不正常(请参阅评论回答).也许trac使用的机制就是解决方案.
可以使用JavaScript删除凭据吗?或者结合使用JavaScript和状态401技巧?
我希望用户能够通过HTTP基本身份验证模式登录.
问题是我还希望他们能够再次注销 - 奇怪的是,浏览器似乎并不支持.
这被认为是一种社交黑客风险 - 用户将其机器解锁并且浏览器打开,而其他人可以轻松地访问该网站.请注意,仅关闭浏览器选项卡不足以重置令牌,因此用户可能很容易错过.
所以我想出了一个解决方法,但这是一个完全的问题:
1)将它们重定向到Logoff页面
2)在该页面上激活一个脚本到ajax加载另一个带有伪凭证的页面:
$j.ajax({
url: '<%:Url.Action("LogOff401", new { id = random })%>',
type: 'POST',
username: '<%:random%>',
password: '<%:random%>',
success: function () { alert('logged off'); }
});
Run Code Online (Sandbox Code Playgroud)
3)应该总是第一次返回401(强制传递新凭据),然后只接受伪凭证:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult LogOff401(string id)
{
// if we've been passed HTTP authorisation
string httpAuth = this.Request.Headers["Authorization"];
if (!string.IsNullOrEmpty(httpAuth) &&
httpAuth.StartsWith("basic", StringComparison.OrdinalIgnoreCase))
{
// build the string we expect - don't allow regular users to pass
byte[] enc = Encoding.UTF8.GetBytes(id + ':' + id);
string expected …Run Code Online (Sandbox Code Playgroud) 我正在Microsoft Edge上测试我的应用程序,它会抛出此错误:
app.config(
function ($routeProvider) {
$routeProvider.
when('/logout', {
template: '<logout-page></logout-page>'
})
.when('/', {
template: '<application-manage></application-manage>'
})
});
Run Code Online (Sandbox Code Playgroud)
在我的索引中:
<body style="height: 100%">
<div class='main-div' style="height: 100%;" ng-view ng-class="slide">Loading....</div>
</body>
Run Code Online (Sandbox Code Playgroud)
第一种情况:'<application-manage></application-manage>'它正常工作.但是当我点击退出时.它抛出错误:
SyntaxError <div class="main-div ng-scope" style="height: 100%" ng-class="slide" ng-view="">
Run Code Online (Sandbox Code Playgroud)
感谢大家.问题解决了,这是因为我使用基本身份验证的方式:
jQuery.ajax({
type: "GET",
url: logoutURL ,
async: true,
username: fakeUser,
password: fakePassword,
headers: {"Authorization": "Basic Authorization"}
}).done(function () {
console.log("Can not logout Basic Authentication in this browser");
defer.resolve(true);
}).fail(function () {
console.log("You have successfully logged out!");
defer.resolve(true);
});
Run Code Online (Sandbox Code Playgroud)
从: …
angularjs angularjs-directive angularjs-ng-click ng-view microsoft-edge
我刚刚使用express basic auth在nodejs中创建了基本身份验证
var express = require('express');
var app = express();
// Authenticator
app.use(express.basicAuth('testuser','testpassword'));
app.get('/home', function(req, res) {
res.send('Hello World');
});
app.listen(process.env.PORT || 8080);
Run Code Online (Sandbox Code Playgroud)
我收到以下错误.我不知道我哪里出错了.
app.use(express.basicAuth('testuser','testpassword'));
^
TypeError: Object function createApplication() {
var app = function(req, res, next) {
app.handle(req, res, next);
};
mixin(app, proto);
mixin(app, EventEmitter.prototype);
app.request = { __proto__: req, app: app };
app.response = { __proto__: res, app: app };
app.init();
return app;
} has no method 'basicAuth'
at Object.<anonymous> (E:\node_modules\npm\login\app.js:5:17)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10) …Run Code Online (Sandbox Code Playgroud) 每当我去/admin/logout,我都被正确地重定向到我的项目的根目录,但是当我访问时仍然登录,/admin/因为我没有被提示输入凭据.
这是我的配置:
security.yml
security:
firewalls:
admin_area:
pattern: ^/admin
http_basic: ~
stateless: true
switch_user: { role: ROLE_SUPER_ADMIN, parameter: _want_to_be_this_user }
logout: { path: /admin/logout, target: / }
Run Code Online (Sandbox Code Playgroud)
AdminBundle /资源/配置/ routing.yml中
logout:
pattern: /logout
Run Code Online (Sandbox Code Playgroud)
应用程序/配置/ routing.yml中
admin:
resource: "@AdminBundle/Resources/config/routing.yml"
prefix: /admin
Run Code Online (Sandbox Code Playgroud)
由于标头状态,授权仍然存在,Authorization:Basic YWRtaW46cEAkJHcwUmQh因此我想在请求期间仍然会向应用程序提供凭据.
我知道有从注销没有适当的方式HTTP Basic Auth按这个问题,但也许Symfony2的允许了吗?
有人可以说这是一个重复的问题,但我查看了很多答案,尝试了很多方法但无法理解我错过了什么。
我在我的 REST 服务器中使用了非常基本的 Spring Security。当我第一次直接从浏览器向我的服务器发出请求到localhost:.../getData我当然会被要求授权。
然后服务器每次都允许这个请求。我如何注销以便下一个请求再次需要授权?
现在我尝试在我的服务器上使用几种方法来注销:
@RequestMapping(value = "/logoutMe2", method = RequestMethod.GET)
public void logout2() {
SecurityContextHolder.getContext().setAuthentication(null);
}
@RequestMapping(value = "/logoutMe3", method = RequestMethod.GET)
public void logout3() {
SecurityContextHolder.clearContext();
}
@RequestMapping(value = "/logoutMe", method = RequestMethod.GET)
public void logout(HttpServletRequest rq, HttpServletResponse rs) {
SecurityContextLogoutHandler securityContextLogoutHandler =
new SecurityContextLogoutHandler();
securityContextLogoutHandler.logout(rq, rs, null);
}
@RequestMapping(value = "/logoutMe4", method = RequestMethod.GET)
public static void myLogoff(HttpServletRequest request, HttpServletResponse response) {
CookieClearingLogoutHandler cookieClearingLogoutHandler = new CookieClearingLogoutHandler(AbstractRememberMeServices.SPRING_SECURITY_REMEMBER_ME_COOKIE_KEY);
SecurityContextLogoutHandler securityContextLogoutHandler = …Run Code Online (Sandbox Code Playgroud) 该系统应如下所示:
auth_request指令向 Flask 应用程序发出子请求(将凭据作为请求的标头传递),期望响应为 200 或 401。
flask.session. 如果是,则立即返回 200 响应;否则,它会尝试根据外部事实来源进行身份验证。如果成功,则将该用户添加到flask.session该应用程序并返回 200 响应;否则,它将返回 401 响应。flask.session并返回 401 响应。然后,用户可以提出新的登录请求。用户的浏览器应该缓存他们提交的凭据,因此每个新请求都应该能够立即看到用户参与flask.session并避免进行新的身份验证尝试。
看似随机,在刷新或浏览受保护资源时(成功验证后),有时会出现验证弹出窗口,并要求用户再次验证。他们可以提交,并且在再次提示重新进行身份验证之前将加载单个资源。
例子:
受保护资源是一个静态网站,由一个索引页、一个 CSS 文件和三个图像组成。初始身份验证后,用户多次刷新页面。其中一次,将触发身份验证提示。他们将再次输入他们的凭据,并加载索引页面。他们将再次提示输入 CSS 文件,然后再次提示输入每个图像。
我不确定我需要在这里链接多少东西才能根除问题,所以我将从负责生成auth_request子请求和后续路由的 nginx 文件以及负责生成的两个 python 文件开始身份验证请求和处理会话。
nginx.default
server {
listen 80;
server_name _;
location / {
auth_request /auth;
proxy_pass {{resource_endpoint}}; …Run Code Online (Sandbox Code Playgroud) 我是达世币新手。我正在 Dash 中开发一个应用程序,它使用基本身份验证(Dash-Auth)进行登录。我向用户提供预定义的用户名和密码。我使用用户名跟踪登录用户。我的问题是,如何在不关闭浏览器的情况下从应用程序中注销用户?我的意思是如何删除用户凭据,以便当用户下次尝试登录时,系统将再次提示用户输入用户名和密码?
logout ×3
php ×2
.htaccess ×1
angularjs ×1
flask ×1
http ×1
http-headers ×1
java ×1
javascript ×1
ng-view ×1
nginx ×1
node.js ×1
plotly-dash ×1
python ×1
python-3.x ×1
security ×1
spring ×1
symfony ×1