auth-and-securitylisted
Install: claude install-skill dbtinoy-/lexigram-framework-skills
# Auth and Security
## Overview
Lexigram-auth provides JWT-based authentication, RBAC, and web-layer guards. The bundle is wired by `AuthModule`, which exports `AuthenticatorProtocol`, `AuthorizerProtocol`, `TokenManagerProtocol`, and `PasswordHasherProtocol`. In DI you normally resolve `AuthenticationService` (login/register), `AuthProviderProtocol` (async verify), or `JWTTokenManager` (tokens).
## Core Pattern
```python
from lexigram.auth.authn.services import AuthenticationService
from lexigram.contracts.auth.exceptions import InvalidCredentialsError
from lexigram.result import Err, Ok, Result
class LoginService:
def __init__(self, auth_service: AuthenticationService,
tokens: TokenManagerProtocol):
self.auth = auth_service # constructor injection
self.tokens = tokens
async def login(self, email: str, password: str) -> Result[str, str]:
result = await self.auth.authenticate_user(email, password)
match result:
case Err(InvalidCredentialsError()) | Err(_):
return Err("invalid credentials")
case Ok(user):
token = self.tokens.create_token(user)
return Ok(token.access_token)
def require_admin(self, token: str) -> bool:
verified = self.tokens.verify_token(token) # sync, Result[VerifiedToken, TokenError]
match verified:
case Ok(vt):
return "admin" in vt.roles # VerifiedToken.roles: list[s