Validating Client and Tenant ID using Regular expression || MSAL4J

Rahul Kapoor 21 Reputation points
2021-02-08T12:42:16.38+00:00

Hi
I am using confidential Client Application object for fetching access token. I want to validate the client id and tenant id using regular expression. I am unable to find a valid document which explains the pattern for both.
Kindly help in the issue

I am using the below regex for matching client ID -
^[a-zA-Z0-9-]+$" -> This is for Alphanumeric characters with Hypen symbol also.

ConfidentialClientApplication app = ConfidentialClientApplication
.builder(<CLIENT-ID>, ClientCredentialFactory.createFromCertificate(certificate, ""))
.authority(https://login.microsoftonline.com/<TENANT-ID>/v2.0).build();

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,668 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Marilee Turscak-MSFT 34,311 Reputation points Microsoft Employee
    2021-02-26T16:00:03.893+00:00

    The regex validation for client id should be the same implementation as for any other input string validations, like passwords, emails etc.

    As of now, unfortunately there is no official document which talks about how to specifically do text validation for this scenario. Refer to this github issue.

    For these kind of validations, custom policies or jquery validations can be helpful. Have a look at this document for claims schema pattern details for validations.

    General documents are available here - doc1, doc2, Stack Overflow post. You can also refer to this as an example.

    Also, I am unsure from this description if you are having a particular issue or if you are mainly just looking for documentation for implementing the validation. Please share the details of the error/issue, if you are facing any.