Lightning.Workflows.WebhookAuthMethod (Lightning v2.15.0-pre5)
View SourceThe Lightning.Workflows.WebhookAuthMethod module defines the schema for webhook authentication methods and provides functionalities to handle them.
Schema
The schema represents a webhook authentication method that can be of two types - :basic and :api. The basic type requires a username and password, while the api type requires an api_key.
The schema fields include:
name: the name of the authentication methodauth_type: the type of authentication, can be:basicor:apiusername: the username required for basic authenticationpassword: the password required for basic authentication (virtual field)hashed_password: the hashed version of the passwordapi_key: the API key required for API authentication
Associations
Each WebhookAuthMethod belongs to a project.
It is also associated with multiple triggers through a many_to_many relationship.
Validations and Constraints
This module provides changeset functions for casting and validating the schema fields and applying unique constraints on name, username, and api_key within the project scope.
Password Verification
The valid_password?/2 function is provided to verify passwords and it avoids timing attacks by using Bcrypt.no_user_verify/0 when there is no webhook_auth_method or the webhook_auth_method doesn't have a password.
Summary
Functions
Retrieves basic auth strings from a WebhookAuthMethod for use in log scrubbing.
Retrieves sensitive values from a WebhookAuthMethod for use in log scrubbing.
Types
Functions
Retrieves basic auth strings from a WebhookAuthMethod for use in log scrubbing.
Returns a list of base64-encoded "username:password" strings that might appear in Authorization headers.
Examples
iex> basic_auth_for(%WebhookAuthMethod{auth_type: :basic, username: "user", password: "pass"})
["dXNlcjpwYXNz"]
iex> basic_auth_for(%WebhookAuthMethod{auth_type: :api, api_key: "secret"})
[]
Retrieves sensitive values from a WebhookAuthMethod for use in log scrubbing.
For :basic auth, returns the username and password.
For :api auth, returns the api_key.
Examples
iex> sensitive_values_for(%WebhookAuthMethod{auth_type: :basic, username: "user", password: "pass"})
["pass"]
iex> sensitive_values_for(%WebhookAuthMethod{auth_type: :api, api_key: "secret123"})
["secret123"]
iex> sensitive_values_for(nil)
[]