Skip to content
Back to skills

Auth And Authorization

ASecurity

Implements authentication, login flows, session/request guards, policies, and permission checks in Laravel for Rust. Use when working on login, registration, logout, protected routes, policies, email verification, password resets, or social login.

  • 8 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 2, 2026
developmentrustgo

Security analysis

A100/100

Scanned December 2, 2026

npx -y skills add danielhe4rt/overthinking-canvas-rs --skill auth-and-authorization --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Auth And Authorization?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Auth And Authorization
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/danielhe4rt-auth-and-authorization/badge)](https://www.skillsdirectory.com/skills/danielhe4rt-auth-and-authorization)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: auth-and-authorization
description: Implements authentication, login flows, session/request guards, policies, and permission checks in Laravel for Rust. Use when working on login, registration, logout, protected routes, policies, email verification, password resets, or social login.
---

# Authentication & Authorization

Consult the installed framework docs (locate via `.agents/skills/writing-laravel-rust-apps/scripts/docs-path.sh`) for complete details: `authentication.md`, `authorization.md`, `passwords.md`, `verification.md`, and `social-login.md`.

## Authentication

- Your user model derives `Authenticatable` (wired to the session guard in `src/app.rs` via `auth.session::<model::Users<User>>()`).
- Neither `PasswordHash` nor `RememberToken` implements `Serialize`, so always annotate both with `#[serde(skip)]` on `User`—this prevents secrets from leaking into Inertia props or JSON responses.
- Mark core auth page handlers with `#[laravel::auth::page(...)]` (e.g., `#[laravel::auth::page(login)]`) only for the pages your app uses so guest redirects, password resets, and email verification links resolve to the right routes.
- Extract the signed-in user in handlers with `Authenticated(user): Authenticated<User>` (or `Option<Authenticated<User>>` / `Auth<User>` when guests are allowed). Protect route groups with auth middleware—don't hand-roll session checks inside handlers.
- Register one session guard for one `User` type. Represent roles (like admin) on `User` and check them in policies rather than adding extra guards.
- Apply rate limiting to login, password reset, and verification endpoints.

## Authorization & Policies

- Authentication is not authorization, and validation is not authorization—always check permissions explicitly on protected actions. Prefer `404` over `403` when cross-tenant isolation should not reveal whether a record exists.
- Define policies by applying `#[policy]` to an `impl PostPolicy` block on a unit struct, kept right beside the model in `src/models/post.rs` (ordered top-down as model, then policy, then factory, and re-exported from `src/models/mod.rs`).
- Every function inside a `#[policy]` block is treated as an ability—put private helper functions in a separate `impl PostPolicy` block without `#[policy]`.
- Return `bool` for standard checks or `Access` (`Access::allow()` / `Access::deny("...")`) when you need a custom denial message.
- Check abilities with `user.authorize(PostPolicy::update, &post).await?` (passing the policy method directly so names and types are verified at compile time), or authorize directly on a `#[laravel::input]` struct via `ValidatesRequest::authorize`.

```rust
// src/models/post.rs (alongside Post and PostFactory)
use laravel::auth::policy;

use crate::models::{Post, User};

pub struct PostPolicy;

#[policy]
impl PostPolicy {
    pub fn update(user: &User, post: &Post) -> bool {
        user.id == post.user_id
    }

    pub fn delete(user: &User, post: &Post) -> bool {
        user.id == post.user_id
    }
}
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.