Expand description
authentication client for the central authentication service of unilim, the university of limoges.
talks to the lemonldap::ng portal at cas.unilim.fr and covers the whole
session lifecycle:
CAS::initializesubmits credentials and returns aPendingAuthholding the 2fa challenge.PendingAuthsolves the challenge with an email code or a totp code, thenPendingAuth::finishestablishes the session.CAS::restorebrings back a persisted session without solving 2fa again.CAS::servicereturns a ticket url for one of the supportedServices.CAS::authorize,CAS::tokenizeandCAS::userinfohandle the oauth2 flow of the portal.
§quick start
use unilim_cas::CAS;
// on first login, solve the 2fa challenge manually.
let mut auth = CAS::initialize("username", "password").await?;
if !auth.solved {
if auth.is_totp_available {
auth.solve_with_totp("123456").await?;
}
else if auth.is_email_available {
auth.send_email_code().await?;
auth.solve_with_email_code("123456").await?;
}
}
let cas = auth.finish().await?;
// store `cas.connection` and `cas.key` somewhere safe, then restore
// later without any 2fa prompt.
let cas = CAS::restore("username", "password", &cas.connection, &cas.key).await?;§session model
an established CAS session is made of three strings:
CAS::cookie, thelemonldapsession cookie sent on every request.CAS::connection, thellngconnectionpersistence cookie obtained by registering the browser.CAS::key, the totp secret answering the browser check duringCAS::restore.
the session cookie expires quickly, so store the other two for the long term.
§features
client, the default, provides the native client documented here. http goes through rikka, so it also runs onwasm32.wasmonly provides theunilim_cas::wasmmodule, extern declarations of the@unilim/casjs classes for packages receiving the session from javascript. pulls no client code and only compiles onwasm32.
Structs§
- CAS
- an established cas session.
- OAuth2
- oauth2 client configuration.
- Pending
Auth - in-progress authentication awaiting a 2fa challenge.
- Tokens
- oauth2 tokens returned by
/oauth2/token. - User
- user information returned by
/oauth2/userinfo.
Enums§
Constants§
- COOKIE
- name of the session cookie.
- HOST
- base url of the cas portal.
- PERSIST_
COOKIE - name of the persistence cookie enabling
CAS::restore.
Type Aliases§
- Result
- alias of
std::result::ResultwithErroras the error type.