typegraphql-authchecker
typegraphql-authchecker copied to clipboard
[feature request]: add customizable default rules to all @Authorized() decoration
I have a specialRule authorization rule that needs to be added to all of my @Authorized(otherRules) so that this behavior
@Authorized({
OR: [
specialRule,
{AND: otherRules}
]
})
is observed
while simply writing @Authorized(otherRules) for specific typegraphql resolvers
where otherRules could be some other combination of rules using AND, OR, NOT from this library.
This would avoid me from writing that same rule pattern for every @Authorized() decoration.
The usage I'm envisioning is something like, in typegraphql's buildSchema call
import {createCustomAuthChecker} from 'typegraphql-authchecker';
// passing a callback function to create a custom authchecker
// the authchecker would run this callback in lieu
const customAuthChecker = createCustomAuthChecker(
(otherRules) => ({
OR: [
specialRule,
{AND: otherRules}
]
})
);
buildSchema({
resolvers: resolvers,
authChecker: customAuthChecker,
});