Building a project for your department and worried about authentication? Making sure only real students can log in can be tough. But with ‘Sign in with CSE JnU’, you don’t have to worry anymore!
This feature allows students to log in using their CSE JnU accounts. It’s simple, automatic, and updates their data whenever they update their profile on the main site. The best part? No need to write extra code to check if they’re valid students. Just follow these two easy steps:
Step 1: Redirect Users to the Auth Server
When a user wants to sign in, send them to the Auth server. Include a callback URL, so the Auth server knows where to send them back after login. For example:
http://auth.itrrc.com/?callback=https://yoursite.com/success.html
If the user enters the correct username and password, they’ll be redirected back to your site with a token attached to the URL, like this:
https://yoursite.com/success.html?token=ey....xyz
Step 2: Verify the Token on Your Backend
After the user lands back on your site, grab the token from the URL. Now, verify the token by sending it to the Auth server:
http://auth.itrrc.com/verify?token=ey....xyz
If the token is valid, you’ll get a response like this:
{
"valid": true,
"payload": {
"name": "MT ASFI",
"email": "asfi@gmail.com",
"meta": {
"role": "student",
"student_id": "B2003051234",
"batch": "1",
"cr": false,
"graduated": false,
"job_description": "Software Engineer",
"blood_type": "A+",
"birthday": "1/12",
"gender": "Male",
"linkedin": "https://linkedin.com/",
"photo": "https://blog.com/profile_photo.jpg"
},
"iat": 1737215096,
"exp": 1737218696
}
}
If the token is invalid, you’ll get a response like this:
{
"valid": false,
"message": "Invalid signature"
}
Why Use ‘Sign in with CSE JnU’?
- No Extra Work: You don’t need to write code to verify if users are real students.
- Always Up-to-Date: If a student updates their main profile, the changes sync automatically.
- Super Simple: Just two easy steps and you’re done!
If you’re wondering how to get started, I’ve got you covered! I’ve created a demo project on GitHub using Express.js to show exactly how to integrate ‘Sign in with CSE JnU’. You can check it out, explore the code, and see how simple it is to implement. 🚀
Open the demo project on GitHub
Now you can make your project secure without breaking a sweat. Add ‘Sign in with CSE JnU’ and focus on building something amazing! 🚀
Great work! I will definitely use this in my upcoming project. Need more cool features like this.