The `better-auth-cas` package, currently at version `0.1.8`, is an early-stage plugin designed to integrate Central Authentication Service (CAS) functionality into the `better-auth` authentication framework. It provides standard CAS sign-in and callback endpoints, handles CAS ticket validation via `serviceValidate`, and includes robust profile mapping capabilities to translate CAS user attributes into `better-auth` user and session data. A key feature is the optional `onProfileResolved` hook, enabling custom persistence logic. It emphasizes solutions for common CAS integration challenges, such as managing CAS's separate SSO session cookies to prevent "auto-login" after a local logout and addressing `service` URL allowlist mismatches in CAS deployments. While in a pre-1.0 state, implying potential API changes, its initial release (v0.1.0 on 2026-03-19) indicates active development and a focused approach to providing a ready-to-use CAS solution for `better-auth` applications, shipping with TypeScript types for better developer experience.
npm install better-auth-casVerified import paths — ran on the pinned version, not inferred.
Initializes `better-auth` with the standard CAS plugin, demonstrating how to configure the CAS base URL, callback path, and provider ID. It also highlights optional configuration for `redirectUri` and `profileMapping` using environment variables.
Implement a global logout route that first clears the local Better Auth session and then redirects the user to the CAS `/logout` endpoint with a `service` parameter pointing back to your application's public URL. Refer to the 'Recommended global logout' section in the README.
Explicitly set the `redirectUri` option in `createStandardCasPlugin` to your application's exact, absolute callback URL. This ensures the `service` parameter in the CAS login request matches the allowlisted value.
Monitor the project's changelog and release notes closely when updating to new versions. Thoroughly test your integration after any update to ensure continued functionality.
Ensure the `redirectUri` option in `createStandardCasPlugin` is set to the exact, absolute URL of your CAS callback endpoint (e.g., `http://localhost:3000/api/auth/cas/callback`) and that this URL is allowlisted on your CAS server.
Implement a comprehensive logout strategy that clears both the local `better-auth` session and redirects the user to the CAS server's logout endpoint. Refer to the 'Recommended global logout' example in the README.