ash_authentication/documentation/dsls/DSL:-AshAuthentication.UserIdentity.cheatmd
Zach Daniel bb9b3d7655 chore: analytics in hexdocs
chore: update cheat sheets
2023-10-02 08:38:58 -04:00

319 lines
8 KiB
Text

<!--
This file was generated by Spark. Do not edit it by hand.
-->
# DSL: AshAuthentication.UserIdentity
An Ash extension which generates the default user identities resource.
The user identities resource is used to store information returned by remote
authentication strategies (such as those provided by OAuth2) and maps them to
your user resource(s). This provides the following benefits:
1. A user can be signed in to multiple authentication strategies at once.
2. For those provides which support it AshAuthentication can handle
automatic refreshing of tokens.
## Storage
User identities are expected to be relatively long-lived (although they're
deleted on log out), so should probably be stored using a permanent data layer
sush as `ash_postgres`.
## Usage
There is no need to define any attributes, etc. The extension will generate
them all for you. As there is no other use-case for this resource it's
unlikely that you will need to customise it.
```elixir
defmodule MyApp.Accounts.UserIdentity do
use Ash.Resource,
data_layer: AshPostgres.DataLayer,
extensions: [AshAuthentication.UserIdentity]
user_identity do
api MyApp.Accounts
user_resource MyApp.Accounts.User
end
postgres do
table "user_identities"
repo MyApp.Repo
end
end
```
If you intend to operate with multiple user resources, you will need to define
multiple user identity resources.
## user_identity
Configure identity options for this resource
### Options
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Default</th>
<th colspan=2>Docs</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">
<a id="user_identity-api" href="#user_identity-api">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
api
</span>
</a>
<sup style="color: red">*</sup>
</td>
<td style="text-align: left">
<code class="inline">module</code>
</td>
<td style="text-align: left">
</td>
<td style="text-align: left" colspan=2>
The Ash API to use to access this resource.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="user_identity-user_resource" href="#user_identity-user_resource">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
user_resource
</span>
</a>
<sup style="color: red">*</sup>
</td>
<td style="text-align: left">
<code class="inline">module</code>
</td>
<td style="text-align: left">
</td>
<td style="text-align: left" colspan=2>
The user resource to which these identities belong.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="user_identity-uid_attribute_name" href="#user_identity-uid_attribute_name">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
uid_attribute_name
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">atom</code>
</td>
<td style="text-align: left">
<code class="inline">:uid</code>
</td>
<td style="text-align: left" colspan=2>
The name of the `uid` attribute on this resource.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="user_identity-strategy_attribute_name" href="#user_identity-strategy_attribute_name">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
strategy_attribute_name
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">atom</code>
</td>
<td style="text-align: left">
<code class="inline">:strategy</code>
</td>
<td style="text-align: left" colspan=2>
The name of the `strategy` attribute on this resource.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="user_identity-user_id_attribute_name" href="#user_identity-user_id_attribute_name">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
user_id_attribute_name
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">atom</code>
</td>
<td style="text-align: left">
<code class="inline">:user_id</code>
</td>
<td style="text-align: left" colspan=2>
The name of the `user_id` attribute on this resource.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="user_identity-access_token_attribute_name" href="#user_identity-access_token_attribute_name">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
access_token_attribute_name
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">atom</code>
</td>
<td style="text-align: left">
<code class="inline">:access_token</code>
</td>
<td style="text-align: left" colspan=2>
The name of the `access_token` attribute on this resource.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="user_identity-access_token_expires_at_attribute_name" href="#user_identity-access_token_expires_at_attribute_name">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
access_token_expires_at_attribute_name
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">atom</code>
</td>
<td style="text-align: left">
<code class="inline">:access_token_expires_at</code>
</td>
<td style="text-align: left" colspan=2>
The name of the `access_token_expires_at` attribute on this resource.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="user_identity-refresh_token_attribute_name" href="#user_identity-refresh_token_attribute_name">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
refresh_token_attribute_name
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">atom</code>
</td>
<td style="text-align: left">
<code class="inline">:refresh_token</code>
</td>
<td style="text-align: left" colspan=2>
The name of the `refresh_token` attribute on this resource.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="user_identity-upsert_action_name" href="#user_identity-upsert_action_name">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
upsert_action_name
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">atom</code>
</td>
<td style="text-align: left">
<code class="inline">:upsert</code>
</td>
<td style="text-align: left" colspan=2>
The name of the action used to create and update records.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="user_identity-destroy_action_name" href="#user_identity-destroy_action_name">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
destroy_action_name
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">atom</code>
</td>
<td style="text-align: left">
<code class="inline">:destroy</code>
</td>
<td style="text-align: left" colspan=2>
The name of the action used to destroy records.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="user_identity-read_action_name" href="#user_identity-read_action_name">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
read_action_name
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">atom</code>
</td>
<td style="text-align: left">
<code class="inline">:read</code>
</td>
<td style="text-align: left" colspan=2>
The name of the action used to query identities.
</td>
</tr>
<tr>
<td style="text-align: left">
<a id="user_identity-user_relationship_name" href="#user_identity-user_relationship_name">
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
user_relationship_name
</span>
</a>
</td>
<td style="text-align: left">
<code class="inline">atom</code>
</td>
<td style="text-align: left">
<code class="inline">:user</code>
</td>
<td style="text-align: left" colspan=2>
The name of the belongs-to relationship between identities and users.
</td>
</tr>
</tbody>
</table>