laravel-rust 0.1.0

Laravel for Rust: a full-stack Rust web framework, inspired by PHP Laravel
Documentation
//! Authentication: logging users in and out, and checking what they may do.
//!
//! Most applications let users log in and keep some pages for them alone. This module logs users
//! in with the session, protects routes, resets passwords, verifies email addresses, and checks
//! [policies](crate::auth::policy) before a user acts on a record. The
//! [authentication guide](https://github.com/laravel/rust-framework/blob/0.x/docs/authentication.md)
//! and the [authorization guide](https://github.com/laravel/rust-framework/blob/0.x/docs/authorization.md)
//! walk through each part.
//!
//! Your application tells Laravel how to find its users with a [`UserProvider`], and derives
//! [`Authenticatable`] for its user type. For a [model](crate::model) user, the provider is
//! [`model::Users`](crate::model::Users). Otherwise, implement the trait for a service, such as a
//! `Users` repository. Register the session guard for them in `src/app.rs`:
//!
//! ```no_run
//! # mod app {
//! # use laravel::auth::{Authenticatable, UserProvider};
//! # use laravel::hash::PasswordHash;
//! # #[derive(Clone)] pub struct User;
//! # impl Authenticatable for User {
//! #     type Id = u64;
//! #     fn auth_id(&self) -> u64 { 1 }
//! #     fn auth_password(&self) -> Option<&PasswordHash> { None }
//! #     fn remember_token(&self) -> Option<&str> { None }
//! # }
//! # pub struct Users;
//! # impl UserProvider for Users {
//! #     type User = User;
//! #     async fn find(&self, _: &u64) -> laravel::Result<Option<User>> { Ok(None) }
//! #     async fn find_for_login(&self, _: &str) -> laravel::Result<Option<User>> { Ok(None) }
//! #     async fn update_password(&self, _: &User, _: &PasswordHash) -> laravel::Result<()> { Ok(()) }
//! #     async fn update_remember_token(&self, _: &User, _: &str) -> laravel::Result<()> { Ok(()) }
//! # }
//! # }
//! # use app::*;
//! laravel::Application::configure().with_auth(|auth, _| {
//!     auth.session::<Users>();
//! });
//! ```
//!
//! Mark the handlers of the login page, the password reset page, and the home page of logged-in
//! users with [`#[laravel::auth::page(..)]`](macro@page), so authentication knows where to send
//! users.
//!
//! Then take [`Auth`] as a handler argument to log users in and out, and protect routes with the
//! [`Authenticate`] middleware. [`Passwords`] sends password reset links and resets passwords.
//! [`EmailVerification`] sends email verification links and verifies emails, and
//! [`RequireVerifiedEmail`] keeps users who haven't verified their email out of routes.
//!
//! To authenticate requests by something other than the session, such as an API key, implement
//! [`RequestGuard`] and protect routes with [`Authenticate::via`].

mod passwords;
pub mod social;
mod verification;

pub(crate) use laravel_http::auth::*;
#[doc(hidden)]
pub use laravel_http::auth::{__Page, __PageKind, __VerifiedUser, __authenticated, __private};
#[doc(inline)]
pub use laravel_http::auth::{
    Ability, Access, Auth, AuthConfig, Authenticatable, Authenticate, AuthenticateVia, Authenticated, Authorizable,
    Decision, MustVerifyEmail, PendingAttempt, PendingLogin, RedirectIfAuthenticated, RememberToken, RequestGuard,
    RequireVerifiedEmail, UserProvider, page, policy,
};

pub use self::passwords::{Passwords, ResetPasswordEmail};
pub use self::verification::{EmailVerification, InvalidVerificationLink, VerificationEmail};