Expand description
Social login for Renox apps: “Continue with Google” and “Continue with
GitHub” on the login and register pages, linked to the app’s users.
use renox::prelude::*;
use renox_oauth::OAuth;
App::new()
.module(Auth::new().account()) // the account page lists linked logins
.module(OAuth::new().google().github()) // GOOGLE_CLIENT_ID, GITHUB_CLIENT_ID, … in .envFor company sign-in, Microsoft (one tenant), Google::hosted_domain and
OAuth::allow_domains accept only the organisation’s own accounts.
The authorization code flow with PKCE (S256) and a single-use state
bound to the session. A provider account logs in the user it is linked
to; at a first login, it is linked to the account with the same
verified address, or makes a new account (without a password) when
registration is open. Users link and unlink providers from their account
page. The guide is docs/oauth.md in the Renox repository.
Re-exports§
pub use events::AccountLinked;pub use events::AccountUnlinked;pub use events::LoggedInWith;pub use events::OAuthRefused;pub use github::GitHub;pub use google::Google;pub use microsoft::Microsoft;pub use provider::BoxFuture;pub use provider::Credentials;pub use provider::Profile;pub use provider::Provider;pub use provider::Refused;pub use provider::Token;pub use provider::TokenRequest;pub use provider::exchange_code;
Modules§
- events
- What the module announces. Listen with
App::listen; when the app has theAuditmodule, each one is recorded inaudit_logs. - github
- Sign in with GitHub: the
read:user user:emailscopes, the profile from/userand the verified primary address from/user/emails. - Sign in with Google (OpenID Connect): the
openid email profilescopes, the profile from Google’s userinfo endpoint.Google::hosted_domainlimits sign-in to one Google Workspace domain. - microsoft
- Sign in with a Microsoft work or school account (Microsoft Entra ID,
OpenID Connect against
login.microsoftonline.com/{tenant}/v2.0): theopenid email profilescopes, the profile from the ID token. Personal Microsoft accounts are never accepted. - provider
- What a provider is: where users approve, how a code becomes a token, and
how the token becomes a
Profile. Google and GitHub come with the crate; another provider is one small impl ofProvider:
Structs§
- OAuth
- The social login module: add it next to
Auth(with.account()for the page where users link and unlink providers). - OAuth
Account - A provider account (a Google or GitHub account) linked to a user: they log in with it. One per provider and user, and a provider account links to one user only. Deleted with its user.