This guide will show you how to implement the user authentication in a Go application. For this tutorial, we will use the Go demo from GitHub and show you step by step how to run it.
This tutorial assumes you have:
- Basic knowledge of HTML/CSS
- Latest Go version installed on your system
Get your credentials and whitelist your application domain as explained in this section. This is a mandatory step to successfully implement and run the demo.
You can clone the Auth Page demo repository on your system using below commands:
git clone firstname.lastname@example.org:LoginRadius/login-page-demos.git
git clone https://github.com/LoginRadius/login-page-demos.git
Now move to the directory Go demo by running the following command using the terminal
This is the file structure you will get in the GoLang demo, let's see what each file does
config folder - Contains the public and secret environment files.
pkg folder - Contains all code for routes and APIs
ui folder - Contains all the HTML, CSS and JS file to create UI for the test application
go.mod - contains all the go lang dependencies
main.go - Contains all the code to run a server and render the html files.
. +-- config | --- public.env | --- secret.env +-- pkg +-- ui | +-- assets | | +-- css | | +-- img | | +-- js | | --- index.html | | --- profile.html | | --- resetpassword.html --- go.mod --- main.go
- Set your LoginRadius credentials on the client and server-side in the following files
- Server side:
- Server side:
APIKEY=<LoginRadius API key> APISECRET=<LoginRadius API secret>
- Client side:
commonOptions.apiKey = "<LoginRadius API key>"; commonOptions.appName = "<LoginRadius App Name>";
- Running application
Run the below commands in the terminal from the root folder of the application, Once all the dependencies have been installed run the application
go run main.go
Then visit http://localhost:3000 from your local browser and you will see the application running. Once you click on login button it will redirect you to auth page.
- Login with Auth Page (IDX)
- Registration with Auth Page (IDX)
- Email Verification
- Forgot Password
- Reset Password