【发布时间】:2016-02-15 20:49:54
【问题描述】:
我将SimpleSAMLphp 用作我们拥有的一堆应用程序的IdP,主要是一个Drupal 站点。我在IdP 上使用SQL 作为身份验证源,它可以对用户进行身份验证,响应返回到Drupal 并且用户已通过身份验证。一切顺利!
但是,我们还需要使用社交登录(使用 Twitter、Facebook 等登录)。 SimpleSAMLphp 支持 OAuth,我已经设置了它,并且使用社交帐户 SimpleSAML 在 IdP 上登录> 创建会话和 cookie,但我没有在 Drupal 站点上进行身份验证。
我需要做的是通过返回 Drupal 并在那里对用户进行身份验证来完成请求,也就是说,在成功时向 Drupal 发出断言。
就像在 SQL 源代码中一样,我已经映射了每个源文件(Twitter.php、Facebook.php 等)中的属性,但是 SQL auth 返回到 Drupal 并创建一个会话,其他的只是显示它们的属性在模板中。
我如何从这些社交登录中为 Drupal 生成并发送回一个断言,以便在那里对我的用户进行身份验证?
saml10-sp-remote.php (IdP)
$metadata['https://durpal_url/simplesaml_drupal_sp/module.php/saml/sp/metadata.php/sp'] = array (
'SingleLogoutService' =>
array (
0 =>
array (
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
'Location' => 'https://durpal_url/simplesaml_drupal_sp/module.php/saml/sp/saml2-logout.php/sp',
),
1 =>
array (
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:SOAP',
'Location' => 'https://durpal_url/simplesaml_drupal_sp/module.php/saml/sp/saml2-logout.php/sp',
),
),
'AssertionConsumerService' =>
array (
0 =>
array (
'index' => 0,
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST',
'Location' => 'https://durpal_url/simplesaml_drupal_sp/module.php/saml/sp/saml2-acs.php/sp',
),
1 =>
array (
'index' => 1,
'Binding' => 'urn:oasis:names:tc:SAML:1.0:profiles:browser-post',
'Location' => 'https://durpal_url/simplesaml_drupal_sp/module.php/saml/sp/saml1-acs.php/sp',
),
2 =>
array (
'index' => 2,
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact',
'Location' => 'https://durpal_url/simplesaml_drupal_sp/module.php/saml/sp/saml2-acs.php/sp',
),
3 =>
array (
'index' => 3,
'Binding' => 'urn:oasis:names:tc:SAML:1.0:profiles:artifact-01',
'Location' => 'https://durpal_url/simplesaml_drupal_sp/module.php/saml/sp/saml1-acs.php/sp/artifact',
),
),
'certData' => 'xxxx',
);
authsources.php (IdP)
'sql' => array(
'sqlauth:SQL',
'dsn' => 'mysql:host=localhost;dbname=db',
'username' => 'user',
'password' => 'pass',
'query' => 'SELECT u.uid, u.name, u.mail, r.name AS role FROM users u JOIN users_roles ur on ur.uid = u.uid JOIN role r on r.rid = ur.rid where u.mail = :username AND pass = MD5(:password);',
),
'facebook' => array(
'authfacebook:Facebook',
'api_key' => 'xxxx',
'secret' => 'xxxx',
'req_perms' => 'email',
),
'linkedin' => array(
'authlinkedin:LinkedIn',
'key' => 'xxxx',
'secret' => 'xxxx',
),
'twitter' => array(
'authtwitter:Twitter',
'key' => 'xxxx',
'secret' => 'xxxx',
'force_login' => true,
),
saml20-idp-remote.php (SP, Drupal)
$metadata['http://idp_url/simplesaml/saml2/idp/metadata.php'] = array (
'metadata-set' => 'saml20-idp-remote',
'entityid' => 'http://idp_url/simplesaml/saml2/idp/metadata.php',
'SingleSignOnService' =>
array (
0 =>
array (
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
'Location' => 'http://idp_url/simplesaml/saml2/idp/SSOService.php',
),
),
'SingleLogoutService' =>
array (
0 =>
array (
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
'Location' => 'http://idp_url/simplesaml/saml2/idp/SingleLogoutService.php',
),
),
'certData' => 'xxx',
'NameIDFormat' => 'urn:oasis:names:tc:SAML:2.0:nameid-format:transient',
);
saml20-idp-hosted.php (IdP)
$metadata['__DYNAMIC:1__'] = array(
'host' => '__DEFAULT__',
'privatekey' => 'mysite.com.key',
'certificate' => 'mysite.com.crt',
'auth' => 'sql',
);
【问题讨论】:
-
发布你们的一些配置。 IDP 是否配置为使用社交提供者作为身份验证源?听起来您可能刚刚配置了额外的身份验证源,而没有配置 IDP 来使用它们。
-
@Patrick 更新了! IdP 配置为使用社交作为身份验证源,IdP 指向 SP,SP 指向 IdP。使用此配置,仅使用 SQL authsource 实际上会在 Drupal 上创建会话
-
您是否还可以将
saml20-idp-hosted.php包含在您的 idp 中?
标签: php oauth-2.0 saml simplesamlphp