Hide Pages
There are two modes of operation available for scseAuth.
In any mode it is crucial to always have at least one page available that is accessible for unauthroized users (
AccessLevel.ANONYMOUS ). Default mode
The default mode is to only check authorization for pages where scseAuth is explicitly enabled in the script block by calling definePageMeta .
Find more information about
AccessLevel on the Access Levels page. import { definePageMeta, AccessLevel } from '#imports';
definePageMeta({
middleware: 'scse-auth',
scseAuth: {
accessLevel: AccessLevel.NONACCESSOR,
},
});
Restrict all pages mode
There is also a mode, which automatically hides all pages from unauthorized users.
This mode is enabled by setting the restrictAllPages in the configuration. By setting restrictAllPages to true, the default access level is set to AccessLevel.ACCESSOR .
Find more information on how to configure scseAuth on the Configuration page.
scseComponents: {
...
scseAuth: {
enabled: true,
restrictAllPages: true,
...
},
...
}
The default access level may be customized by setting defaultAccessLevel .
scseComponents: {
...
scseAuth: {
enabled: true,
restrictAllPages: {
enabled: true,
defaultAccessLevel: AccessLevel.MANAGER,
},
...
},
...
}
In this mode all pages are hidden from unauthorized users automatically with the default access level. The access level may be overwritten on a page by calling definePageMeta .
import { definePageMeta, AccessLevel } from '#imports';
definePageMeta({
scseAuth: {
accessLevel: AccessLevel.SUPERUSER,
},
});