Creatio.Auth (creatio v0.3.1)

Copy Markdown

Authentication services for Creatio CRM.

Supports both Forms Authentication (AuthService.svc with BPMCSRF and cookies) and OAuth 2.0 (Identity Service client credentials grant).

Summary

Functions

Logs into Creatio using Forms authentication (Username & Password).

Authenticates via OAuth 2.0 Client Credentials against the Creatio Identity Service.

Checks the health of the OAuth functionality on the Creatio instance.

Retrieves the OpenID configuration from the Identity Service (/.well-known/openid-configuration).

Functions

login_forms(client_or_req, username, password, opts \\ [])

@spec login_forms(
  Creatio.Client.t() | Req.Request.t(),
  String.t(),
  String.t(),
  keyword()
) ::
  {:ok, Creatio.Client.t()} | {:error, Creatio.Error.t()}

Logs into Creatio using Forms authentication (Username & Password).

Sends a request to /ServiceModel/AuthService.svc/Login, captures the .ASPXAUTH, BPMLOADER, and BPMCSRF cookies, and configures the client with the required cookie and bpmcsrf headers for subsequent requests.

Examples

client = Creatio.new(base_url: "https://mycreatio.com")
{:ok, client} = Creatio.Auth.login_forms(client, "User01", "SecretPass")

login_oauth(client, opts \\ [])

@spec login_oauth(Creatio.Client.t(), keyword()) ::
  {:ok, Creatio.Client.t(), map()} | {:error, Creatio.Error.t()}

Authenticates via OAuth 2.0 Client Credentials against the Creatio Identity Service.

Sends a request to {identity_service_url}/connect/token with grant_type=client_credentials. On success, configures the client with the Bearer access token.

Options

  • :client_id - The OAuth client ID (defaults to client.client_id).
  • :client_secret - The OAuth client secret (defaults to client.client_secret).
  • :identity_service_url - The base URL of the Identity Service (defaults to client.identity_service_url).
  • :token_url - Overrides the token endpoint path (defaults to "/connect/token").

oauth_health_check(client, opts \\ [])

@spec oauth_health_check(Creatio.Client.t(), keyword()) ::
  {:ok, map() | String.t()} | {:error, Creatio.Error.t()}

Checks the health of the OAuth functionality on the Creatio instance.

Sends a GET request to /0/api/OAuthHealthCheck.

openid_configuration(client_or_url, opts \\ [])

@spec openid_configuration(Creatio.Client.t() | String.t(), keyword()) ::
  {:ok, map()} | {:error, Creatio.Error.t()}

Retrieves the OpenID configuration from the Identity Service (/.well-known/openid-configuration).