我只是将spring-security-plugin添加到我的grails项目中.一切看起来都很好.但是当我尝试注销时,应用程序会向我显示注销消息,但应用程序仍然已登录!
我的配置文件如下:
// Added by the Spring Security Core plugin:
grails.plugins.springsecurity.useBasicAuth = true
grails.plugins.springsecurity.userLookup.userDomainClassName = 'malibu.server.User'
grails.plugins.springsecurity.userLookup.authorityJoinClassName = 'malibu.server.UserRole'
grails.plugins.springsecurity.authority.className = 'malibu.server.Role'
Run Code Online (Sandbox Code Playgroud)
干杯
我想使用 XHR 登录到使用 HTTP 基本身份验证的站点。下面的作品就是这样做的。
http = new XMLHttpRequest();
http.open("get", "http://...", false, username, password);
http.send("");
Run Code Online (Sandbox Code Playgroud)
问题是,这并没有从一个域是从一个地方认证是不同的工作。解决方案很简单:将 Access-Control-Allow-Origin 标头设置为 *. 所以我将我的 Apache 配置更改为:
<Location />
Header set Access-Control-Allow-Origin "*"
AuthType Basic
AuthName "trac"
AuthUserFile /home/admin/development/pass.htpasswd
Require valid-user
</Location>
Run Code Online (Sandbox Code Playgroud)
该页面的响应如下所示:
HTTP/1.1 401 Authorization Required
Connection: Keep-Alive
Content-Encoding: gzip
Content-Length: 345
Content-Type: text/html; charset=iso-8859-1
Date: Sun, 11 Sep 2011 01:17:55 GMT
Keep-Alive: timeout=15, max=100
Vary: Accept-Encoding
WWW-Authenticate: Basic realm="trac"
Run Code Online (Sandbox Code Playgroud)
响应没有 Access-Control-Allow-Origin 标头。这看起来很奇怪。
当我对内页使用相同的 Header 指令时,设置了标题。
为什么没有设置标题?如何在 Apache 中为 HTTP 基本身份验证响应设置 Access-Control-Allow-Origin …
我可以在哪里为使用 basicHttpBinding 的服务设置用户名和密码
<binding name="proxioBasicHttpBinding"
closeTimeout="05:00:00"
openTimeout="05:00:00"
receiveTimeout="05:00:00"
maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647"
messageEncoding="Mtom"
transferMode="Streamed" >
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Digest" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
Run Code Online (Sandbox Code Playgroud)
如果该服务托管在 windows 服务下?
我正在尝试向受保护的网页发出请求,因此我尝试在QAuthenticator(). 但是,我收到以下错误:
mgr.authenticationRequired(response, auth)
TypeError: native Qt signal is not callable
Run Code Online (Sandbox Code Playgroud)
这是我的脚本的一部分:
def authenticate(self):
username = 'user'
password = 'pass'
url = 'http://someurl.com'
mgr = QNetworkAccessManager(self)
auth = QAuthenticator()
auth.setUser(username)
auth.setPassword(password)
response = QNetworkRequest()
response.setUrl(QUrl(url))
mgr.authenticationRequired(mgr.get(response), auth)
Run Code Online (Sandbox Code Playgroud)
我在这里做错了什么?
python authentication basic-authentication pyqt4 qnetworkaccessmanager
使用tastypie API并为用户资源实现一些功能(遵循此示例代码:如何使用tastypie登录django),我想知道如何存放经过身份验证的用户或如何以正确的方式访问它.在测试登录方法时:
curl -u "user:pw" -H "Content-Type: application/json" -X POST --data '{"username" : "user", "password": "pw"}' http://localhost:8000/api/user/login/?format=json
Run Code Online (Sandbox Code Playgroud)
一切正常; 但是logout方法将request.user视为匿名用户.如何向正确认证的用户传递注销方法?非常感谢.
来自api.py的片段
class UserResource(ModelResource):
class Meta:
queryset = AppUser.objects.all()
resource_name = 'user'
fields = ['first_name', 'last_name', 'username', 'email', 'is_staff']
allowed_methods = ['get', 'post', 'patch']
always_return_data = True
authentication = BasicAuthentication()
authorization = Authorization()
def prepend_urls(self):
params = (self._meta.resource_name, trailing_slash())
return [
url(r"^(?P<resource_name>%s)/login%s$" % params, self.wrap_view('login'), name="api_login"),
url(r"^(?P<resource_name>%s)/logout%s$" % params, self.wrap_view('logout'), name="api_login")
]
def login(self, request, **kwargs):
"""
Authenticate a user, …Run Code Online (Sandbox Code Playgroud) 我们使用clj-http进行 HTTP 基本身份验证。我想用这个标头发送一个请求:
Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=
Run Code Online (Sandbox Code Playgroud)
所有的例子我发现说做这样的:
(clj-http.client/get "http://my.domain.com"
{:headers {:basic-auth [username password]}})
Run Code Online (Sandbox Code Playgroud)
这似乎发送只含有一种叫头的请求basic-auth,与未编码值username和password。我必须像这样手动生成基本身份验证标头:
(clj-http.client/get "http://my.domain.com"
{:headers {:Authorization "Basic dXNlcm5hbWU6cGFzc3dvcmQ="}})
Run Code Online (Sandbox Code Playgroud)
当然,这要困难得多,因为我必须正确编码用户名和密码并在前面贴上“基本”一词。clj-http 可以为我做这个吗?
我是REST服务的新手,我正在网上寻找几个小时......
我有一个REST服务URL,它可以返回JSON数据.登录(用户名和密码)是基本身份验证.我正在寻找一个简单的库/代码片段,让我插入uri,用户名和密码,然后给我回JSON字符串.
任何帮助,将不胜感激!
很抱歉就这个主题做另一个问题,但我一直在阅读,但无法真正让它发挥作用......
切入正题...我有一个可以下载 zip 文件的链接。我已获得访问该网站(我的用户)的权限,现在我正在尝试编写一个程序来每隔一段时间获取 zip.file,以便我可以对其数据进行处理。
当我刚刚尝试下载需要身份验证的东西的代码时(见下面的代码),我得到一个 HTTP 401。我想知道为什么我的凭据没问题,我可以使用浏览器获取文件。
HttpWebRequest request;
HttpWebResponse response;
request = (HttpWebRequest)WebRequest.Create(strURL);
request.Credentials = ((domain == null || domain == "") ?
new System.Net.NetworkCredential(user, pass) :
new System.Net.NetworkCredential(user, pass, domain)));
response = (HttpWebResponse)request.GetResponse();
//...do somthing
Run Code Online (Sandbox Code Playgroud)
在阅读和搜索后,我得出的结论是我必须明确告诉身份验证者。方法并找到了 CredentialCache 示例。我之后做的是打开 fiddler 并查看网站的响应并找到以下标题:
WWW-Authenticate: Negotiate
WWW-Authenticate: Basic realm="BACKLOG ::::::: AUTENTICACAO NECESSARIA - USAR APENAS USERNAME E PASSWORD DE DOMINIO"
Run Code Online (Sandbox Code Playgroud)
有了这个,我可以知道什么是 auth. 我需要输入,所以我将代码更改为以下内容:
HttpWebRequest request;
HttpWebResponse response;
request = (HttpWebRequest)WebRequest.Create(strURL);
CredentialCache cc = new CredentialCache();
cc.Add(new Uri(strURL), "Negotiate", (
(domain == …Run Code Online (Sandbox Code Playgroud) c# authentication httprequest basic-authentication negotiate
我正在使用WebAPI并将其与Katana托管在一起。我现在正在编写一些用于身份验证和授权的中间件。我必须对SSL使用基本身份验证,因为请求可能来自各种平台。目前还不能选择OAuth。中间件需要使用基本身份验证提供的用户名和密码,并验证用户是否是本地Windows组的成员。
现在,我正在尝试弄清楚如何创建WindowsPrincipal。如果我能弄清楚如何使用用户名和密码创建WindowsPrincipal,那么我会做其余的事情。这就是我现在所拥有的。
//TODO
WindowsPrincipal userPrincipal = null; //This is where I need to take the username and password and create a WindowsPrincipal
Thread.CurrentPrincipal = userPrincipal;
AppDomain.CurrentDomain.SetPrincipalPolicy(System.Security.Principal.PrincipalPolicy.WindowsPrincipal);
PrincipalPermission permission = new PrincipalPermission(null, "Local Group Name");
permission.Demand();
Run Code Online (Sandbox Code Playgroud)
我正在努力寻找一种使用用户名和密码来验证该成员是否属于特定组的好方法。做这个的最好方式是什么?我在这里先向您的帮助表示感谢。
我在Vue 2.0中使用Vue Resource编写了一种方法,该方法可通过基本身份验证连接到API。
getCountries: function()
{
options = {
headers:
{
'type' : 'GET',
'Authorization' : 'Basic c3VyZWJ1ZGR5LWFwaS11c2VyOkFwaTQzMjJTdXJlYg==',
'Access-Control-Allow-Headers': 'Content-Type',
'Access-Control-Allow-Methods': 'GET',
'Access-Control-Allow-Origin' : '*',
'dataType' : "json"
}
}
this.$http.get('http://surebuddy.azurewebsites.net/Api/Products', [options])
.then((response) => {
console.log(response.body);
}, (error) => {
console.log(error);
});
}
Run Code Online (Sandbox Code Playgroud)
当我在浏览器中运行此命令时,我在控制台中仅收到“ 403(禁止访问)”错误消息。
有了Postman中的这些授权凭证,我可以完美地连接和接收数据。我感到自己在标头中错误地传递了Authorization。