Agama Lab tool helps developers to make a flow for Jans Agama.
Table of Content
Agama-Lab Online Tool
Make a Project
Make a Flow File
Make a Simple Basic Auth Flow
Download Basic Flow
Make a template file
Make a gama file / Release Project
Deploy a gama file on Jans
Testing using Jans Tent
Login with GitHub
button. Click on it and give access to agama-lab. In the next step, it will ask you to enter the repository path. Right now, Agama Lab always users your personal repository. You just need to enter your repository name. For Example: if your repository URL is https://github.com/temp-user/agama-projects
then just enter the repository name agama-projects
.
Your repository must have at least one Git Commit to proceed. Just making a fresh new repo with README.md will be good.
Navigate to the Project Tree File view to make Agama Flows and .gama
files.
Code
folder and select New Flow file Enter Details in Form
Final look at the flow diagram:
Save it and you can click on the Code
button to see the actual flow
It will look like this:
Flow co.basic
Basepath ""
authService = Call io.jans.as.server.service.AuthenticationService#class
cdiUtil = Call io.jans.service.cdi.util.CdiUtil#bean authService
authResult = {}
Repeat 3 times max
creds = RRF "login.ftlh" authResult
authResult.success = Call cdiUtil authenticate creds.username creds.password
authResult.uid = creds.username
When authResult.success is true
Finish authResult.uid
Finish false
login.ftlh
template file. Let’s create it.
web
folder and select the new free maker templateSelect Template and add details. It is up to you to make a beautiful design using UI-Editor.
Edit HTML to add existing code. You can make your own.
<!doctype html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> Jans Agama Basic Auth flow </title> </head> <body> <h2>Welcome</h2> <hr /> [#if !(success!true)] <p class="fs-6 text-danger mb-3">${msgs["login.errorMessage"]}</p> [/#if] <hr /> <form method="post" enctype="application/x-www-form-urlencoded"> <div> Username: <input type="text" class="form-control" name="username" id="username" value="${uid!}" required> </div> <div> Password: <input type="password" class="form-control" id="password" name="password"> </div> <div> <input type="submit" class="btn btn-success px-4" value="Login"> </div> </form> </body> <style> input { border: 1px solid #000000; } </style> </html>
Once you save the file. It will add [#ftl output_format="HTML"]
which is needed because we are using [#if...
instead of <#if...
.
Notice If you want to add code like
<input type="submit" class="btn btn-success px-4" value="${msgs["login.login"]}">
then it will not work instead of add<input type="submit" class="btn btn-success px-4" value="${msgs['login.login']}"/>
.You need to use a single quote inside a double quote.
Release Project
# cd /opt/jans/jans-cli
# python3 jans_cli_tui.py
Enable Agama Configuration, In TUI, navigate to AuthServer > Properties > agamaConfiguration > Enabled [*] > Save
Enable Agama Script, In TUI, navigate to Scripts > Search 'agama' > Select script Enabled [*] > Save
Move your .gama
file to your Jans server
Navigate to Auth Server > Agama > Upload Project
Select a file and upload
You should see now uploaded project in the list
Check your Jans logs for Any Errors
config.py
as per your need.ACR_VALUES = "agama"
ADDITIONAL_PARAMS = {
'agama_flow': 'co.basic'
}
Successfully login