You are here

public static function Utilities::createAuthnRequest in SAML SP 2.0 Single Sign On (SSO) - SAML Service Provider 8

1 call to Utilities::createAuthnRequest()
MiniOrangeAuthnRequest::initiateLogin in src/MiniOrangeAuthnRequest.php

File

src/Utilities.php, line 258

Class

Utilities
This file is part of miniOrange SAML plugin.

Namespace

Drupal\miniorange_saml

Code

public static function createAuthnRequest($acsUrl, $issuer, $nameid_format, $force_authn = 'false', $rawXml = false) {
  $requestXmlStr = '<?xml version="1.0" encoding="UTF-8"?>' . '<samlp:AuthnRequest xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" ID="' . self::generateID() . '" Version="2.0" IssueInstant="' . self::generateTimestamp() . '"';
  if ($force_authn == 'true') {
    $requestXmlStr .= ' ForceAuthn="true"';
  }
  $requestXmlStr .= ' ProtocolBinding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" AssertionConsumerServiceURL="' . $acsUrl . '" ><saml:Issuer xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">' . $issuer . '</saml:Issuer><samlp:NameIDPolicy AllowCreate="true" Format="' . $nameid_format . '"
                        /></samlp:AuthnRequest>';
  if ($rawXml) {
    return $requestXmlStr;
  }
  $deflatedStr = gzdeflate($requestXmlStr);
  $base64EncodedStr = base64_encode($deflatedStr);
  $urlEncoded = urlencode($base64EncodedStr);
  return $urlEncoded;
}