Configuring Mimecast for Log Collection via API
Configuring Mimecast for Log Collection via API
You must complete the following to successfully configure and verify your Mimecast log collector:
Set up the Mimecast application
Configure collection
Verify successful configuration
1. Set up the Mimecast application
You must identify your regional base URL, enable enhanced logging, add a custom API application, create a new user profile and application setting, and generate API access and secret Keys in the Mimecast administrator portal.
Identify your base domain URL
Copy and paste the base URL for your host region in a safe place for later.
Enable enhanced logging for your account
You must enable the log API endpoint in the Mimecast console.
Log into the Administration Console.
Go to Administration > Account > Account Settings menu.
Click the Enhanced Logging section.
Enable the log type(s) you would like to get by using the BluSapphire Mimecast collector.
For more information on enabling the log endpoint, see SIEM log API endpoint. For a description of Mimecast SIEM logs, see Understanding SIEM Logs.
Add a custom API application for integration with BluSapphire
You must add an API application in the Mimecast console. This procedure creates an Application ID and Application Key that you target when you configure the Mimecast collector later in the BluSapphire later.
Log into the Administration Console.
Navigate to the Administration | Services | API and Platform Integrations menu.
Click the Your Application Integrations tab.
Click Add API Application.
In the details section, provide the following information:
Application Name— Name of your BluSapphire Integration. Example: "BluSapphire Log Collector"
Category— SIEM Integration
Select the Enable Extended Session option so that the access keys generated for the application do not expire based on the Authentication Profile's Authentication TTL value. This option prevents interruptions to the BluSapphire Mimecast collector.
Description— Provide an additional description of the integration. For example, "Our cybersecurity Managed Detection and Response (MDR) provider"
Click Next.
In the settings section, provide the following information:
Developer: BluSapphire
Email: info@blusapphire.com
Click Next.
Verify the information in the Summary page.
Click Add.
Copy and paste the Application ID and Application Key in a safe place for later.
Create a user profile for the BluSapphire integration
You must create a user profile with the correct permissions to generate API keys for Mimecast collector authentication.
To create a new user:
Log into the Administration Console.
Navigate to the Administration | Directories | Internal Directories menu.
Click the internal domain you want for your new user, which is used to get API keys later.
Click New Address and complete the form to create a new user.
Copy and paste the user name and password in a safe place for later.
To add the user to the administrative role:
Navigate to the Administration | Account | Roles menu.
Right-click the Basic Administrator role and click Add users to role.
Select the new user that you created.
Click Add Selected Users.
To create a new group to add your users:
Navigate to the Administration | Directories | Profile Groups menu.
Click the + icon on a parent directory to create a new child group directory named "New Folder." If you aren't sure which parent directory to add the group under, use Root. To edit the name, click the group and change the name in the text box. Example: "BluSapphire Logs Admin"
Click the Build tab, and then click Add Email Addresses.
Enter the email address of the new user that you created. Click Save and Exit.
To create a new authentication profile:
Navigate to the Administration | Services | Applications menu.
Click the Authentication Profiles tab.
Click New Authentication Profile.
In the Description field, enter a name for your new profile. Example: "API Authentication Profile for the BluSapphire Log collector."
On the Authentication TTL dropdown menu, click Never Expires.
Leave the other settings as default.
Click Save and Exit.
To create a new application setting:
You must create a new application setting to bind the user group, authentication profile, and custom API application to each other.
Navigate to the Administration | Services | Applications menu.
Click the New Application Settings tab.
Click New Authentication Profile.
In the Description field, enter a name for your new setting. Example: "API Application Setting for the BluSapphire Log collector."
In the Group field, paste the group you created.
In the Authentication Profile field, select the authentication profile you created.
Click Save and Exit.
Troubleshooting: If you receive an error during this step, you must reach out to Mimecast customer service to perform a workaround that only Super Administrator users and Mimecast employees can perform.
Get your authentication token
Now that you have a dedicated user who will receive an Authentication Token that will never expire, the final preparation task is to get the Authentication Token for the user.
Get an Authentication token using Windows
NOTE: This process has been tested in Powershell version 4 and 5.
Copy paste the following script into a Powershell window:
$appId = Read-Host -Prompt 'Input your registered application id'
$creds = Get-Credential
$discoverPostBody = @{"data" = ,@{"emailAddress" = $creds.UserName}}
$discoverPostBodyJson = ConvertTo-Json $discoverPostBody
$discoverRequestId = [GUID]::NewGuid().guid
$discoverRequestHeaders = @{"x-mc-app-id" = $appId; "x-mc-req-id" = $discoverRequestId; "Content-Type" = "application/json"}
$discoveryData = Invoke-RestMethod -Method Post -Headers $discoverRequestHeaders -Body $discoverPostBodyJson -Uri "https://api.mimecast.com/api/login/discover-authentication"
$baseUrl = $discoveryData.data.region.api
$keys = @{}
$uri = $baseUrl + "/api/login/login"
$requestId = [GUID]::NewGuid()
$netCred = $creds.GetNetworkCredential()
$PlainPassword = $netCred.Password
$credsBytes = [System.Text.Encoding]::ASCII.GetBytes($creds.UserName + ":" + $PlainPassword)
$creds64 = [System.Convert]::ToBase64String($credsBytes)
$headers = @{"Authorization" = "Basic-Cloud " + $creds64; "x-mc-app-id" = $appId; "x-mc-req-id" = $requestId; "Content-Type" = "application/json"}
$postBody = @{"data" = ,@{"username" = $creds.UserName}}
$postBodyJson = ConvertTo-Json $postBody
$data = Invoke-RestMethod -Method Post -Headers $headers -Body $postBodyJson -Uri $uri
"Meta: " + $data.meta
"Access key: " + $data.data.accessKey
"Secret key: " + $data.data.secretKey
"Fail: " + $data.fail.errorss
When prompted, enter the Application ID value received when you registered your application.
Enter the email address and password of the user created in Step 1: Create a new user into the Windows credentials box that will launch after you have pasted the script into the Powershell window.
Copy and paste the accessKey and secretKey values printed at the bottom of the Powershell window to use in your application.
IMPORTANT: be sure to copy and paste these values to a text editor and remove any line breaks caused by your Powershell window size before using the values.
Getting an Authentication token using Mac OSX or *nix systems
Open a terminal application and type the following command to generate a base64 encoded string of your administrators email address and password:
echo -n 'email_address:password' | openssl base64
Where email_address is the email address of the user created in Step 1 and password is the password created for the user in Step 1. Be sure to include the ":" between the email_address and password as authentication will fail without it.
Type the following command to use cURL to login to the Mimecast API and get your Authentication Token.
curl -i -H 'Authorization: Basic-Cloud base64_encoded_username_password' -H 'x-mc-app-id: app_id' -H 'Content-Type:application/json' https://xx-api.mimecast.com/api/login/login --data-binary '{"data":[{"username": "email_address"}]}'
Where:
base64_encoded_username_password is the value generated in step 1. app_id is your Application ID value received when you registered your application. xx-api is the base url for the region where your Mimecast account is hosted as documented in the System Requirements section. email_address is the email address of the user created in Step 1: Create a new user.
An example response to this command is:
HTTP/1.1 200 OK | |
Content-Type: application/json | |
Cache-control: no-store | |
Pragma: no-cache | |
Content-Length: 375 | |
Content-MD5: 124911b164dbd3b9e823610a2eb4996a | |
Date: Mon, 25 Jul 2016 16:19:37 +0100 | |
Connection: Keep-Alive | |
{"meta":{"status":200},"data":[{"accessKey":"LOWgx__TRUNCATED__Ect2nN","secretKey":"jD9DVicE2__TRUNCATED__EJdC4e/Q\u003d\u003d","duration":3153600000000,"bindingType":"one_step","extendOnValidate":false}],"fail":[]} |
Copy and paste the accessKey and secretKey values from the response to use in your application.
IMPORTANT: make sure to replace the \u003d\u003d at the end of the secret key with == (\u003d is the uri encoding for the = symbol and is printed to the terminal, however the actual string should contain the = symbol when used)
Last updated