@wild-framework/auth
v0.1.0
Published
Authentication guards and authorization policies for Wild Framework.
Maintainers
Readme
@wild-framework/auth
Authentication guards and authorization policies for Wild Framework.
Install
pnpm add @wild-framework/authUsage
import { AuthManager, Policy } from "@wild-framework/auth";
auth.setUserResolver(async (req) => verifyToken(req.headers.authorization));
router.get("/dashboard", auth.authenticate(), action(Dashboard, "index"));
class PostPolicy extends Policy<Post> {
update(user: User, post: Post) { return user.id === post.authorId; }
}
if (!auth.authorize(PostPolicy, "update", post, user)) throw new ForbiddenException();License
MIT
