Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion auth0/actions/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
all: dist/silent-account-linking.js dist/post-login-claims.js dist/render-privacy-policy-form.js dist/mfa-when-enrolled.js
all: dist/silent-account-linking.js dist/post-login-claims.js dist/render-privacy-policy-form.js dist/mfa-when-enrolled.js dist/sms-to-slack.js

dist/%.js: %.ts
npm run build
Expand Down
34 changes: 34 additions & 0 deletions auth0/actions/sms-to-slack.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import {Event, CustomPhoneProviderAPI} from "@auth0/actions/custom-phone-provider/v1";

// noinspection JSUnusedLocalSymbols
/**
* Handler to be executed while sending an email notification
* @param {Event} event - Details about the user and the context in which they are logging in.
* @param {CustomPhoneProviderAPI} api - Methods and utilities to help change the behavior of sending a phone notification.
*/
exports.onExecuteCustomPhoneProvider = async (event: Event, api: CustomPhoneProviderAPI) => {
const SLACK_WEBHOOK_URL = event.secrets.SLACK_WEBHOOK_URL;

console.log(`onExecuteCustomPhoneProvider event: ${JSON.stringify(event)}`);

const {message_type, as_text, recipient} = event.notification;
const slackText = `Type ${message_type} \nRecipient: ${recipient} \nMessage: ${as_text}`;

const axios = require('axios');

// send to slack
const {data} =
await axios({
method: 'post',
url: `${SLACK_WEBHOOK_URL}`,
data: {
text: slackText
},
headers: {
'Content-Type': 'application/json'
},
timeout: 5000 // 5 sec
});

console.log(`response from slack: ${data}`);
};
8 changes: 5 additions & 3 deletions tf/02-donor-website.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ resource "auth0_user" "user1" {
connection_name = data.auth0_connection.Username-Password-Authentication.name
email = "user1@atko.email"
password = "user1@atko.email"
email_verified = true
}

resource "auth0_user" "user2" {
connection_name = data.auth0_connection.Username-Password-Authentication.name
email = "user2@atko.email"
password = "user2@atko.email"
connection_name = data.auth0_connection.Username-Password-Authentication.name
email = "user2@atko.email"
password = "user2@atko.email"
custom_domain_header = "id.${var.top_level_domain}"
email_verified = true
}


Expand Down
1 change: 1 addition & 0 deletions tf/03-social-login.tf
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ resource "null_resource" "build_auth0_actions" {
sal_acntlink_ts_hash = filesha1("${path.module}/../auth0/actions/silent-account-linking.ts")
mfa_ts_hash = filesha1("${path.module}/../auth0/actions/mfa-when-enrolled.ts")
form_ts_hash = filesha1("${path.module}/../auth0/actions/render-privacy-policy-form.ts")
sms_to_slack_ts_hash = filesha1("${path.module}/../auth0/actions/sms-to-slack.ts")
}

provisioner "local-exec" {
Expand Down
52 changes: 52 additions & 0 deletions tf/12-ciba.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
## Email Server
resource "auth0_email_provider" "mailtrap" {
name = "smtp"
enabled = true
default_from_address = "noreply@replate.dev"
credentials {
smtp_host = var.mailtrap_smtp_host
smtp_port = var.mailtrap_smtp_port
smtp_user = var.mailtrap_smtp_user
smtp_pass = var.mailtrap_smtp_pass
}
}

resource "auth0_phone_provider" "custom_phone_provider" {
name = "custom"
disabled = false

configuration {
delivery_methods = ["text"]
}

credentials {}

depends_on = [
auth0_action.sms_to_slack
]
}

resource "auth0_action" "sms_to_slack" {

depends_on = [null_resource.build_auth0_actions]

name = "SMS to Slack"
runtime = "node22"
deploy = true
code = file("${path.module}/../auth0/actions/dist/sms-to-slack.js")

supported_triggers {
id = "custom-phone-provider"
version = "v1"
}

dependencies {
name = "axios"
version = "1.7.9"
}

secrets {
name = "SLACK_WEBHOOK_URL"
value = var.slack_webhook_url
}
}
27 changes: 27 additions & 0 deletions tf/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,33 @@ variable "microsoft_client_secret" {
sensitive = true
}

## mailtrap
variable "mailtrap_smtp_host" {
type = string
default = "sandbox.smtp.mailtrap.io"
}

variable "mailtrap_smtp_port" {
type = number
default = 2525
}

variable "mailtrap_smtp_user" {
type = string
}

variable "mailtrap_smtp_pass" {
type = string
sensitive = true
}

# slack
variable "slack_webhook_url" {
type = string
sensitive = true
}


## AoB
variable "default-password" {
type = string
Expand Down