Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use string preprocessor and remove functions #17

Merged
merged 2 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,35 +68,6 @@ Example usage:
let update_title = Article.update_title ?ctx mike thomas_article "Updated Title"
```

### Integrate within a query (MariaDB)

Requirement: Run `MariaDb.start` when the executable is started.

The `start` function defines needed MariaDB functions for guardian. They can be integrated within your queries as well.
It creates a `guardianValidate<Role>Uuid(...)` function for all roles, it takes care of all registered Relations within guardian.

The following example shows how to check for a specific Post:

```ocaml
(** [guardianValidatePostUuid]

Input arguments:
- actor_uuid (binary 16)
- action (enum: 'create','read','update','delete','manage')
- target_uuid (binary 16, usually within the query)

Outputs a boolean
*)
let find_accessible kind =
{sql|
SELECT *
FROM posts
GROUP BY posts.uuid
HAVING guardianValidatePostUuid(guardianEncodeUuid(?), ?, posts.uuid)
|sql}
|> Caqti_type.(t2 UuidActor.t Action.t ->* Post.t)
```

## Development

A guide how to setup the project with devcontainers can be found [here](./.devcontainer/README.md).
Expand Down
Loading
Loading