Navigation and Access
A package adds its pages to the navigation in the left sidebar. Every route, API operation and navigation entry names the actors that may use it; a request without such a declaration is denied.
Navigation entries
Implement Navigation and return the entries. The navigation of the attendance package:
use WebVision\Adsum\Core\Shared\Navigation\NavigationEntries;
use WebVision\Adsum\Core\Shared\Navigation\NavigationEntry;
final readonly class AttendanceNavigation implements NavigationEntries
{
public function entries(): iterable
{
yield new NavigationEntry('myDays', 'myTime', 5, 'nav.myDays', 'clock', 'app_my_days', ['self']);
yield new NavigationEntry('teamDays', 'team', 30, 'nav.teamDays', 'list-checks', 'app_team_days', ['managerInScope', 'hr']);
}
}
The constructor arguments of Navigation are, in this order:
key- A unique key of the entry.
group- The group the entry belongs to.
order- The position in the group. Lower numbers come first; entries with the same number are sorted by key.
labelKey - The translation key of the label, for example
nav.(see Translations and Icons).my Days icon- The name of an icon in the icon set of a package (see Translations and Icons).
route- The route name of the page.
access- The actors that see the entry.
A reader sees an entry only if admitted by its access, and a group only if it has a visible entry. Give an entry
the same access as its page.
Groups
The groups are fixed and shown in this order:
home, shown as Overviewmy, shown as My timeTime team, shown as Teamorganisation, shown as Organisationadministration, shown as Administration
Choose the group by the audience of the page.
Top bar items
A package can add custom elements to the top bar, left of the notification bell, such as the clock of the attendance
package. Implement Top and return the tag names:
use WebVision\Adsum\Core\Shared\Navigation\TopBarItems;
final readonly class ClockTopBar implements TopBarItems
{
public function itemsFor(User $reader, CompanyId $companyId): iterable
{
yield 'tt-clock';
}
}
The class decides whether its elements apply to the reader in that company. Define the custom element in the entry module of the package (see Frontend).
Actors
These actors are valid in #, in x- of the API contract and in navigation entries:
public- Anyone, without login.
anyEmployee - Any logged-in employee of the company.
self- A logged-in user acting on their own data.
participant,manager,In Scope approver- A logged-in user related to the subject: a participant of the record, a manager of the person in their reporting line, or an approver of the request. The action checks the relationship in a voter or a scoped query.
- Derived actors of packages, such as
projectManager - Registered with
#on the class that decides it from current data. A name may be registered once and must not be a core actor; an actor no installed package registers is refused. Core operations use core actors only.[As Access Actor (name: 'project Manager', package: 'adsum- projects')] hr,admin- Holders of the role in the company of the request. The role is checked before the action runs.
The #[Access] attribute
Every controller action declares who may call it with #:
use WebVision\Adsum\Core\Shared\Security\Access;
#[Route('/team/roster', name: 'app_roster', methods: ['GET'])]
#[Access('managerInScope', 'hr')]
public function roster(): Response
{
// ...
}
The attribute goes on a class or a method and takes one or more actors. An action without # answers
403.
OpenAPI x-access
Every operation of the API contract declares the same actors in x- (see API):
workingTimeModels:
get:
operationId: listWorkingTimeModels
x-access:
- anyEmployee
- hr
- admin
An API route declares exactly the actors its operation lists.
Data categories of person fields
A class that describes a person, such as an API resource, an export or a report row, is marked with
#. Each of its properties carries a #:
use WebVision\Adsum\Core\Shared\Security\Category;
use WebVision\Adsum\Core\Shared\Security\DataCategory;
use WebVision\Adsum\Core\Shared\Security\PersonResource;
#[PersonResource]
final readonly class DirectoryEntryResource
{
public function __construct(
#[DataCategory(Category::Directory)]
public string $displayName,
// ...
) {}
}
The category decides who may read a property:
directory- Everyone in the company.
workData - The person, their managers in scope and HR.
personal- The person and HR.
hrInternal - HR only.
The schema in the OpenAPI contract names the same category with x-:
DirectoryEntry:
type: object
properties:
displayName:
type: string
x-data-category: directory