Secure Route Component

Using SecureRoute React component

The SecureRoute component will prevent rendering a route if the user doesn't have the matched permissions (either security scopes or security roles). The following attributes roles and scopes can be specified and found once you click Security -> Roles and Groups -> Roles.

Values for the roles attribute can be found here:

Security Role Example

Values for the scopes attribute can be found here:

Security Scope Example

import { SecureRoute } from "@webiny/app-security/components";
/**
In this example, the roles and scopes used are definitions
you might define in order to build an e-library.
**/
function myComponent() {
return (
<SecureRoute
roles={["book-access"]}
scopes={["library:books:get"]}
>
<Book />
</SecureRoute>
)
}

If the user does not have the defined roles or scopes permissions, the SecureRoute component will either render a secure-route-error plugin, otherwise it will render a span containing a string "You are not authorized to view this route.".

Last updated on by Adrian Smijulj