ash_authentication/priv/repo/migrations/20230111010206_add_user_with_token_required_resource.exs
James Harton d5c5d6b6c5
feat: Add token-required-for-authentication feature. (#116)
* Adds the `require_token_presence_for_authentication?` DSL option to the Authentication extension which when enabled changes the following behaviour:
  1. The `store_in_session` plug will store the user's token rather than their subject in the session.
  2. The `retrieve_from_session` plug will look for a stored token in the session rather than a subject and ensure that it's present in the `TokenResource`.
  3. The `retrieve_from_bearer` plug will ensure that the token is present in the `TokenResource`.
* Adds the `get_token` action to the `TokenResource`.
2023-01-11 15:12:53 +13:00

31 lines
No EOL
1 KiB
Elixir

defmodule Example.Repo.Migrations.AddUserWithTokenRequiredResource do
@moduledoc """
Updates resources based on their most recent snapshots.
This file was autogenerated with `mix ash_postgres.generate_migrations`
"""
use Ecto.Migration
def up do
create table(:user_with_token_required, primary_key: false) do
add :id, :uuid, null: false, default: fragment("uuid_generate_v4()"), primary_key: true
add :email, :citext, null: false
add :hashed_password, :text
add :created_at, :utc_datetime_usec, null: false, default: fragment("now()")
add :updated_at, :utc_datetime_usec, null: false, default: fragment("now()")
end
create unique_index(:user_with_token_required, [:email],
name: "user_with_token_required_email_index"
)
end
def down do
drop_if_exists unique_index(:user_with_token_required, [:email],
name: "user_with_token_required_email_index"
)
drop table(:user_with_token_required)
end
end