OTPBySMTPValve
Warning
This valve is blocking - this may hurt throughput and cause performance issues since other pipes won't be able to execute while this valve is waiting on a long-running operation in the same instance of the pipes module, for example due to a network request, disk access or similar. Try to limit the usage of blocking valves, try to ensure that they are fast to execute, and if needed, consider deploying multiple instances of the pipes module.
Note
Valve for delivering one-time passwords by SMTP.
Properties
Name | Description | Default value | Mandatory | Supports property expansion |
---|---|---|---|---|
generated_otp_name | Item property containing the generated otp. | generated_otp | No | No |
mail_param_name | Property containing the recipient mail address. | No | Yes | |
userid_param_name | Property containing the username. | User-Name | No | Yes |
mail_template | The file path to the mail message template. | resources/otp_mail_template.mustache | No | No |
smtp_settings | SMTP server Settings. | Yes | No | |
smtp_host | SMTP host address. Overrides SMTP server Settings. | No | No | |
smtp_port | SMTP port number. Overrides SMTP server Settings. | 587 | No | No |
smtp_from_address | The from mail address. Overrides SMTP server Settings. | No | No | |
smtp_username | Username for the smtp account. Overrides SMTP server Settings. | No | No | |
smtp_password | Password for the smtp account. Overrides SMTP server Settings. | No | No | |
start_tls_enabled | true | No | No | |
ssl_on_connect | false | No | No | |
ssl_check_server_identity | false | No | No | |
socket_connection_timeout | 15 | No | No | |
removal_prefixes | Prefixes to be removed as a comma separated list. | smtp:,SMTP:,sip: | No | No |
message_subject_key | Locale key for the mail message subject. Found in lang/*/strings.xml | valves.otp.smtp.message.subject | No | No |
message_body_key | Locale key for the mail message body. Found in lang/*/strings.xml | valves.otp.smtp.message.body | No | No |
message_subject | Static, non localizeable message. Overrides message_subject_key parameter. | No | No | |
message_body | Static, non localizeable message. Overrides message_body_key parameter. | No | No | |
dynamic_values | Dynamic template mapping values. Separated by pipe (|) Replaces key with value in the message sent to user. Syntax: $$USERNAME={{item.givenName}}|$$SOME_OTHER_KEY={{item.somevalue}} See example below. |
No | Yes |
Advanced properties
Additional configuration properties to be used for recipients like +467012345678@phenixidentity.com
Name | Description | Default value | Mandatory | Supports property expansion |
---|---|---|---|---|
wash_mobile_number | If the mobile number should be washed (i.e. removal of whitespaces, - and other non-number characters). | false | No | No |
recipient_prefix | Prepends the recipient number with a country prefix if it starts with '0'. (example: +46) | No | No | |
force_prefix | Always prefixes the recipient number. | false | No | No |
remove_leading_plus | If the leading + character should be removed from the mobile number. | false | No | No |
Example Configuration
A connection to SMTP can be made using scenario's in PhenixID configuration portal.
So some of the parameters will be contained within that global smtp configuration.
If a connection has been created already, the id for smtp_settings will be used and configuration will look similar to the first example.
The valve can also be added with all the parameters, through the Advanced tab in PhenixID configuration portal.
Configuration will then look similar to the second example.
{
"name": "OTPBySMTPValve",
"enabled": "true",
"config": {
"smtp_settings": "fff21007-4fbe-450d-8aa2-3756a44745fa",
"start_tls_enabled": "true",
"userid_param_name": "User-Name",
"mail_param_name": "mail",
"generated_otp_name": "generated_otp",
"mail_template": "resources/otp_mail_template.mustache",
"socket_connection_timeout": "15",
"removal_prefixes": "smtp:,SMTP:,sip:",
"message_body_key":"valves.otp.smtp.message.body",
"dynamic_values" : "$$USERNAME={{item.givenName}}"
}
}
{
"name": "OTPBySMTPValve",
"config": {
"start_tls_enabled":"true",
"socket_connection_timeout" : "30",
"removal_prefixes" : "smtp:,SMTP:",
"generated_otp_name" : "generated_otp",
"userid_param_name":"{{request.username}}",
"mail_param_name":"{{request.mail}}",
"mail_template" : "resources/otp_mail_template.mustache",
"smtp_host" : "smtp.company.org",
"smtp_port" : "587",
"smtp_username" : "noreply@company.org",
"smtp_password" : "{enc}Lsd28p9AMU1oAjwHgHprVdWmGteLZ6XYxY/AxkBusXg=",
"smtp_from_address" : "noreply@company.org",
"message_subject": "Hello $$USERNAME",
"message_body": "Hello $$USERNAME, your otp is $$OTP",
"wash_mobile_number" : "true",
"recipient_prefix" : "+46",
"dynamic_values" : "$$USERNAME={{item.givenName}}"
}
}
In the example above the value for attribute mail has been picked up earlier in the flow.
The value for userid_param_name has been picked up from the request. Most common values are {{request.User-Name}} for RADIUS and {{request.username}} for HTTP.
In the first example the message sent to user is fetched from the entry: valves.otp.smtp.message.body located in the lang/en/strings.xml file.
Requirements
Item set must have at least one entry.