To address the issue where the first name includes a space and the vendor requires it to be formatted without that space, you can indeed use a regex to remove the space from the first name before sending the SAML assertion. For example, in Python, you can use the re.sub()
method to apply this regex.
You need a regular expression that matches spaces in the first name and replaces them with an empty string. After cleaning up the first name, you can join the first name and surname as required.
To implement it, you can use the regular expression \s+
which matches one or more whitespace characters (including spaces). You will use this regex in combination with joining the first name and surname.
Here is sample code:
import re
# Sample values for first name and last name
first_name = "John Charles"
last_name = "Jones"
# Step 1: Remove the space in the first name
cleaned_first_name = re.sub(r'\s+', '', first_name) # This will remove all spaces
# Step 2: Create the combined SSOID value
ssoid = f"{cleaned_first_name}.{last_name}"
# Results
print(f"Cleaned First Name: {cleaned_first_name}") # Output: JohnCharles
print(f"SSOID: {ssoid}") # Output: JohnCharles.Jones
If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.
hth
Marcin