























Authorizer is an open-source authentication and authorization solution that comes with easy to integrate frontend SDKs while also allowing you to bring your own database. You can think of it as a self-hosted alternative to Auth0.
Authorizer provides an onboarding experience that takes just 3 minutes so that you can spend all your valuable time staying focused on your product and not losing sleep worrying about security, authentication and authorization.
At Railway, we provide a free one-click deploy for Authorizer that is maintained by Lakhan Samani (the creator of Authorizer) himself. We also automatically provision the required PostgreSQL and Redis databases for you!

Once you set up your Authorizer instance using this guide, you get the following features straight out of the box:
To deploy Authorizer on Railway, you can simply click this button and follow the guide below. You can also visit Github to view the source code.
After you click the button, you will see the following screen:

To deploy your Authorizer instance, Railway needs to create a repo in your GitHub account which it will deploy for you. So if you haven’t already, give Railway access to your GitHub on this page.
By default, the repository created for you will be titled authorizer-railway but feel free to choose a different name. Just make sure another repository with that name doesn’t already exist.
DATABASE_URL will be automatically configured for you by Railway when we provision the required PostgreSQL database for you.REDIS_URL will also automatically configured for you by Railway when we provision the required Redis database for you.ADMIN_SECRET and the JWT_SECRET.💬 Psst, we have a secret generator that you can use. Just hit CMD+K (or CTRL+K) and search for secret.
Once you’ve filled in all the required environment variables, just hit the deploy button on the page and you’ll be taken to your brand new project and your Authorizer instance will be deployed in a few minutes!
Optionally, if you’re using a React frontend, carry on reading for a guide on integrating Authorizer in your React application.
If you use NPM:
npm i --save @authorizerdev/authorizer-react
Or, if you use yarn, you can run:
yarn add @authorizerdev/authorizer-react
Make sure you replace the text RAILWAY_ENDPOINT with the actual endpoint that Railway gives you once your application is deployed.
import {
AuthorizerProvider,
} from "@authorizerdev/authorizer-react";
const App = () => {
return (
<AuthorizerProvider
config={{
authorizerURL: RAILWAY_ENDPOINT,
redirectURL: window.location.origin,
}}
>
<LoginSignup />
<Profile />
</AuthorizerProvider>
);
};
Authorizer provides a core component that can be used for your login, sign up, and forgot password flows with support for social logins.
import { Authorizer } from "@authorizerdev/authorizer-react";
const LoginPage = () => {
return (
<>
<h1>Login / Signup</h1>
<Authorizer
onLogin={(loginResponse) => {}}
onMagicLinkLogin={(magicLinkResponse) => {}}
onSignup={(signupResponse) => {}}
onForgotPassword={(forgotPasswordResponse = {})}
/>
</>
);
};
The Authorizer hook gives you access to the global state stored inside the Authorizer context with additional methods to update the state.
const Profile = () => {
const { user } = useAuthorizer();
if (user) {
return <div>{user.email}</div>;
}
return null;
};
And with that, you should have all the information you need to deploy your own Authorizer instance on Railway. You should be able to create new projects and add the Authorizer widget to your websites.
If you have any suggestions for more open-source self-hosted solutions you'd like to see guides for, let us know on Discord. Or even better, submit a pull request to our starters repository on Github!
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。