Giter VIP home page Giter VIP logo

podcast-auth's Introduction

Podcast Authentication Backend

License


This TypeScript-based backend system provides a secure and efficient way to authenticate podcasters through email verification. It uses Cloudflare Workers for API routing, Cloudflare D1 SQL database for data storage, and Mailjet for email notifications.

Features

  • Generate Verification Code: Generate a code to check a podcast RSS feed ownership and send it by mail (email address provided in the itunes:email tag). Ownership is linked to any user ID, originally built to be tied to a user's EVM address.

  • Verify Podcasters: Allow podcasters to verify their identity by submitting the verification code received via email. The system checks the code's validity and expiration.

Usage example

  1. Generate a verification code:
curl --request POST \
  --url 'https://podcast-auth.[subdomain].workers.dev/generate-code' \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --data rss_feed=https://www.vocast.fr/desondes/rss/main \
  --data admin_address=0x64E8f7C2B4fd33f5E8470F3C6Df04974F90fc2cA
  1. Verify the ownership, with the code received by mail:
curl --request POST \
  --url 'https://podcast-auth.[subdomain].workers.dev/validate-code' \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --data rss_feed=https://www.vocast.fr/desondes/rss/main \
  --data admin_address=0x64E8f7C2B4fd33f5E8470F3C6Df04974F90fc2cA \
  --data code=222311
  1. Get all validated feeds for a user (from the EVM address account):
curl --request GET \
  --url 'https://podcast-auth.[subdomain].workers.dev/0x64E8f7C2B4fd33f5E8470F3C6Df04974F90fc2cA/validated-feeds'

Development

Prerequisites

Before you begin, ensure you have met the following requirements:

  • Node.js installed
  • Cloudflare account
  • A Mailjet API key

Setup

Installation

To install the project, follow these steps:

git clone https://github.com/antho31/podcast-auth.git
cd podcast-auth
npm install

Mailjet configuration

Create a .dev.vars file and provide the following environment variables:

Variable Name Description Required
MJ_APIKEY_PUBLIC Public API key for Mailjet Yes
MJ_APIKEY_PRIVATE Private API key for Mailjet Yes
MJ_SENDER_MAIL Sender's email address for Mailjet Yes

See .dev.example.vars for an example.

Cloudflare configuration

  1. Use wrangler to log in:
npx wrangler login
  1. Create a D1 database:
npx wrangler d1 create PodcastAuth

Note the created database database_id.

  1. Update database_id in the wrangler.toml configuration file.

  2. Add the required SQL table:

npm run int-db
  1. Add secrets in production:
npx wrangler secret put MJ_APIKEY_PRIVATE
npx wrangler secret put MJ_APIKEY_PUBLIC
npx wrangler secret put MJ_SENDER_MAIL

Start the dev server

npm run dev-api

Access the API at http://localhost:8787

Deployment

To deploy the project to Cloudflare Workers:

npm run deploy-api

Note the published API endpoint.

License

This project is licensed under the MIT License. See the LICENSE file for details.

podcast-auth's People

Contributors

antho31 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.