我有一个工作的Kerberos SSO设置,我使用apache和jboss与mod_jk.Apache正在使用以下配置保护(通过kerberos)auto-login.htm页面:
<Location /auto-login.htm>
AuthType Kerberos
AuthName "Kerberos Active Directory Login"
KrbMethodNegotiate on
KrbMethodK5Passwd on
KrbAuthRealms KRB.SOMEDOMAIN.COM
KrbServiceName HTTP/server.somedomain.com@KRB.SOMEDOMAIN.COM
Krb5Keytab /etc/krb/krb5.keytab
KrbVerifyKDC on
KrbAuthoritative on
require valid-user
#ErrorDocument 401 /login.htm
</Location>
Run Code Online (Sandbox Code Playgroud)
这100%工作,我能够使用Kerberos/SSO登录并在我的java应用程序中读取remote_user变量.
现在的问题是,如果用户无法通过Kerberos/SSO登录,我想重定向到不受保护的login.htm.我想到的解决方案是设置401 ErrorDocument,但是当我通过在上面的代码中取消注释#ErrorDocument 401来设置它时,它总是重定向到login.htm,因为返回401以请求用户凭据本身就是Kerberos的一部分/ SSO身份验证过程.因此,结果是用户总是以login.htm结束,并且永远不会完成Kerberos/SSO登录过程.
任何帮助或替代解决方案将不胜感激.
在此先感谢
皮埃尔
我收到“401 未经授权访问端点”。当我在 POSTMAN(Chrome 扩展)上运行相同的调用时,它工作正常。即使它在我的 Android 应用程序中也运行良好。
但在这里,即使我在标头中发送令牌,我也会收到未经授权的访问。我不知道这里出了什么问题。我得到的回应是:
{“detail”:“未提供身份验证凭据。”}
这是我的代码:
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
NSString *url=[NSString stringWithFormat:@"%@",endpoint];
NSLog(@"url is %@",url);
[request setURL:[NSURL URLWithString:url]];
[request setHTTPMethod:@"GET"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
NSString *token=[NSString stringWithFormat:@"token %@",TOKEN];
NSLog(@"token is %@",token);
[request addValue:token forHTTPHeaderField:@"Authorization"];
NSURLSession *session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
[[session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error)
{
NSString *requestReply = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
NSLog(@"requestReply: %@", requestReply);
}] resume];
Run Code Online (Sandbox Code Playgroud)
我在哪里做错了什么?
编辑:如果我通过使用不同的类尝试这种方式,则响应为(空)。
NSMutableURLRequest *request =
[NSMutableURLRequest requestWithURL:[NSURL
URLWithString:url]
cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData
timeoutInterval:10
];
[request setHTTPMethod: …Run Code Online (Sandbox Code Playgroud) objective-c token nsurlconnection http-status-code-401 nsurlsession
我想使用spring security. 从spring 官方文档 中 23.2 WebSocket Authentication,WebSocket 将重用在建立 WebSocket 连接时在 HTTP 请求中找到的相同身份验证信息。所以我设置了 spring security 来验证rest service. 如果用户通过了其余的认证,则拥有WebSocket连接的权限,否则无法建立WebSocket连接。以下是代码:
用于登录的休息服务:WssAuthService.java
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
/**
* Authentication service.
*/
@RestController
@RequestMapping(path = "/hpdm")
public class WssAuthService {
@RequestMapping(path = "/login", method = RequestMethod.GET)
public String login(){
return "Login success to WssBroker...";
}
}
Run Code Online (Sandbox Code Playgroud)
spring 安全配置:WebSecurityConfig.java
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.http.SessionCreationPolicy; …Run Code Online (Sandbox Code Playgroud) 我需要的是当收到错误 401(未经授权)响应时重定向到某个 url。我的代码中有几个 Ajax 调用,所以我想知道是否有一种通用方法来监听所有这些调用,并且只有当该代码返回时才重定向到该 url?
我想在所有页面中包含此代码,以便在收到它时进行重定向,而无需编辑代码中的所有 AJAX 调用。
编辑:基本上其他答案不会解释确切的模式
只需这样做即可完成:
<script>
$(document).ajaxComplete(function(response, a){
if(a.status == 401){
return window.location.href = '/whatever/url/you/want';
}
});
</script>
Run Code Online (Sandbox Code Playgroud)
先感谢您
我创建了一个401页面,它是html,并在一个可访问的目录中.
它显示在IE 6,Firefox,Safari中,但不显示在IE 7中.
这是.htaccess文件,用于在401页面的目录和位置上设置身份验证.
KrbServiceName HTTP
KrbMethodNegotiate On
KrbMethodK5Passwd On
#KrbVerifyKDC on
KrbSaveCredentials off
KrbAuthRealms HCCC.CAMPUS
Krb5KeyTab /etc/httpd/keytab
KrbAuthoritative off
AuthType Kerberos
AuthName "Please Login"
AuthBasicProvider ldap
AuthzLDAPAuthoritative on
AuthLDAPURL "ldap://domain:389/OU=Campus Users,DC=hccc,DC=campus?userPrincipalName?sub?(objectClass=*)"
AuthLDAPBindDN "CN=ldapuser,CN=Users,DC=hccc,DC=campus"
AuthLDAPBindPassword ldapsearch
require ldap-group CN=Students,CN=Users,DC=hccc,DC=campus
#require ldap-group CN=Faculty,CN=Users,DC=domain,DC=local
#Satisfy any
ErrorDocument 401 /all/401.html
Run Code Online (Sandbox Code Playgroud)
当我进入目录/页面时,它会提示我输入用户名/密码,因为我的帐户不在学生组内,它将我踢到401页面,它在Safari,IE6,Firefox中执行,但IE7确实如此不,它只显示默认页面(屏幕截图:http://i35.tinypic.com/2qbgmjs.png)
任何帮助是极大的赞赏.
我正在尝试设置Django-Paypal并且已经从PayPal获得了回报.简而言之,在我的Apache访问日志中,每当我通过PayPal处理付款时(以及PayPal将结果发回给我的服务器),我都会收到以下信息:
173.0.82.126 - - [27/Oct/2012:16:42:52 +0200] "POST /my/super/secret/notify/url/ HTTP/1.0" 401 787 "-" "-"
Run Code Online (Sandbox Code Playgroud)
通知视图确实@csrf_exempt用于解决此错误,但仍然无法正常工作.
如果有人能告诉我如何解决这个问题(这显然是权限/授权问题),我将非常感激!
PS:我已经尝试添加WSGIPassAuthorization到我的apache配置文件,这也没有帮助.
我对Web浏览器的基本身份验证有点困惑.我原以为Web浏览器只会在上一个响应中收到HTTP 401状态后发送Authorization标头.但是,Chrome似乎会随后向每个请求发送Authorization标头.它有一次我输入的数据,以响应我网站上的401,并随每条消息一起发送(根据Chrome和我的网络服务器附带的开发人员工具).这是预期的行为吗?是否有一些标题我应该用我的401来推断授权的东西不应该被缓存?我目前正在使用WWW-Authenticate标头.
iis basic-authentication http-headers wcf-data-services http-status-code-401
我是网络开发的新手.我有Android应用程序使用HTTPServer托管一些网页.我正在使用Netty来解码/编码请求/响应.现在,我想在有人导航到我的网页时显示基本身份验证对话框.像这样的东西:
我可以得到一些指示吗?这是HTTP内置的功能,任何RFC?我需要编写一些java脚本吗?任何帮助都会很棒.
javascript httpwebrequest httpwebresponse httpserver http-status-code-401
目前使用来自NSURLConnection的sendAsynchronous来发布和获取请求,但无法获取响应中的状态代码.大多数帖子都建议使用NSURLConnection及其委托方法,我理解它们也是异步的.
我不明白委托如何将信息发送回调用方法(最终需要数据的方法).sendAsynchronous方法有一个我现在正在使用的回调.
我是新来的,谢谢你的帮助.
cocoa-touch http-status-code-401 nsurlconnectiondelegate sendasynchronousrequest ios6
我无可救药地试图打电话Amazon MWS Products API.特别是我正在尝试请求此功能
它需要使用签名构建一个非常复杂的请求:
POST /Products/2011-10-01 HTTP/1.1
Content-Type: x-www-form-urlencoded
Host: mws.amazonservices.com
User-Agent: <Your User Agent Header>
AWSAccessKeyId=AKIAEXAMPLEFWR4TJ7ZQ
&Action=ListMatchingProducts
&MWSAuthToken=amzn.mws.4ea38b7b-f563-7709-4bae-87aeaEXAMPLE
&MarketplaceId=ATVPDKIKX0DER
&Query=0439708184
&SellerId=A1IMEXAMPLEWRC
&SignatureMethod=HmacSHA256
&SignatureVersion=2
&Timestamp=2012-12-12T22%3A23%3A50Z
&Version=2011-10-01
&Signature=V%2BEXAMPLERT%2Baj%2Fxwqo7y3PIifMFHeqFlNYW0EXAMPLEA%3D
Run Code Online (Sandbox Code Playgroud)
我在这个小库的帮助下构建了这个查询:
所以我的最终url字符串看起来像这样:
https://mws.amazonservices.com/Products/2011-10-01?AWSAccessKeyId=<MY_ACCESS_KEY>&Action=ListMatchingProducts&MarketplaceId=A1PA6795UKMFR9&Query=0439708184&SellerId=<SELLER_ID>&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2016-04-19T16%3A50%3A13Z&Version=2011-10-01&Signature=mZt3OhM14gwLdsQ%2Bhxz5UFMzr7m2U36DvZ7RG3dcsTI%3D
Run Code Online (Sandbox Code Playgroud)
似乎url字符串是正确构建的.我想是的,因为如果参数丢失或不正确,API会返回400错误,并说明此参数无效.这同样适用于签名.如果签名不正确,则API返回错误,该错误明确指出签名无效.所以,再次,我认为网址必须是好的.然而,API返回401错误和一个看起来像这样的html页面:
<?xml version="1.0"?>
<ErrorResponse xmlns="http://mws.amazonservices.com/schema/Products/2011-10-01">
<Error>
<Type>Sender</Type>
<Code>AccessDenied</Code>
<Message>Access denied</Message>
</Error>
<RequestID>7b12e3c8-7b1a-4b6e-b7ba-15ec8c4e0968</RequestID>
</ErrorResponse>
Run Code Online (Sandbox Code Playgroud)
拒绝访问.我不明白为什么.我已经花了几个小时试图弄清楚什么是错的.谁能帮我?
http objective-c amazon-web-services http-status-code-401 ios
javascript ×2
objective-c ×2
.htaccess ×1
ajax ×1
apache ×1
cocoa-touch ×1
http ×1
http-headers ×1
httpserver ×1
iis ×1
ios ×1
ios6 ×1
jboss ×1
kerberos ×1
ldap ×1
nsurlsession ×1
paypal-ipn ×1
token ×1