Configure User Authentication in MATLAB Online Server
To authenticate user access in MATLAB® Online Server™, you must configure an identity provider (IdP) that MATLAB Online Server can use to authenticate and allow users. The IdP allows the use of user credentials for the organization through a user name/password prompt or single sign-on, depending on the type of identity provider configured.
At least one IdP must be configured to sign in to MATLAB
Online Server. When you issue the command to generate overrides, the command generates a
configuration for the IdP of type local (see Local for details) with the user
name admin
and password
that are defined in
install.config
.
To apply the IdP configuration, edit the settings in the file
.
For example,
<matlab_online_server_install_dir>/overrides/<cluster>/<namespace>/
authnz.yaml/opt/matlab_online_server/overrides/matlab-online-server/mathworks/authnz.yaml
.
Identity Provider
Identity Provider Specification
Field | Default Value | Required or Optional | Description |
---|---|---|---|
identityProviders | [] | Required | List of identity providers configured for use with MATLAB Online Server |
In YAML format:
identityProviders: - "<list of identity provider configurations>" |
Field | Default Value | Required or Optional | Description |
---|---|---|---|
name | "" | Required | Name of the identity provider |
displayName | "" | Optional | How the identity provider's name is displayed, specified using characters
|
type | "" | Required | The type of the identity provider. Based on the type, the identity provider properties vary; see next section. |
Identity Provider Types
MATLAB Online Server supports the following types of identity providers:
LOCAL
OAuth 2.0 and OIDC
MSAL
LDAP
SAML
Local
The LOCAL (local) identity provider type sets up the accounts that are in memory. For this identity provider, the accounts must be defined with the properties shown in the following table.
Field | Default Value | Required or Optional | Description |
---|---|---|---|
subjectId | "" | Required | User ID or username for the account |
displayName | "" | Required | Display name for the account |
password | "" | Required | Account password |
groups | [] | Optional | Groups that the user is associated with Example: |
extra | {} | Optional | Extra metadata that can be added to the user account when they sign in. Do not leave any field in the For the LOCAL identity provider only, enclose each metadata value
in square brackets, Example: |
Values in the settings for groups and extra are user-defined and not validated in any way.
In YAML format:
identityProviders: - id: "local" type: "local" displayName: "local" accounts: - subjectId: "admin" displayName: "Admin" password: "admin" groups: ["admin"] extra: {} - subjectId: "stateful" password: "stateful" extra: {} |
OAuth 2.0 and OIDC
OAuth 2.0 is an authorization protocol that allows third-party applications such as MATLAB Online Server to access resources on behalf of a user by obtaining an access token.
OpenID Connect (OIDC) is an authentication protocol that layers additional functionality on top of OAuth 2.0, most importantly an additional ID token containing user identification information. MATLAB Online Server does not currently support this ID token and instead requires a user information endpoint from the OAuth 2.0 protocol described in the OpenID specification.
To integrate MATLAB
Online Server with an OAuth 2.0 and OIDC identity provider (IdP) the
identityProviders
configuration supports the extra properties shown in
the table.
Field | Default Value | Required or Optional | Description |
---|---|---|---|
id | "" | Required | Specifies an identifier for this identityProviders
configuration. |
type | "" | Required | Identity provider type. For the OAuth 2.0 provider, type must
be "oauth" . |
clientId | "" | Required | Client identifier, which must be the same as the client identifier specified in the IdP. Note The supplied Kubernetes® secret must be the client secret associated with this
|
oidc | "" | Optional (Required if | Specifies a URL that MATLAB Online Server uses to look up the authorization, token, and user endpoints required by the OIDC protocol. Specify these subfields:
You must specify either the Example: oidc: enabled: true discoveryUrl: https://host/.well-known/... retryMode: "bypass" |
authorizationLocation | "" | Optional (Required if | Specifies the authorization endpoint described in https://datatracker.ietf.org/doc/html/rfc6749#page-18. If you
set the Example:
|
tokenLocation | "" | Optional (Required if | Specifies the token endpoint described in https://datatracker.ietf.org/doc/html/rfc6749#page-18. If you
set the Example:
|
graphLocation | "" | Optional (Required if | Specifies the user information endpoint described in https://openid.net/specs/openid-connect-core-1_0.html#UserInfo. This
endpoint must use the HTTPS protocol and can include port, path, and query
parameters. If you set the Example:
|
redirectpath | "/authnz/oauth/code" | Optional | Specifies the path portion of the redirection endpoint described in https://datatracker.ietf.org/doc/html/rfc6749#page-18. With
the default value, the result will be
Example:
|
secretName | "oauth-client" | Optional | Specifies the Kubernetes secret used to specify the secret associated with the
|
secretKey | "secretFile.yaml" | Optional | Specifies the name of the field in the Kubernetes secret used hold the secret value. Example: This example shows the sample contents of a secrets YAML file. apiVersion: "v1" kind: "Secret" metadata: name: "oauth-client" data: secret: "amwXbWYtcmVhbG0XZ2VjcmV0" To add this secret file to the Kubernetes cluster, use this command.
|
scopes | "user.read,openid,profile,email" | Optional | Comma-separated list of scopes that OAuth 2.0 protocol has. Do not insert a space after each comma. |
pkce | "" | Optional | The
For more details on PKCE, see https://auth0.com/docs/flows/authorization-code-flow-with-proof-key-for-code-exchange-pkce. Example: pkce: enabled: true challengeMethod: "S256" challengeLength: 32 |
subjectAttributeMapping | {} | Optional | Mapping between the keys in the OpenID Connect claims to values needed by MATLAB Online Server. Enclose each subjectAttributeMapping: displayName: "displayNameClaimKey" subjectId: "subjectIdClaimKey" groups: "groupsClaimKey" extra: email: "emailClaimKey" uid: "userIdClaimKey" gid: "groupIdClaimKey"
|
This authnz.yaml
file shows a sample OIDC specification.
replicaCount: 1 identityProviders: - id: "oauth" type: "oauth" clientId: "example-realm-oidc" authorizationLocation: "https://example-keycloak.example.com/realms/example-realm/protocol/openid-connect/auth" tokenLocation: "https://example-keycloak.example.com/realms/example-realm/protocol/openid-connect/token" graphLocation: "https://example-keycloak.example.com/realms/example-realm/protocol/openid-connect/userinfo" scopes: "openid,profile,roles" subjectAttributeMapping: subjectId: "preferred_username" displayName: "preferred_username" groups: "groups" extra: email: "email" uid: "uidNumber" gid: "gidNumber"
The graphLocation
, the user information endpoint, returns a JSON
response similar to the following:
{\"sub\":\"269e67a3-877a-4525-9c88-fb8707ac7a93\",\"randomAttribute\":\"user1RandomAttribute\", \"resource_access\":{\"account\":{\"roles\":[\"manage-account\",\"manage-account-links\", \"view-profile\"]}},\"email_verified\":false,\"groups\":[\"non-gpu\",\"user\"], \"preferred_username\":\"user1\",\"given_name\":\"user1_FirstName\", \"realm_access\":{\"roles\":[\"non-gpu\",\"user\"]},\"uidNumber\":\"7777\", \"name\":\"user1_FirstName user1_LastName\",\"gidNumber\":\"7777\", \"family_name\":\"user1_LastName\",\"email\":\"user1@example.com\"}
The license server logs an entry similar to the following:
21:52:53 (MLM) OUT: "MATLAB" user1@mathworks-matlab-pool-7b775bc559-ct2vv
Additionally, the MATLAB
Online Server user interface displays "user1"
as the username.
If other attributes passed as claims from the IdP must show up in the license server logs
and MATLAB
Online Server user interface, then update the mapping. For example, suppose you use
randomAttribute
instead of preferred_name
for the
license log entry and the username in the user interface.
identityProviders: - id: oauth type: oauth clientId: ex-realm-oidc authorizationLocation: https://ex-keycloak.matlabonlineserver.com/realms/ex-realm/protocol/openid-connect/auth tokenLocation: https://ex-keycloak.matlabonlineserver.com/realms/ex-realm/protocol/openid-connect/token graphLocation: https://ex-keycloak.matlabonlineserver.com/realms/ex-realm/protocol/openid-connect/userinfo scopes: "openid,profile,roles" subjectAttributeMapping: subjectId: "randomAttribute" displayName: "name" groups: "groups" extra: email: "email"
The license server will contain an entry similar to the following:
21:52:53 (MLM) OUT: "MATLAB" user1RandomAttribute@mathworks-matlab-pool-7b775bc559-ct2vv
The MATLAB
Online Server user interface displays "user1_FirstName user1_LastName"
as
the username.
Because the value set for the groups
field in the sample
subjectAttributeMapping
above and the associated values of the claims
returned by the IdP, the user is allowed to access a matlab-pool
configuration with the following in the associated matlab-pool.yaml
file.
resourceDefinition: allowedGroups: - "gpu" |
MSAL
The Microsoft® Security Authentication Library (MSAL) software package provides simplified configuration options for the OAuth 2.0 and OIDC authentication protocols. If you host the identity provider in Azure®, you can use this authentication method as a more streamlined alternative to the standard OAuth 2.0 and OIDC methods. If you want to delegate access to Azure storage resources in MATLAB Online Server, then you must use MSAL. For more details on Azure delegation, see Enable Access to Azure Storage Using Delegation.
Field | Default Value | Required or Optional | Description |
---|---|---|---|
clientId | "" | Required | Client ID value. Enclose the client ID in quotes. |
tenantId | "" | Required | Tenant ID value. Enclose the tenant ID in quotes. |
clientType | "confidential" | Optional | Type of OAuth 2.0 and OIDC client, specified as one of these values.
|
redirectPath | "/authnz/msal/code" | Optional | Specifies the path portion of the redirection endpoint described in https://datatracker.ietf.org/doc/html/rfc6749#page-18. |
scopes | "https://graph.microsoft.com/.default" | Optional | Comma-separated list of scopes used to obtain login and user information. Do not insert a space after each comma. |
useGroups | false | Optional | When set to true, the MATLAB
Online Server authentication service expects groups returned in the ID token
( |
subjectAttributeMapping | {} | Required | Mapping between the keys in the OpenID Connect claims to values needed by MATLAB Online Server. Enclose each subjectAttributeMapping: displayName: "displayNameClaimKey" subjectId: "subjectIdClaimKey" groups: "groupsClaimKey" extra: email: "emailClaimKey" uid: "userIdClaimKey" gid: "groupIdClaimKey"
|
This authnz.yaml
file shows a sample MSAL specification. Any attributes
that use default values can be omitted.
identityProviders: - id: msal type: msal displayName: "msal" clientId: "<client ID>" tenantId: "<tenant ID>" clientType: "confidential" redirectPath: "/authnz/msal/code" scopes: "https://graph.microsoft.com/.default" useGroups: false subjectAttributeMapping: subjectId: "oid" displayName: "preferred_username" groups: "groups" extra: {} |
LDAP
Lightweight Directory Access Protocol, also known as LDAP, is used to manage user identities. Identity management for MATLAB Online Server can apply user information from sources that you specify. The LDAP (ldap) identity provider type provides access control and tells MATLAB Online Server how to map user information tables to user information that MATLAB Online Server needs to manage these users.
For more about LDAP settings, visit https://ldap.com/.
The LDAP identity provider type requires extra properties, shown in the following table:
Field | Default Value | Required or Optional | Description |
---|---|---|---|
host | "" | Required | Specifies the host address for the LDAP, for example:
|
port | "" | Required | Specifies the LDAP port at the host address, for example:
|
useStartTls | false | Optional | Specifies if your LDAP server requires start TLS for connection. You must add the trusted certificates to the MATLAB Online Server trust store. See Add Certificates to MATLAB Online Server Trust Store. |
useSsl | false | Optional | Specifies if your LDAP server requires SSL for connection. You must add the trusted certificates to the MATLAB Online Server trust store. See Add Certificates to MATLAB Online Server Trust Store. |
baseDn | "" | Required | Specifies the starting point for the search tree in your LDAP environment.
For example: |
filter | "" | Required | Specifies an LDAP search filter. Use the search filter to scan a subset of users from the LDAP database. This allows you to reduce the scope of the LDAP search and control which organizational user may access MATLAB Online Server.
The default search filter is
For more
information on search filters, see LDAP filters at
|
adminDn | "" | Required | Specifies the administrator account used to establish the connection to the
LDAP server, for example: This account is used to query LDAP for the list of users. The account requires only read access to the directory and does not attempt to store information back into LDAP. |
adminPassword | "" | Required | Specifies the administrator account password used to establish the connection to the LDAP server. |
subjectAttributeMapping | {} | Required | Mapping between your internal LDAP values to values needed by MATLAB Online Server. For example, your user’s first name might be stored as
To map this
value in MATLAB
Online Server set Enclose each
subjectAttributeMapping: subjectId: "subject_id" displayName: "display_name" groups: "groups" extra: email: "email_address" uid: "uid_number" gid: "gid_number"
The The extra fields are for additional customization relating to the network files system (NFS):
Do not leave any field in the |
In YAML format:
identityProviders: - id: "ldap" type: "ldap" displayName: "LDAP" host: "ldap" port: 636 useStartTls: true useSsl: true baseDn: "dc=matlabonlineserver,dc=mwcloudtest,dc=com" filter: "(uid={0})" adminDn: "cn=readonly,dc=matlabonlineserver,dc=mwcloudtest,dc=com" adminPassword: "readonly" subjectAttributeMapping: subjectId: "uid" displayName: "cn" groups: "groups" extra: uid: "uidNumber" |
Add Certificates to MATLAB Online Server Trust Store
When you use LDAPS or LDAP with TLS, you must add the certificates to the global trust store. These certificates are validated against the LDAP/LDAPS server to establish a secure connection.
You must add the certificate information, shown in the following table, to authnz.yaml.
Field | Default Value | Required or Optional | Description |
---|---|---|---|
validateCertificate | true | Optional | The As an example, when LDAP is being used with useSSL= true or useTLS = true, the secure communication will be validated. If this field is disabled, the communication will still be LDAPS, but the certificate verification will be skipped. |
trustedCertificates | "" | Optional | The server certificates that are required for communicating with the
external identity providers in the authnz service must be provided using the
For example, when LDAP is being used with useSSL= true or useTLS = true, the secure communication must be validated and server certificates must be provided using this field. If the certificates are not provided, the LDAPS communication fails. |
In YAML format:
global: tls: validateCertificate: true trustedCertificates: | -----BEGIN CERTIFICATE----- MIIC5DCCAk2gAwIBAgIUZhnmeMmayNSTcAI2hgyxQt6GotUwDQYJKoZIhvcNAQEL ... VA/d/fQ+yxUjlDBc6ly/OwVFtIr0QykE -----END CERTIFICATE----- -----BEGIN CERTIFICATE----- BQAwgYMxCzAJBgNVBAYTAlVTMQswCQYDVQQIDAJNQTEPMA0GA1UEBwwGTmF0aWNr ... EdUg4pCYWUyFgGA/QCg4EniQEMN -----END CERTIFICATE----- |
The certificates must be formatted using PEM. For details on PEM, see:
SAML
Security Assertion Markup Language (SAML) is used to communicate with an identity provider. The SAML configuration for MATLAB Online Server ensures that the identities used to control access to MATLAB Online Server are managed by the Enterprise Identity Provider.
For more information about SAML settings, see https://wiki.oasis-open.org/security/.
The SAML identity provider type has extra properties, as shown in the following table:
Field | Default Value | Required or Optional | Description |
---|---|---|---|
authRequestBinding | "POST" | Optional | Binding method used for sending authentication requests to the Identity
Provider, specified as The HTTP Redirect method sends request data as query parameters in the URL, whereas HTTP POST method sends data more securely in the request body. |
assertionConsumerPath | "/authnz/saml/code" | Optional | The assertion consumer service (ACS) endpoint is a location where the SSO tokens are sent. ACS is applicable to all SAML versions and both the IdP-initiated and SP-initiated SSO profiles. |
corsAllowOriginDomain | "" | Required | The fully qualified domain name of the server that communicates with
MATLAB
Online Server, for example,
|
relyingPartyId | "" | Required | The hostname for the server that integrates with the SAML Identity Provider. This value is typically the hostname of the DNS entry for your MATLAB Online Server Kubernetes cluster, but depending on the integration product or service being used to expose the Identity Provider via the SAML system, this value can also be an arbitrary identifier. |
subjectAttributeMapping | {} | Required | The subject attribute mapping lets you set values for the user attributes that map to your organizational SAML assertion values. For example, your user’s first name might be stored as displayFirstName in the SAML system. To map this in
MATLAB
Online Server, set Enclose each
subjectAttributeMapping: subjectId: "<subject_id>" displayName: "<display_name>" groups: "<groups>" extra: email: "<email_address>" uid: "<uid_number>" gid: "<gid_number>"
Do not leave any field in the |
supportIdpInitiated | false | Optional | Set this field to In an IdP-initiated workflow, when users log in to their IdP (such as by using their SSO credentials), they are brought to a portal for accessing applications supported by their organization. When users select an application hosted by MATLAB Online Server, they are redirected to that application. To enable IdP-initiated workflows, you must:
Omit this field or set it to |
idpIssuer | "" | Optional (Required if | IdP issuer for IdP-initiated relay state. This value uniquely identifies the IdP issuer. It is often the name of the IdP client configuration that MATLAB Online Server uses to authenticate users. This value must be the same as
the one used to configure the default relay state parameter that the IdP uses when
communication with MATLAB
Online Server. When configuring the IdP field, the format of the default relay state
is
Separate these values with a pipe character
(
This field applies only when
|
idpMetadataUrl | "" | Optional (You must specify either
| URL to the required SAML metadata for SP-initiated or IdP-initiated profiles. |
idpMetadataXml | "" | Optional (You must specify either
| The value of Depending on the integration product or service being used to
expose the Identity Provider via SAML, there might be newline characters. Delete
those newline characters from the metadata XML before pasting the code into
|
In YAML format:
identityProviders: - id: "saml" type: "saml" assertionConsumerPath: "/service/assertionConsumer" corsAllowOriginDomain: "samlintegrationhost.yourcompanydomain.com" relyingPartyId: "matlab.domain.com" idpMetadataXml: | <xml content/> subjectAttributeMapping: displayName: "name" subjectId: "myNameId" groups: "groups" extra: email: "email" uid: "uidNumber" gid: "gidNumber" supportIdpInitiated: true idpIssuer: "idp-issuer-name|https://<IdP issuer redirect URL>" idpMetadataUrl: "https://<IdP metadata>" |
This code specifies both idpMetadataUrl
and
idpMetadataXml
for illustrative purposes. For your YAML file, specify
only one or the other of these fields.
If your MATLAB end users access AWS® storage resources such as Amazon S3™, you can specify additional fields to delegate access to AWS. With delegated access enabled, MATLAB end users can log in with their single sign-on credentials and do not have to provide a separate login to access these resources. For more details on enabling delegated access to AWS resources, see Enable Access to AWS Storage Using Delegation.