Skip to content

new recipe: gateway-injected rights matrix #48

@divarvel

Description

@divarvel

Context

In a multi-service setup, were rights definitions are managed by a single service. In order to avoid having this service directly queried by everyone every time a token is checked, the gateway can inject relevant information in the token itself, so that the receiving service can check the token in a self-contained way. The service can also use the received token to communicate with other services.

sequenceDiagram
    Client->>Gateway: Request with regular token
    Gateway-->>Gateway: Inject rights matrix in token
    Gateway->>Service A: Request with enriched token
    Service A->>Service B: Sub request with the same token (possibly attenuated)
    Service B->>Service A: Response
    Service A->>Gateway: Response
    Gateway->>Client: Response
Loading

Example

Token sent by the client

user("user_1234");

Block injected by the gateway, signed with the gateway secret key

right("user_1234", "file1", "read");
right("user_1234", "file2", "read");
right("user_1234", "file2", "write");

Authorizer used by the service

resource("file1");
operation("read");
allow if resource($r), operation($op), right("user_123", $r, $op) trusting authority, {gatewayPk};

The service is able to trust the rights matrix provided by the gateway because the gateway has signed the block with its secret key.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions