Authorization
Published: 2022-05-23
Aside from authentication, authorization is another important aspect of building applications.
RBAC - Role Based Access Control#
WunderGraph supports role based access control to implement authorization.
By default, a WunderGraph application has two roles, "user" and "admin".
You can modify the roles via the configuration object passed to configureWunderGraphApplication
.
// wundergraph.config.tsconfigureWunderGraphApplication({authorization: {roles: ["superadmin","admin","user"]},});
Once the roles are defined, they become available for the @rbac
directive.
You can use this directive to attach rules to Operations so that WunderGraph can determine if a user is allowed to execute an Operation.
Learn more on how to use the @rbac
directive in the directives' documentation.