Git Product home page Git Product logo

authorizerdev / authorizer Goto Github PK

View Code? Open in Web Editor NEW
1.4K 15.0 143.0 11.32 MB

Your data, your control. Fully open source, authentication and authorization. No lock-ins. Deployment in Railway in 120 seconds || Spin a docker image as a micro-service in your infra. Built in login page and Admin panel out of the box.

Home Page: https://authorizer.dev

License: MIT License

Go 79.02% Dockerfile 0.10% Makefile 0.29% CSS 0.05% TypeScript 20.27% Shell 0.21% JavaScript 0.05%
hacktoberfest authentication auth authorization 2fa golang security user-privileges role-based-access-control typescript

authorizer's Introduction

Logo

Authorizer

Authorizer is an open-source authentication and authorization solution for your applications. Bring your database and have complete control over the user information. You can self-host authorizer instances and connect to any database (Currently supports 11+ databases including Postgres, MySQL, SQLite, SQLServer, YugaByte, MariaDB, PlanetScale, CassandraDB, ScyllaDB, MongoDB, ArangoDB).

For more information check:

Introduction

We offer the following functionality

  • ✅ Sign-in / Sign-up with email ID and password
  • ✅ Secure session management
  • ✅ Email verification
  • ✅ OAuth2 and OpenID compatible APIs
  • ✅ APIs to update profile securely
  • ✅ Forgot password flow using email
  • ✅ Social logins (Google, Github, Facebook, LinkedIn, Apple more coming soon)
  • ✅ Role-based access management
  • ✅ Password-less login with magic link login
  • ✅ Multi factor authentication
  • ✅ Email templating
  • ✅ Webhooks

Roadmap

  • VueJS SDK
  • Svelte SDK
  • Golang SDK
  • React Native SDK
  • Flutter SDK
  • Android Native SDK
  • iOS native SDK
  • Python SDK
  • PHP SDK
  • WordPress plugin
  • Kubernetes Helm Chart
  • Local Stack
  • AMI
  • Digital Ocean Droplet
  • Azure
  • Render
  • Edge Deployment using Fly.io
  • Password-less login with mobile number and OTP SMS

Getting Started

Step 1: Get Authorizer Instance

Deploy Production Ready Instance

Deploy production ready Authorizer instance using one click deployment options available below

Infra provider One-click link Additional information
Railway.app Deploy on Railway docs
Heroku Deploy to Heroku docs
Render Deploy to Render docs
Koyeb Deploy to Koyeb docs
RepoCloud Deploy on RepoCloud docs

Deploy Authorizer Using Source Code

This guide helps you practice using Authorizer to evaluate it before you use it in a production environment. It includes instructions for installing the Authorizer server in local or standalone mode.

Install using source code

Prerequisites

Project Setup

  1. Fork the authorizer repository (Skip this step if you have access to repo)
  2. Clone repo: git clone https://github.com/authorizerdev/authorizer.git or use the forked url from step 1
  3. Change directory to authorizer: cd authorizer
  4. Create Env file cp .env.sample .env. Check all the supported env here
  5. Build Dashboard make build-dashboard
  6. Build App make build-app
  7. Build Server make clean && make

    Note: if you don't have make, you can cd into server dir and build using the go build command. In that case you will have to build dashboard & app manually using npm run build on both dirs.

  8. Run binary ./build/server

Deploy Authorizer using binaries

Deploy / Try Authorizer using binaries. With each Authorizer Release binaries are baked with required deployment files and bundled. You can download a specific version of it for the following operating systems:

  • Mac OSX
  • Linux

Download and unzip bundle

  • Download the Bundle for the specific OS from the release page

Note: For windows, we recommend running using docker image to run authorizer.

  • Unzip using following command

    • Mac / Linux
    tar -zxf AUTHORIZER_VERSION -c authorizer
  • Change directory to authorizer

    cd authorizer

Step 3: Start Authorizer

  • Run following command to start authorizer

    • For Mac / Linux users
    ./build/server

Note: For mac users, you might have to give binary the permission to execute. Here is the command you can use to grant permission xattr -d com.apple.quarantine build/server

Step 2: Setup Instance

  • Open authorizer instance endpoint in browser
  • Sign up as an admin with a secure password
  • Configure environment variables from authorizer dashboard. Check env docs for more information

Note: DATABASE_URL, DATABASE_TYPE and DATABASE_NAME are only configurable via platform envs

Things to consider

  • For social logins, you will need respective social platform key and secret
  • For having verified users, you will need an SMTP server with an email address and password using which system can send emails. The system will send a verification link to an email address. Once an email is verified then, only able to access it.

    Note: One can always disable the email verification to allow open sign up, which is not recommended for production as anyone can use anyone's email address 😅

  • For persisting user sessions, you will need Redis URL (not in case of railway app). If you do not configure a Redis server, sessions will be persisted until the instance is up or not restarted. For better response time on authorization requests/middleware, we recommend deploying Redis on the same infra/network as your authorizer server.

Testing

  • Check the testing instructions here

Integrating into your website

This example demonstrates how you can use @authorizerdev/authorizer-js CDN version and have login ready for your site in few seconds. You can also use the ES module version of @authorizerdev/authorizer-js or framework-specific versions like @authorizerdev/authorizer-react

Copy the following code in html file

Note: Change AUTHORIZER_URL in the below code with your authorizer URL. Also, you can change the logout button component

<script src="https://unpkg.com/@authorizerdev/authorizer-js/lib/authorizer.min.js"></script>

<script type="text/javascript">
	const authorizerRef = new authorizerdev.Authorizer({
		authorizerURL: `YOUR_AUTHORIZER_INSTANCE_URL`,
		redirectURL: window.location.origin,
		clientID: 'YOUR_CLIENT_ID', // obtain your client id from authorizer dashboard
	});

	// use the button selector as per your application
	const logoutBtn = document.getElementById('logout');
	logoutBtn.addEventListener('click', async function () {
		await authorizerRef.logout();
		window.location.href = '/';
	});

	async function onLoad() {
		const res = await authorizerRef.authorize({
			response_type: 'code',
			use_refresh_token: false,
		});
		if (res && res.access_token) {
			// you can use user information here, eg:
			const user = await authorizerRef.getProfile({
				Authorization: `Bearer ${res.access_token}`,
			});
			const userSection = document.getElementById('user');
			const logoutSection = document.getElementById('logout-section');
			logoutSection.classList.toggle('hide');
			userSection.innerHTML = `Welcome, ${user.email}`;
		}
	}
	onLoad();
</script>

Support my work

Buy Me A Coffee

authorizer's People

Contributors

agarwal-nitesh avatar anand-panigrahi avatar anik-ghosh-au7 avatar catusax avatar converter-user-old avatar cosark avatar deep-codes avatar foestauf avatar hiranivipul avatar imchairmanm avatar jerebtw avatar jyash97 avatar lakhansamani avatar leandergangso avatar luclu7 avatar manojown avatar medvedewem avatar minilikmila avatar miqe avatar mussiet avatar olatunji-longe avatar pjort avatar productdevbook avatar samyakbhuta avatar scaletech-milan avatar siimsams avatar szczepad avatar testwill avatar vicg853 avatar vishwasshashidhar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

authorizer's Issues

Signup should not support protected role signup

Version: x.y.z

Describe the bug

Steps To Reproduce

Expected behavior

Screenshots

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Additional context

Implement OIDC protocol on top oauth2 for secure authentication

Feature Description

Currently, we are just authorizing users using oauth2, but open id lets us authenticate users more securely on top of oauth2

Describe the solution you'd like

Check the following video on how it works
youtube.com/watch?v=996OiexHze0

Describe alternatives you've considered

Additional context

Add meta query

Descrption

Add: _meta query that lets the client know the current configuration,

{
   version: `0.1.0.beta`
   isGoogleLoginEnabled: true/false
   isFacebookLoginEnabled: true/false
   isTwitterLoginEnabled: true/false
  isBasicAuthEnabled: true/false
  isEmailVerificationEnabled: true/false
}

Note: this meta-information should also be there with token information as one can configure the frontend UI based on this.

Add support for JS script via env

Feature Description
Allow user to write JS script and manipulate the JWT token contents.
Ref: https://hasura.io/docs/latest/graphql/core/guides/integrations/auth0-jwt.html
This enable users to use platforms like hasura with more security

Describe the solution you'd like

  • Use .env called SCRIPT
  • Expose the Go context and user as param. Expected return is JSON object
  • Use https://github.com/rogchap/v8go to execute JS on start of server

Describe alternatives you've considered

Additional context

Add ability to load env file using cli arg

Description

Currently, env is either loaded from '.env' or using system vars.
It would be good to have -env_file flag where user can specify env file path and variable are loaded from that file

Add query to get new access token

  • If the user has an expired access token and valid refresh token
    • generate a new token and set in response + cookie
  • If the user has a valid access token return the same and set in cookie

fix: verify role in middleware

Version: x.y.z
Latest

Describe the bug
Role for a given JWT token should be verified against the roles of user. This should be done in auth middleware
Here is the util:

func VerifyAuthToken(token string) (map[string]interface{}, error) {

Steps To Reproduce

Expected behavior

Screenshots

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Additional context

Add login wall which can be integrated with JS SDK

  • Create /app route
  • Serve application built using react sdk
  • Set global data with /app route request
  • Global state data should be passed as query string
  • Make sure global state is base64 encoded
  • Make sure state data includes the redirect url
  • Add Allowed origins env
  • Make sure redirect url is available in allowed origins

Create docker image

  • Create Docker file
  • Create image
  • Create Docker compose file to run with postgres

Add ability to update role of a user

Feature Description
Create a mutation for admins only, so that they can update roles of a user

Describe the solution you'd like

Describe alternatives you've considered

Additional context

Add support for following envs

Envs to be supported

  • PORT
  • DATABASE_URL
  • CALLBACK_URL
  • ADMIN_SECRET
  • PASSWORD_ENCRYPTION_KEY
  • FACEBOOK_ID
  • FACEBOOK_SECRET
  • GITHUB_ID
  • GITHUB_SECRET
  • GOOGLE_ID
  • GOOGLE_SECRET
  • TWITTER_ID
  • TWITTER_SECRET
  • EMAIL_SERVER=smtp://username:[email protected]:587
  • EMAIL_FROM=NextAuth [email protected]
  • DATABASE_URL=sqlite://localhost/:memory:?synchronize=true

Update the email template sent to user

Feature Description

Make a generic email for verification mails that are sent to users during

  1. signup mutation
  2. updateProfile mutation if email is change

Describe the solution you'd like

Describe alternatives you've considered

Additional context

Allow login and token verification with multiple roles

Version: x.y.z

Describe the bug

Steps To Reproduce

Expected behavior

Screenshots

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Additional context

Refactor social login to use common util to save data

Version: x.y.z

Describe the bug

Steps To Reproduce

Expected behavior

Screenshots

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Additional context

Add ability to invite users

Feature Description

Super admins should be able to invite users

Describe the solution you'd like

Describe alternatives you've considered

Additional context

Add support for multiple sessions

Feature Description

Currently only one active session of user is valid.
Ideally we would like to allow user to have multiple sessions and keep track of that in db

Describe the solution you'd like

Describe alternatives you've considered

Additional context

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.