initsamlauthrequest

Starts the SAML Single Sign-On (SSO) login process by redirecting the user to an external login provider such as Okta, Azure AD, or ADFS. Before using this function, both the Identity Provider (IdP) and Service Provider (SP) must already be configured in ColdFusion Administrator or Application.cfc.

InitSAMLAuthRequest(options) → returns void

This function requires Adobe ColdFusion 2021 and up.  Not supported on Lucee, etc.

Argument Reference

options struct
Required

Structure containing the SAML authentication settings.

options.idp.name string
Required

Name of the configured Identity Provider (IdP). The IdP is the external system that handles user login, such as Okta or Azure Active Directory.

options.sp.name string
Required

Name of the configured Service Provider (SP). The SP represents your ColdFusion application that uses the external login system for authentication.

options.relayState string

Optional value used to return users to a specific page after successful login.

options.template string

Optional template page shown before redirecting users to the Identity Provider. Used only with POST binding.

options.lifetime numeric

Time in seconds that the authentication request remains valid while waiting for a response from the Identity Provider.

Compatibility

ColdFusion:

Version 2021+ Requires the SAML package to be installed using ColdFusion Package Manager (CFPM). Configure the Identity Provider and Service Provider in ColdFusion Administrator under Security > SAML before using this function.

Links more information about initsamlauthrequest

Examples
Sample code invoking the initsamlauthrequest function

This example starts a SAML login request using Okta as the Identity Provider (IdP). The ColdFusion application acts as the Service Provider (SP). Both configurations must already exist in ColdFusion Administrator under Security > SAML.

<cfscript>
config = {

    // External login provider
    idp = {
        name = "OktaIDP"
    },

    // ColdFusion application
    sp = {
        name = "EmployeePortal"
    },

    // Optional page to return after login
    relayState = "dashboard"
};

// Redirect user to the login provider
InitSAMLAuthRequest(config);
</cfscript>

Expected Result: The user is redirected to the configured external login page for authentication.

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub