Worker Auth Providers

worker-auth-providers is an open-source providers to make authentication easy with workers. Very lightweight script which doesn't need a lot of dependencies. Plug it with any framework or template of workers.
Alternatives To Worker Auth Providers
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Awesome Go108,423
a day ago35April 19, 2021171mitGo
A curated list of awesome Go frameworks, libraries and software
Hackathon Starter34,33924 days ago7December 09, 202011mitJavaScript
A boilerplate for Node.js web applications
Passport21,79781,2724,3892 days ago32May 20, 2022375mitJavaScript
Simple, unobtrusive authentication for Node.js.
Next Auth18,7502122619 hours ago650July 25, 2023304iscTypeScript
Authentication for the Web.
Casbin15,65163819 days ago240July 28, 202326apache-2.0Go
An authorization library that supports access control models like ACL, RBAC, ABAC in Golang: https://discord.gg/S5UjpzGZjN
Cas10,3246291a day ago192July 21, 20238apache-2.0Java
Apereo CAS - Identity & Single Sign On for all earthlings and beyond.
Supertokens Core10,055
19 hours ago101otherJava
Open source alternative to Auth0 / Firebase Auth / AWS Cognito
Springcloud8,298
14 days ago56apache-2.0Java
基于SpringCloud2.1的微服务开发脚手架,整合了spring-security-oauth2、nacos、feign、sentinel、springcloud-gateway等。服务治理方面引入elasticsearch、skywalking、springboot-admin、zipkin等,让项目开发快速进入业务开发,而不需过多时间花费在架构搭建上。持续更新中
Django Allauth8,2935,1601262 days ago70March 31, 2023102mitPython
Integrated set of Django applications addressing authentication, registration, account management as well as 3rd party (social) account authentication.
Satellizer8,01728474 years ago56August 30, 2016287mitTypeScript
Token-based AngularJS Authentication
Alternatives To Worker Auth Providers
Select To Compare


Alternative Project Comparisons
Readme

worker-auth-providers

worker-auth-providers

An open-source auth providers for Cloudflare workers

Repo Size Issues Pull Requests Last Commit

worker-auth-providers is an open-source providers to make authentication easy with workers. Very lightweight script which doesn't need a lot of dependencies. Plug it with any framework or template of workers.

Demo

Try now

Features

  • Open Source
  • Fast & Lightweight
  • Easy

Installation

Step 1: Install the dependencies

npm install worker-auth-providers

Step 2: Import the dependencies

import {
  github, google,
  twilio, facebook, discord,
  spotify
} from "worker-auth-providers";

Step 3: Redirect users

const githubLoginUrl = await github.redirect({
    options: {
        clientId,
    },
});
return {
    status: 302,
    headers: {
        location: githubLoginUrl,
    },
};

// or send otp

const res = await awsSNS.send({
  options: {
    phone,
    region: 'ap-south-1',
    kvProvider: WORKER_AUTH_PROVIDERS_STORE,
  },
})

Step 4: Get user

const { user: providerUser, tokens } = await github.users({
    options: { clientSecret, clientId },
    request,
});
console.log("[providerUser]", providerUser);

// or verify otp
const res = await awsSNS.verify({
  options: {
    phone,
    otp,
    kvProvider: WORKER_AUTH_PROVIDERS_STORE,
    secret: 'eyJhbGciOiJIUzI1NiJ9.ew0KICAic3ViIjogIjE2Mjc4MTE1MDEiLA0KICAibmFtZSI6ICJoYWFsLmluIiwNCiAgImlhdCI6ICIwMTA4MjAyMCINCn0.aNr18szvBz3Db3HAsJ-2KHYbnnHwHfK65CiZ_AWwpc0',
  },
})

Documentation

Coming soon

Tech

Contributing

Contributions are always welcome! See contributing.md for ways to get started. Please adhere to this project's code of conduct.

Roadmap

  • [ ] Docs.
  • [x] Apple.
  • [ ] Azure (Microsoft)
  • [x] Google.
  • [x] Github
  • [x] OTP Twilio
  • [x] Mailgun Email
  • [x] Sendgrid Email
  • [x] Facebook
  • [x] Discord
  • [ ] Instagram
  • [ ] Amazon
  • [ ] Twitter
  • [x] Spotify
  • [ ] Auth0

##FAQs

How to persist login?

Use cookie. Setting a cookie to indicate that theyre authorized for future requests

const cookieKey = "worker-auth-providers"
const persistAuth = async exchange => {
    const date = new Date()  date.setDate(date.getDate() + 1)
    const headers = { 
      Location: "/",
      "Set-cookie": `${cookieKey}=${id}; Secure; HttpOnly; SameSite=Lax; Expires=${date.toUTCString()}`,
    }
    return { headers, status: 302 }
}

How to logout?

Easy, delete the cookie

export const logout = event => {
  const cookieHeader = event.request.headers.get('Cookie')
  if (cookieHeader && cookieHeader.includes(cookieKey)) {
    return {
      headers: {
        'Set-cookie': `${cookieKey}=""; HttpOnly; Secure; SameSite=Lax;`,
      },
    }
  }
  return {}
}

Feedback

If you have any feedback, please reach out to me at [email protected]

Authors

License

MIT

Popular Authentication Projects
Popular Oauth Projects
Popular Security Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Typescript
Authentication
Oauth
Spotify
Cloudflare
Facebook Login
Google Login