cas.unilim.fr
Client for the Central Authentication Service of Unilim, the University of Limoges.
It talks to the LemonLDAP::NG portal at cas.unilim.fr and handles login,
2FA, session persistence, service tickets and OAuth2.
Usage
First login, with 2FA
use CAS;
let mut auth = CASinitialize.await?;
if !auth.solved
let cas = auth.finish.await?;
import { CAS } from "@unilim/cas";
const auth = await CAS.initialize(username, password);
if (!auth.solved) {
if (auth.isTotpAvailable) {
await auth.solveWithTotp(code);
}
else if (auth.isEmailAvailable) {
await auth.sendEmailCode();
await auth.solveWithEmailCode(code);
}
}
const cas = await auth.finish();
finish() registers our "browser" on the portal.
Restoring a session, bypassing 2FA
To be able to do this you should've stored the following values.
cas.connection(llngconnectionpersistence cookie)cas.key(TOTP secret linked to that cookie)
let cas = CASrestore.await?;
const cas = await CAS.restore(
username,
password,
connection, // = cas.connection
key // = cas.key
);
A raw lemonldap session cookie can also be wrapped with
CAS::temporary(cookie). Such a session cannot be restored.
Forge service tickets
The returned URL is the login route of the service with a ticket=ST-...
query parameter. Requesting it logs you into the service.
use Services;
let url = cas
.service
.await?;
import { Services } from "@unilim/cas";
const url = await cas.service(
Services.CommunityIut
);
Authorize OAuth2
use OAuth2;
let client = new;
let callback = cas
.authorize
.await?;
let tokens = cas
.tokenize
.await?;
let user = cas.userinfo.await?;
import { OAuth2 } from "@unilim/cas";
const client = new OAuth2(
clientId,
callbackUrl,
scopes,
);
const callback = await cas.authorize(
client, false, "state",
);
const tokens = await cas.tokenize(
callback, client, false,
);
const user = await cas.userinfo(tokens);
License
GPL-3.0-or-later, see LICENSE.md. Not affiliated with the University of Limoges.