Skip to content

Commit

Permalink
Policy logs (#277)
Browse files Browse the repository at this point in the history
* pagy size default

* policy logs

* Update docs/3.0/authorization.md

* Update docs/3.0/authorization.md

* Update docs/3.0/authorization.md

* Update docs/3.0/authorization.md

* Update docs/3.0/authorization.md

* fix code block

* Update docs/3.0/authorization.md
  • Loading branch information
Paul-Bob authored Aug 16, 2024
1 parent bc02589 commit d7b7fb5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
16 changes: 16 additions & 0 deletions docs/3.0/authorization.md
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,22 @@ end

Now, you'll have to provide a policy for each resource you have in your app, thus making it a more secure app.

## Logs
<VersionReq version="3.11.7" />
[Developers](authentication.html#_2-developer-user) have the ability to monitor any unauthorized actions. When a [developer user](authentication.html#_2-developer-user) makes a request that triggers an unauthorized action, a log entry similar to the following will be generated:

In development each log entry provides details about the policy class, the action attempted, the user who made the request, and the record involved:
```bash
web | [Avo->] Unauthorized action 'act_on?' for 'UserPolicy'
web | user: #<User id: 20, first_name: "Avo", last_name: "Cado", roles: {"admin"=>true, "manager"=>false, "writer"=>false}, team_id: nil, slug: "avo-cado", active: true, email: "[email protected]", created_at: "2023-05-20 18:32:32.857042000 +0000", updated_at: "2024-01-03 14:20:00.352895000 +0000">
web | record: User(id: integer, first_name: string, last_name: string, roles: json, team_id: integer, slug: string, active: boolean, email: string, encrypted_password: string, reset_password_token: string, reset_password_sent_at: datetime, remember_created_at: datetime, created_at: datetime, updated_at: datetime)
```

In production each log entry provides details about the policy class and the attempted action:
```bash
web | [Avo->] Unauthorized action 'act_on?' for 'UserPolicy'
```

## Custom policies

<VersionReq version="2.17" />
Expand Down
4 changes: 2 additions & 2 deletions docs/3.0/resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -937,9 +937,9 @@ The exposed pagination setting above have the default value for each key.
#### Possible values
[Pagy docs - Control the page links](https://ddnexus.github.io/pagy/docs/how-to/#control-the-page-links)
#### Default
`[1, 2, 2, 1]` - before <Version version="3.11.4" />
`[1, 2, 2, 1]` - before <Version version="3.11.5" />

`9` - <VersionReq version="3.11.4" />
`9` - <VersionReq version="3.11.5" />

### Examples
#### Default
Expand Down

0 comments on commit d7b7fb5

Please sign in to comment.