我是Azure SSO的新手,所以我可能在这里错过了一些显而易见的事情-请记住这一点;-)
我需要将我的应用程序集成到Azure Active Directory。为此,我们的组织没有太多帮助,所以我任由我自己在这里查找问题:-/我的确切问题是,当我登录后从Azure收到此错误:
AADSTS50011: The reply URL specified in the request does not match the
reply URLs configured for the application: 'https://192.168.0.1/secure/'.
我当然已经在寻找如何解决这个问题的方法,但是我没有发现任何可以使我更加接近的方法。
我有此设置:
我没有设置也没有访问Azure的部分,因为这是由我们的IT人员设置的,但是他们已经设置了:
Basic SAML Configuration
Identifier (Entity ID) : https://192.168.0.1/secure/
Reply URL (Assertion Consumer Service URL) : https://192.168.0.1/secure/
Sign on URL : Optional
Relay State : Optional
Logout URL : Optional
我从Azure检索了联合身份验证XML文件,并将其转换/填充为simpleSAMLphp文件\ metadata \ saml20-idp-remote.php
我已设置\ config \ authsources.php文件:
'entityID' => "https://192.168.0.1/secure/",
'idp' => "https://sts.windows.net/06dg12k9-1wl2-4mue-79gh-40ff1a8dnd4a/",
'NameIDFormat' => 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent',
'simplesaml.nameidattribute' => 'eduPersonTargetedID',
在配置本指南的所有内容时,https://www.lewisroberts.com/2015/09/05/single-sign-on-to-azure-ad-using-simplesamlphp/
当我启动https://192.168.0.1/simpleSAMLphp/www/并转到身份验证和测试配置的身份验证源,然后使用default-sp进行测试时,我会得到一个Azure登录屏幕。如果我查看该网址,则如下所示:
https://login.microsoftonline.com/0ad94219-6af5-474e-99d0-60f9188f3fce/saml2
?SAMLRequest=f[CUT]2Fy%2Fi%2Bjc%3D
&RelayState=https%3A%2F%2F192.168.0.1%2FsimpleSAMLphp%2Fwww%2Fmodule.php%2Fcore%2Fauthenticate.php%3Fas%3Ddefault-sp
我假设RelayState是请求来自服务器的位置。我试图将Azure中的Entity ID和Reply URL设置为https://192.168.0.1/simpleSAMLphp/www/module.php/core/authenticate.php?as=default-sp,但结果相同。
因此,我已在此处提供了我所知道的一切,但在解决此问题上我真的是空白。我是否需要在simpleSAMLphp中配置Reply URL,以便将其作为URL参数传递?
任何帮助都将不胜感激。
###更新1-另一个问题###
从simpleSAMLphp修改日志文件后,它显示了发送到Azure的内容:
<samlp:AuthnRequest xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" ID="_25e3fb2" Version="2.0" Destination="https://login.microsoftonline.com/088f3fce/saml2" AssertionConsumerServiceURL="https://192.168.0.1/simpleSAMLphp/www/module.php/saml/sp/saml2-acs.php/default-sp" ProtocolBinding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST">
<saml:Issuer>https://192.168.0.1/simpleSAMLphp/www/module.php/saml/sp/metadata.php/default-sp</saml:Issuer>
<samlp:NameIDPolicy Format="urn:oasis:names:tc:SAML:2.0:nameid-format:transient" AllowCreate="true"/>
</samlp:AuthnRequest>
然后我从那里拿走AssertionConsumerServiceURL
,并在Azure中将其用作Reply URL。我也从simpleSAMLphp联合页面获取了[[实体ID,并且从现在simpleSAMLphp演示页面开始了:-)
基本SAML配置
Identifier (Entity ID) : https://192.168.0.1/simpleSAMLphp/www/module.php/saml/sp/metadata.php/default-sp
Reply URL (Assertion Consumer Service URL) : https://192.168.0.1/simpleSAMLphp/www/module.php/saml/sp/saml2-acs.php/default-sp
Sign on URL : Optional
Relay State : Optional
Logout URL : Optional
(请注意URL中的差异)但是可悲的是我仍然有问题。当我在Web范围中有一个包含以下内容的PHP文件时:
<?PHP require_once ("../../simpleSAMLphp/lib/_autoload.php"); $as = new SimpleSAML_Auth_Simple('default-sp'); $as->requireAuth(); $attributes = $as->getAttributes(); echo '<pre>'; print_r($attributes); echo '</pre>'; // Get a logout URL $url = $as->getLogoutURL(); echo '<a href="' . htmlspecialchars($url) . '">Logout</a>'; ?>
然后,它最终在中在服务器和Azure之间重定向!?查看日志对我而言没有任何重要的见识。似乎我确实从Azure接收了数据,并且已通过身份验证,因为我可以在调试日志中看到用户属性,但是...如果我已通过身份验证,那么为什么我重定向回Azure !!无限循环
###更新2-解决方案###
[在查看了simpleSAMLphp日志文件几个小时并清除了警告(它们实际上很重要)之后,我发现我的无限重定向是由PHP会话和simpleSAMLphp会话之间的不匹配引起的。我的解决方案是将两者对齐,并在所有位置进行完全相同的设置。确保检查php.ini
会话设置和\config\config.php
会话设置并使它们相同。
[我还发现我使用的PHP源代码用于simpleSAMLphp的较旧版本,尽管我认为这不是问题。
代替此旧方法:$as = new SimpleSAML_Auth_Simple('default-sp');
然后应该是这个新方法:$as = new \SimpleSAML\Auth\Simple('default-sp');
RelayState
只是按原样回送给SP的参数。例如,它可以用于存储用户尝试访问的页面URL。[如果您使用的是SAML2
,则replyURL应该是SP元数据中的AssertionConsumerService
网址。 Azure将在其中发送SAML
Response
。如果该网址与https://192.168.0.1/secure/
不同,则会收到该错误。即使缺少尾随的/
也会导致错误。