Skip to content

Commit

Permalink
Improve README titles
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielpra1 committed Dec 23, 2019
1 parent 7ab8e73 commit 84b866e
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ Middlewares usage can be found below.

## Middlewares

## Query Authorization
### Query Authorization

Ensures Absinthe's queries can only be accessed by determined users.

Usage:
#### Usage:

[Create your Authorization module and add it and QueryAuthorization to your Absinthe.Schema](#usage). Then set the permitted role to access a query or mutation:

Expand Down Expand Up @@ -127,15 +127,15 @@ Usage:

Query authorization will call [role_authorized?/2](https://hexdocs.pm/rajska/Rajska.Authorization.html#c:role_authorized?/2) to check if the [user](https://hexdocs.pm/rajska/Rajska.Authorization.html#c:get_current_user/1) [role](https://hexdocs.pm/rajska/Rajska.Authorization.html#c:get_user_role/1) is authorized to perform the query.

## Query Scope Authorization
### Query Scope Authorization

Provides scoping to Absinthe's queries, as seen above in [Query Authorization](#query-authorization).

In the above example, `:all` and `:admin` (`super_role`) permissions don't require the `:scope` keyword, but you can modify this behavior by overriding the [not_scoped_roles/0](https://hexdocs.pm/rajska/Rajska.Authorization.html#c:not_scoped_roles/0) function.

There are also extra options for this middleware, supporting the definition of custom rules, access of nested parameters and allowing optional parameters. All possibilities are listed below:

### Options
#### Options

All the following options are sent to [has_user_access?/3](https://hexdocs.pm/rajska/Rajska.Authorization.html#c:has_user_access?/3):

Expand All @@ -149,11 +149,11 @@ All the following options are sent to [has_user_access?/3](https://hexdocs.pm/ra
* `:optional` (optional) - when set to true the arguments are optional, so if no argument is provided, the query will be authorized. Defaults to false.
* `:rule` (optional) - allows the same struct to have different rules. See `Rajska.Authorization` for `rule` default settings.

## Object Authorization
### Object Authorization

Authorizes all Absinthe's [objects](https://hexdocs.pm/absinthe/Absinthe.Schema.Notation.html#object/3) requested in a query by checking the permission defined in each object meta `authorize`.

Usage:
#### Usage:

[Create your Authorization module and add it and ObjectAuthorization to your Absinthe.Schema](#usage). Then set the permitted role to access an object:

Expand Down Expand Up @@ -182,7 +182,7 @@ Usage:
With the permissions above, a query like the following would only be allowed by an admin user:

```graphql
{
{
userQuery {
name
email
Expand All @@ -196,13 +196,13 @@ With the permissions above, a query like the following would only be allowed by

Object Authorization middleware runs after Query Authorization middleware (if added) and before the query is resolved by recursively checking the requested objects permissions in the [role_authorized?/2](https://hexdocs.pm/rajska/Rajska.Authorization.html#c:role_authorized?/2) function (which is also used by Query Authorization). It can be overridden by your own implementation.

## Object Scope Authorization
### Object Scope Authorization

Absinthe Phase to perform object scoping.

Authorizes all Absinthe's [objects](https://hexdocs.pm/absinthe/Absinthe.Schema.Notation.html#object/3) requested in a query by checking the underlying struct.

Usage:
#### Usage:

[Create your Authorization module and add it and ObjectScopeAuthorization to your Absinthe pipeline](#usage). Then set the scope of an object:

Expand Down Expand Up @@ -254,11 +254,11 @@ end

This way different rules can be set to the same struct.

## Field Authorization
### Field Authorization

Authorizes Absinthe's object [field](https://hexdocs.pm/absinthe/Absinthe.Schema.Notation.html#field/4) according to the result of the [has_user_access?/3](https://hexdocs.pm/rajska/Rajska.Authorization.html#c:has_user_access?/3) function, which receives the user role, the `source` object that is resolving the field and the field rule.

Usage:
#### Usage:

[Create your Authorization module and add it and FieldAuthorization to your Absinthe.Schema](#usage).

Expand Down

0 comments on commit 84b866e

Please sign in to comment.