【问题标题】:SimpleSAMLphp generate assertionSimpleSAMLphp 生成断言
【发布时间】:2016-02-15 20:49:54
【问题描述】:

我将SimpleSAMLphp 用作我们拥有的一堆应用程序的IdP,主要是一个Drupal 站点。我在IdP 上使用SQL 作为身份验证源,它可以对用户进行身份验证,响应返回到Drupal 并且用户已通过身份验证。一切顺利!

但是,我们还需要使用社交登录(使用 Twitter、Facebook 等登录)。 SimpleSAMLphp 支持 OAuth,我已经设置了它,并且使用社交帐户 SimpleSAMLIdP 上登录> 创建会话和 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


【解决方案1】:

背景

您的问题是您的身份提供者配置为使用 sql auth 而不是 twitter、linkedin 等。drupal 站点会将您发送到 IDP,而 IDP 仅了解 sql。虽然您确实为社交配置了身份验证源,但 SSP 允许您独立于 IDP 配置测试和验证这些身份验证源。这就是为什么 SSP 只是在模板中显示社交属性,而不是让您使用它们登录到 drupal。

选项 A

multiauth 将让您定义一个包含您的社交和 sql 的 authsource。然后,您将 idp 配置为使用新的 multiauth authsource

选项 B

每个社交提供者的 IDP。我们为每个社交提供者运行一个 IDP。我们在saml20-idp-hosted.php 中定义了多个 IDP(具有唯一的 entityID) - 每个社交帐户一个。我们这样做是因为我们的每个 SP 只想信任所有已配置社交 IDP 的子集。

此选项中的每个 SP 都将在 saml20-idp-remote.php 中包含额外的 IDP 数据

选项 C

外包。我们以SaaS product 运行这种社交到 saml 网关。如果您不喜欢自己运行东西,或者如果您有多个 SP 都想要不同的社交提供者,或者每个 SP 使用不同的社交 api 密钥/秘密,那么这是有道理的。

【讨论】:

    猜你喜欢
    • 2014-07-25
    • 2021-05-28
    • 1970-01-01
    • 2013-10-12
    • 2019-12-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多