Skip to main content

Crate unilim_cas

Crate unilim_cas 

Source
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:

§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, the lemonldap session cookie sent on every request.
  • CAS::connection, the llngconnection persistence cookie obtained by registering the browser.
  • CAS::key, the totp secret answering the browser check during CAS::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 on wasm32.
  • wasm only provides the unilim_cas::wasm module, extern declarations of the @unilim/cas js classes for packages receiving the session from javascript. pulls no client code and only compiles on wasm32.

Structs§

CAS
an established cas session.
OAuth2
oauth2 client configuration.
PendingAuth
in-progress authentication awaiting a 2fa challenge.
Tokens
oauth2 tokens returned by /oauth2/token.
User
user information returned by /oauth2/userinfo.

Enums§

Error
errors returned by the client.
Services
a cas-fronted service reachable through sso.

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::Result with Error as the error type.