Skip to content
Back to skills

Auth And Authorization

ASecurity

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

  • 3 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 3, 2026
developmentgo

Security analysis

A100/100

Scanned December 3, 2026

npx -y skills add airshell/laravel-php-to-rust-go --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/airshell-auth-and-authorization-laravel-php-to-rust-go/badge)](https://www.skillsdirectory.com/skills/airshell-auth-and-authorization-laravel-php-to-rust-go)

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 Go. 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-go-apps/scripts/docs-path.sh`) for complete details: `authentication.md`, `authorization.md`, `passwords.md`, `verification.md`, and `social-login.md`.

## Authentication

- Your user model in `models/user.go` provides `ID`, `Password`, and `RememberToken`. Always keep `json:"-"` on `Password` and `RememberToken` (and any other secret fields) so they never leak into Inertia props or JSON responses.
- `auth.Session[models.User]{}` is appended to `m.Web` in `bootstrap/app.go`. Register one session middleware for one `User` type, and represent roles (like admin) on `User` and check them in policies rather than adding extra guards.
- Retrieve the signed-in user with `models.CurrentUser(r)` (which returns `nil` for guests). Protect route groups with auth middleware—don't hand-roll session checks inside handlers.
- Name core auth routes (such as `.Name("login")`) so guest redirects, password resets, and email verification links resolve to the right URLs.
- 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 as functions returning `auth.Ability[models.User]` right below the model in `models/<model>.go` (or in `policies/<model>.go` if the project already uses a `policies/` package).
- Return `auth.Allow(condition)` for boolean checks or `auth.Deny("...")` when you need a custom denial message.
- Check abilities in handlers with `if err := auth.Authorize(r, ...); err != nil { return web.Fail(err) }`, or authorize directly on a form struct via its `Authorize` method.

```go
// models/post.go (below the Post struct)
func UpdatePost(post *Post) auth.Ability[User] {
	return func(user *User) error {
		return auth.Allow(user.ID == post.UserID)
	}
}

func DeletePost(post *Post) auth.Ability[User] {
	return func(user *User) error {
		return auth.Allow(user.ID == post.UserID)
	}
}
```

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.