hsynlms / fastify-guard Goto Github PK
View Code? Open in Web Editor NEWA simple user role and scope check plugin to protect endpoints for Fastify
License: MIT License
A simple user role and scope check plugin to protect endpoints for Fastify
License: MIT License
FastifyError [Error]: fastify-plugin: fastify-guard - expected '3.x' fastify version, '4.2.0' is installed
In the README.md
This code doesn't work:
{ preHandler: [fastify.guard.role(['cto', 'admin'])] },
Instead it should be without []
{ preHandler: [fastify.guard.role('cto', 'admin')] },
When new PRs are sent, there is no CI mechanism to check changes and linter errors.
For people who want to send PR.
We do not need environment-specific ignored files. Instead, only ignore project-specific things. Contributors need to ignore environment-specific things like .vscode
, .DS_STORE
etc, in their global gitignore file.
With the update of 1.3.0 my project has been broken.
With this declaration
role(roles: string | string[]): preHandlerHookHandler
Only allow
role('ADMIN') or role(['ADMIN','USER']);
Therefore this would not work
// this route can only be called by users who has 'admin' or 'editor' role
fastify.get(
'/',
{ preHandler: [fastify.guard.role('admin', 'editor')] },
(req, reply) => {
// 'user' should already be defined in req object
reply.send(req.user)
}
)
To enable this functionality it should be:
role(...roles: string[]): preHandlerHookHandler
role(roles: string[]): preHandlerHookHandler
The same happens with the scope function
scope(scopes: string | string[]): preHandlerHookHandler
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.