title: SimpleSAMLphp generate assertion
body: <p>I'm using <code>SimpleSAMLphp</code> as an <code>IdP</code> for a bunch of applications we have, chiefly a <strong>Drupal</strong> site. I've used SQL as an authsource on the <code>IdP</code> and that works to authenticate users, the response returns to <strong>Drupal</strong> and the users are authenticated. All good !</p>
  
  <p>However we also need to use social login (login with Twitter, Facebook etc). <strong>SimpleSAMLphp</strong> supports <strong>OAuth</strong>, I've set it up and the login works on the <strong>IdP</strong> with the social accounts, <strong>SimpleSAML</strong> creates the session and cookies but I'm not authenticated on the Drupal site.    </p>
  
  <p>What I need to do is complete the request by returning to Drupal and authenticating the user there, that is, to issue an assertion back to Drupal on success.</p>
  
  <p>Just like in the SQL source, I've mapped the attributes in each of the source files (Twitter.php, Facebook.php etc) however where SQL auth returns to Drupal and creates a session, the others just display their attributes in a template.</p>
  
  <p>How do I generate and send back an assertion for <strong>Drupal</strong> from these social logins so as to authenticate my users there ?</p>
  
  <p><code>saml10-sp-remote.php (IdP)</code></p>
  
  <pre><code>$metadata['https://durpal_url/simplesaml_drupal_sp/module.php/saml/sp/metadata.php/sp'] = array (
    'SingleLogoutService' =&gt;
    array (
      0 =&gt;
      array (
        'Binding' =&gt; 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
        'Location' =&gt; 'https://durpal_url/simplesaml_drupal_sp/module.php/saml/sp/saml2-logout.php/sp',
      ),
      1 =&gt;
      array (
        'Binding' =&gt; 'urn:oasis:names:tc:SAML:2.0:bindings:SOAP',
        'Location' =&gt; 'https://durpal_url/simplesaml_drupal_sp/module.php/saml/sp/saml2-logout.php/sp',
      ),
    ),
    'AssertionConsumerService' =&gt;
    array (
      0 =&gt;
      array (
        'index' =&gt; 0,
        'Binding' =&gt; 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST',
        'Location' =&gt; 'https://durpal_url/simplesaml_drupal_sp/module.php/saml/sp/saml2-acs.php/sp',
      ),
      1 =&gt;
      array (
        'index' =&gt; 1,
        'Binding' =&gt; 'urn:oasis:names:tc:SAML:1.0:profiles:browser-post',
        'Location' =&gt; 'https://durpal_url/simplesaml_drupal_sp/module.php/saml/sp/saml1-acs.php/sp',
      ),
      2 =&gt;
      array (
        'index' =&gt; 2,
        'Binding' =&gt; 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact',
        'Location' =&gt; 'https://durpal_url/simplesaml_drupal_sp/module.php/saml/sp/saml2-acs.php/sp',
      ),
      3 =&gt;
      array (
        'index' =&gt; 3,
        'Binding' =&gt; 'urn:oasis:names:tc:SAML:1.0:profiles:artifact-01',
        'Location' =&gt; 'https://durpal_url/simplesaml_drupal_sp/module.php/saml/sp/saml1-acs.php/sp/artifact',
      ),
    ),
    'certData' =&gt; 'xxxx',
  );
  </code></pre>
  
  <p><code>authsources.php (IdP)</code></p>
  
  <pre><code>'sql' =&gt; array(
          'sqlauth:SQL',
          'dsn' =&gt; 'mysql:host=localhost;dbname=db',
          'username' =&gt; 'user',
          'password' =&gt; 'pass',
          'query' =&gt; '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' =&gt; array(
      'authfacebook:Facebook',
      'api_key' =&gt; 'xxxx',
      'secret' =&gt; 'xxxx',
      'req_perms' =&gt; 'email',
  ),
  
  'linkedin' =&gt; array(
      'authlinkedin:LinkedIn',
      'key' =&gt; 'xxxx',
      'secret' =&gt; 'xxxx',
  ),
  
  'twitter' =&gt; array(
      'authtwitter:Twitter',
      'key' =&gt; 'xxxx',
      'secret' =&gt; 'xxxx',
      'force_login' =&gt; true,
  ),
  </code></pre>
  
  <p><code>saml20-idp-remote.php (SP, Drupal)</code></p>
  
  <pre><code>$metadata['http://idp_url/simplesaml/saml2/idp/metadata.php'] = array (
    'metadata-set' =&gt; 'saml20-idp-remote',
    'entityid' =&gt; 'http://idp_url/simplesaml/saml2/idp/metadata.php',
    'SingleSignOnService' =&gt;
    array (
      0 =&gt;
      array (
        'Binding' =&gt; 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
        'Location' =&gt; 'http://idp_url/simplesaml/saml2/idp/SSOService.php',
      ),
    ),
    'SingleLogoutService' =&gt;
    array (
      0 =&gt;
      array (
        'Binding' =&gt; 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
        'Location' =&gt; 'http://idp_url/simplesaml/saml2/idp/SingleLogoutService.php',
      ),
    ),
    'certData' =&gt; 'xxx',
    'NameIDFormat' =&gt; 'urn:oasis:names:tc:SAML:2.0:nameid-format:transient',
  );
  </code></pre>
  
  <p><code>saml20-idp-hosted.php (IdP)</code></p>
  
  <pre><code>$metadata['__DYNAMIC:1__'] = array(
      'host' =&gt; '__DEFAULT__',
      'privatekey' =&gt; 'mysite.com.key',
      'certificate' =&gt; 'mysite.com.crt',
      'auth' =&gt; 'sql',
  );
  </code></pre>