supabase / auth

A JWT based API for managing users and issuing JWT tokens
https://supabase.com/docs/guides/auth
MIT License
1.38k stars 338 forks source link

Information about Contributing Regional SMS Provider (via Send SMS HTTP Hook) #1582

Closed J0 closed 1 week ago

J0 commented 3 months ago

Regional SMS Senders

We're accepting contributions for regional SMS providers via the Send SMS Hook.

Contributors for select SMS providers (e.g. msg91 (@MeetChaudhari) and Africa's Talking (@mutumbakato) ) can add the following lines to your config.toml on the latest version of the CLI to enable the hook locally. If you are interested in contributing a regional provider for a hook which is not msg91 or Africa's Talking please make a comment with the provider name below.

Note that this feature is only available for use with the CLI locally - it will be available on Supabase projects once we merge the frontend

[auth.hook.send_sms]
enabled = true
uri = "http://host.docker.internal:54321/functions/v1/sms_sender"
secret = "env(SEND_SMS_HOOK_SECRET)"

This configuration assumes we're using a Supabase Edge Function which is called sms_sender though in practice you can use any HTTP endpoint of your choosing. With respect to the secret, it should take the form v1,whsec_<standard-base64-string>. You can use a generic base64 encoding tool to help generate the base64 string.

You can view the wip docs and example README for details about HTTP Hooks. You can use the JSON Schema Faker Tool in tandem with the Send SMS JSON Schema provided in order to generate a fake payload to test the function with.

Let us know if there's anything unclear or if there are any further questions or concerns. Thanks!

Details About Contributing

Contributing Format

We may feature some of the functions on our Edge Function Guides - if you wish for your regional sender to be considered, please paste a link to a Github repository containing a README.md, an .env.local file, and an index.ts file containing the function content. We will then check with the appropriate team to see whether it would fit into the guides.

Here's the README outline:

Your-edge-function-name

Example:

Use this Hook with the Send SMS Extension Point to send a message with an AppHash via Twilio Programmable Messaging. The App Hash identifies a mobile application and is embedded it an SMS to allow an Android application to determine that the message was intended for the Application. In turn, this allows for the App to fetch specific information, such as OTP codes, to perform autofill so that the user does not have to exit the application to retrieve information from a message.

Configuration

Example:

Copy the following environment variables from the Twilio Console into your .env.local file:

TWILIO_ACCOUNT_SID=""
TWILIO_AUTH_TOKEN=""
TWILIO_PHONE_NUMBER=""

Testing

Any other points of note?

mutumbakato commented 2 months ago

Hey @J0. I noticed that the HTTP hooks UI has been merged—thank you for your efforts on this! However, I'm encountering an issue: I'm unable to connect the edge function to Authentication as a hook. It seems that the hooks currently only accept database functions. Is there anything specific I need to do to establish this connection to the Edge functions?

Thank you for your assistance.

J0 commented 2 months ago

Hey @mutumbakato,

Apologies on the delayed reply - it's merged but currently behind a feature flag. Should be unflagged once the docs go in

mutumbakato commented 2 months ago

Thanks for the update, I'll be waiting for the actual release.

shaharyarrahmad commented 3 weeks ago

@J0 Any update on this? Can see sms hook in UI, But not firing. Any update would be helpful. Thank you.

J0 commented 3 weeks ago

Hey @shaharyarrahmad,

Yup that is correct - it is behind a feature flag. We're done with the implementation for the most part but need to release the docs and go through the implementation. I know it has taken quite a while but it is coming soon.

Do check back mid Aug - in the meantime feel free to use the locally hosted version or let us know if there's a specific provider you'd like to see so we can look into examples or similar

shaharyarrahmad commented 3 weeks ago

Thank tou @J0 .. looking forward to it.

kangmingtay commented 1 week ago

hi everyone, we've just released the "Send SMS" hook - you can check out the following links:

mutumbakato commented 6 days ago

Hey Kang, thanks a lot for shipping this, it's going to be very helpful. I've been trying it out and I realised that I still can't enable phone auth provider without selecting one of the listed phone providers. It there any other way I can do this?

kangmingtay commented 3 days ago

@mutumbakato thanks for raising this - i've made a fix for it here so it should work properly now (https://github.com/supabase/supabase/pull/28706)