PaadamപാഠംGuides

Your brand

Sign-in from your website

Students signed in to your own website come in with one tap, with no second password.

If students already sign in to your own website, they can open Paadam from there without signing in again. Your website signs a short-lived token with a secret only it and Paadam know, and sends the student to Paadam with it.

Turn it on

In Settings → Developers → Sign-in from your website, choose Turn it on. Copy the signing secret into your website's server settings (never into a page). Choose whether Paadam should make an account for a student it doesn't know yet, and, if you like, where people go after signing out.

When a signed-in student clicks "My classes" on your website, your server makes a token (a JWT signed with HS256) and sends them to:

https://<your address>/sso/jwt?token=<the token>&next=/learn

The token carries:

ClaimWhat it is
email or phoneHow Paadam finds the student (one is needed)
nameTheir name
iat, expWhen it was made and when it stops working (at most five minutes apart)
jtiA one-time id: the same token is refused a second time
roleOptional, for a new account: learner (the default) or parent

Node.js

import { createHmac, randomUUID } from "node:crypto";

const b64 = (o) => Buffer.from(JSON.stringify(o)).toString("base64url");
const now = Math.floor(Date.now() / 1000);
const body = b64({ alg: "HS256", typ: "JWT" }) + "." +
  b64({ email: student.email, name: student.name, iat: now, exp: now + 120, jti: randomUUID() });
const token = body + "." + createHmac("sha256", process.env.PAADAM_SSO_SECRET).update(body).digest("base64url");
res.redirect("https://learn.yourschool.in/sso/jwt?token=" + token + "&next=/learn");

PHP

$b64 = fn($s) => rtrim(strtr(base64_encode($s), '+/', '-_'), '=');
$now = time();
$body = $b64(json_encode(['alg' => 'HS256', 'typ' => 'JWT'])) . '.' . $b64(json_encode([
  'email' => $student['email'], 'name' => $student['name'],
  'iat' => $now, 'exp' => $now + 120, 'jti' => bin2hex(random_bytes(16)),
]));
$token = $body . '.' . $b64(hash_hmac('sha256', $body, getenv('PAADAM_SSO_SECRET'), true));
header('Location: https://learn.yourschool.in/sso/jwt?token=' . $token . '&next=/learn');

Rules

  • Only learners and parents can come in this way. Owners, admins and tutors always sign in on Paadam itself.
  • A token older than five minutes, used twice, or signed with another secret is refused, and the sign-in page says why.
  • Paadam asks "Continue as <name>?" once before signing the student in, so a link someone else made can't sign them in to another person's account.
  • Make a new secret any time; the old one stops working at once.