本文将介绍objective-c–我可以使用NSURLCredentialStorage进行HTTP基本身份验证吗?的详细情况,。我们将通过案例分析、数据研究等多种方式,帮助您更全面地了解这个主题,同
本文将介绍objective-c – 我可以使用NSURLCredentialStorage进行HTTP基本身份验证吗?的详细情况,。我们将通过案例分析、数据研究等多种方式,帮助您更全面地了解这个主题,同时也将涉及一些关于active-directory – 您可以使用AD LDS(ADAM)帐户对SSAS进行身份验证吗?、Azure Active Directory身份验证和现有应用程序正在使用Identity框架进行用户身份验证使用ADAL或Web Api、io.reactivex.netty.protocol.http.HttpObjectAggregationConfigurator的实例源码、IOS – 使用NSURLRequest在HTTP标头中进行令牌身份验证的知识。
本文目录一览:- objective-c – 我可以使用NSURLCredentialStorage进行HTTP基本身份验证吗?
- active-directory – 您可以使用AD LDS(ADAM)帐户对SSAS进行身份验证吗?
- Azure Active Directory身份验证和现有应用程序正在使用Identity框架进行用户身份验证使用ADAL或Web Api
- io.reactivex.netty.protocol.http.HttpObjectAggregationConfigurator的实例源码
- IOS – 使用NSURLRequest在HTTP标头中进行令牌身份验证
objective-c – 我可以使用NSURLCredentialStorage进行HTTP基本身份验证吗?
<?PHP if (!isset($_SERVER['PHP_AUTH_USER'])) { header('WWW-Authenticate: Basic realm="My Realm"'); header('HTTP/1.0 401 Unauthorized'); //Stuff that users will see if they click 'Cancel' exit; } else { //Validation Code echo "You entered info."; } ?>
在这一点上,我正在使用一个同步的NSURLConnection,我知道苹果文档状态对认证的支持较少。
但是,甚至有可能吗?我可以很容易地进行cookie身份验证NSURLProtectionSpaces或NSURLCredentials或任何认证类。还有,有什么资源可以在这里阅读有关可可认证类的更多信息?
谢谢。
更新:mikeabdullahuk
你提供的代码(第二个例子)与我所写的几乎相同。我已经做了更多的调查,并发现NSURLConnection返回错误…
Error Domain=NSURLErrorDomain Code=-1012 UserInfo=0x1a5170 "Operation Could not be completed. (NSURLErrorDomain error -1012.)"
代码对应于NSURLErrorUserCancelledAuthentication。显然,我的代码没有访问NSURLCredentialStorage,而是取消认证。这可能与PHP HTTP身份验证功能有关吗?在这一点上我很困惑
解决方法
> NSURLConnection从服务器请求页面
>服务器回复401响应
NSURLConnection看起来可以看到从URL获取的凭据
>如果URL没有提供完整的凭据(用户名和密码),NSURLConnection还将参考NSURLCredentialStorage填写空白
>如果完整凭据尚未确定,NSURLConnection将发送-connection:didReceiveAuthenticationChallenge:委托方法请求凭据
>如果NSURLConnection现在终于有完整的凭据,它将重试原始请求,包括授权数据。
通过使用同步连接方法,您只能在步骤5中输入提供自定义身份验证的能力。因此,您可以在URL中预先提供身份验证凭据,也可以在发送请求之前将其置于NSURLCredentialStorage中。例如
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://user:pass@example.com"]]; [NSURLConnection sendSynchronousRequest:request returningResponse:NULL error:NULL];
要么:
NSURLCredential *credential = [NSURLCredential credentialWithUser:@"user" password:@"pass" persistence:NSURLCredentialPersistenceForSession]; NSURLProtectionSpace *protectionSpace = [[NSURLProtectionSpace alloc] initWithHost:@"example.com" port:0 protocol:@"http" realm:nil authenticationMethod:nil]; [[NSURLCredentialStorage sharedCredentialStorage] setDefaultCredential:credential forProtectionSpace:protectionSpace]; [protectionSpace release]; NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://example.com"]]; [NSURLConnection sendSynchronousRequest:request returningResponse:NULL error:NULL];
active-directory – 您可以使用AD LDS(ADAM)帐户对SSAS进行身份验证吗?
我们有几个实现,我们通过HTTPS代理(msmdpump.dll)公开SSAS,目前我们有一个临时域设置处理这个(我们的最终用户有第二个帐户信用管理,因为这=非理想).我想让我们转向一个更持久的解决方案,我正在考虑将所有身份验证移植到AD LDS以用于我们的Web应用程序,SSAS和其他人.但是,SSAS是我关心的地方.
我知道SSAS需要Windows身份验证并且运行良好,这最终意味着将涉及Active Directory.
有没有办法用AD LDS完成这项工作,而不必使用完整的AD DS实现?如果是这样,怎么样?
(注意:我在StackOverflow的问题提出了一个建议,即我在ServerFault上发布此问题.如果我没有在正确的论坛上提问,我很抱歉.)
解决方法
Azure Active Directory身份验证和现有应用程序正在使用Identity框架进行用户身份验证使用ADAL或Web Api
由于您尝试使用两种不同的方案对应用程序进行身份验证,因此可以使用Azure AD B2C轻松实现。希望这个tutorial对您有所帮助。
此外,如果您想使用ADAL,则自2020年6月30日开始,建议使用MSAL,我们将不再为ADAL添加新功能。我们将继续向ADAL添加重要的安全修复程序,直到2022年6月30日。请参阅here。
io.reactivex.netty.protocol.http.HttpObjectAggregationConfigurator的实例源码
@Override public HttpClient<ByteBuf,ByteBuf> newHttpClient(final IClientConfig config) { final List<ExecutionListener<HttpClientRequest<ByteBuf>,HttpClientResponse<ByteBuf>>> listeners = new ArrayList<>(); listeners.add(createBearerHeaderAdder()); final PipelineConfiguratorComposite<HttpClientResponse<ByteBuf>,HttpClientRequest<ByteBuf>> pipelineConfigurator = new PipelineConfiguratorComposite<HttpClientResponse<ByteBuf>,HttpClientRequest<ByteBuf>>(new HttpClientPipelineConfigurator<ByteBuf,ByteBuf>(),new HttpObjectAggregationConfigurator(maxChunkSize)); final LoadBalancingHttpClient<ByteBuf,ByteBuf> client = LoadBalancingHttpClient.<ByteBuf,ByteBuf>builder() .withClientConfig(config) .withExecutorListeners(listeners) .withRetryHandler(getDefaultHttpRetryHandlerWithConfig(config)) .withPipelineConfigurator(pipelineConfigurator) .withPoolCleanerScheduler(RibbonTransport.poolCleanerScheduler) .build(); return client; }
@Override public HttpClient<ByteBuf,ByteBuf>builder() .withClientConfig(config) .withExecutorListeners(listeners) .withRetryHandler(getDefaultHttpRetryHandlerWithConfig(config)) .withPipelineConfigurator(pipelineConfigurator) .withPoolCleanerScheduler(RibbonTransport.poolCleanerScheduler) .build(); return client; }
public static <I,O> PipelineConfigurator<io.reactivex.netty.protocol.http.server.HttpServerRequest<I>,io.reactivex.netty.protocol.http.server.HttpServerResponse<O>> httpServerConfigurator() { return new PipelineConfiguratorComposite<io.reactivex.netty.protocol.http.server.HttpServerRequest<I>,io.reactivex.netty.protocol.http.server.HttpServerResponse<O>>(new HttpServerPipelineConfigurator<I,O>(),new HttpObjectAggregationConfigurator()); }
public static <I,O> PipelineConfigurator<HttpClientResponse<O>,HttpClientRequest<I>> httpClientConfigurator() { return new PipelineConfiguratorComposite<HttpClientResponse<O>,HttpClientRequest<I>>(new HttpClientPipelineConfigurator<I,new HttpObjectAggregationConfigurator()); }
IOS – 使用NSURLRequest在HTTP标头中进行令牌身份验证
//Failed to authenticate with server [request setValue:@"tokenHere" forHTTPHeaderField:@"token"]; [request setValue:@"def" forHTTPHeaderField:@"nonce"]; //Failed as well NSDictionary *authToken = [NSDictionary dictionaryWithObjectsAndKeys: @"tokenHere",@"token",@"def",@"nonce",nil]; [request setValue:[Nsstring stringWithFormat:@"Token %@",authToken] forHTTPHeaderField:@"Authorization"]; //Failed again [request setValue:@"Authorization: Token token='tokenHere',nonce='def'" forHTTPHeaderField:@"Authorization"];
后端服务器在ruby中编程,并且期望单个头部看起来就像上面的例子.我需要一些帮助来制作这个值,以便它与后端一起工作.
解决方法
Nsstring *authHeader = [Nsstring stringWithFormat:@"token=\"%@\",nonce=\"%@\"",@"tokenHere",@"def"]; [myMutableRequest setValue:authHeader forHTTPHeaderField:@"Authorization"];
换句话说,标题字段的名称是“授权”,它的值是逗号分隔的名称=值对.你的规范中唯一没有意义的部分是额外提到“令牌”,如同
… Token token=…
关于objective-c – 我可以使用NSURLCredentialStorage进行HTTP基本身份验证吗?的介绍现已完结,谢谢您的耐心阅读,如果想了解更多关于active-directory – 您可以使用AD LDS(ADAM)帐户对SSAS进行身份验证吗?、Azure Active Directory身份验证和现有应用程序正在使用Identity框架进行用户身份验证使用ADAL或Web Api、io.reactivex.netty.protocol.http.HttpObjectAggregationConfigurator的实例源码、IOS – 使用NSURLRequest在HTTP标头中进行令牌身份验证的相关知识,请在本站寻找。
本文标签: