Custom Single Sign-On (SSO)
Learn how to implement a custom Single Sign-On (SSO) in your application.
SSO is a user authentication process that allows a user to access multiple applications with one set of login credentials.
Build-in SSO
VitNode has a build-in providers like Google or Facebook. Go to Guide for SSO to enable and configure SSO in your application.
Custom SSO
As an example, we will implement a custom SSO for Google.
Provide URL
First, you need to provide an URL for the SSO to redirect client to Google login page.
VitNode provides redirect_uri
and client_id
for you to use.
Handle Callback
After the user login with Google, Google will redirect the user back to your application with a code
. You need to handle this code
to get the access_token
.
Get User Info
After you get the access_token
, you need to get the user info from Google. Create registerCallback()
function to get the user info.
Use SSO
Now, you can use the SSO in your application. Go to AdminCP => Settings => Authorization => Login Methods
to enable your SSO.
Callback URL
The callback URL will be https://yourdomain.com/login/sso/{your_sso_code} /callback
. For example, https://yourdomain.com/login/sso/google/callback
.