-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(JWT): Generate tenant claims and validate them. (#914)
--------- Co-authored-by: Zach Daniel <[email protected]>
- Loading branch information
1 parent
499e171
commit 62e3ee5
Showing
12 changed files
with
458 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
defmodule Example.Repo.Migrations.FixMultitenancy 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 | ||
drop(constraint(:mt_user_identities, "mt_user_identities_user_id_fkey")) | ||
|
||
alter table(:mt_user_identities) do | ||
modify( | ||
:user_id, | ||
references(:mt_user, | ||
column: :id, | ||
name: "mt_user_identities_user_id_fkey", | ||
type: :uuid, | ||
prefix: "public" | ||
) | ||
) | ||
end | ||
|
||
drop_if_exists(unique_index(:mt_user, [:username], name: "mt_user_username_index")) | ||
|
||
create unique_index(:mt_user, [:organisation_id, :username], name: "mt_user_username_index") | ||
end | ||
|
||
def down do | ||
drop_if_exists( | ||
unique_index(:mt_user, [:organisation_id, :username], name: "mt_user_username_index") | ||
) | ||
|
||
create unique_index(:mt_user, [:organisation_id, :username], name: "mt_user_username_index") | ||
|
||
drop(constraint(:mt_user_identities, "mt_user_identities_user_id_fkey")) | ||
|
||
alter table(:mt_user_identities) do | ||
modify( | ||
:user_id, | ||
references(:mt_user, | ||
column: :id, | ||
name: "mt_user_identities_user_id_fkey", | ||
type: :uuid, | ||
prefix: "public" | ||
) | ||
) | ||
end | ||
end | ||
end |
143 changes: 143 additions & 0 deletions
143
priv/resource_snapshots/repo/mt_user/20250218213646.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
{ | ||
"attributes": [ | ||
{ | ||
"allow_nil?": true, | ||
"default": "nil", | ||
"generated?": false, | ||
"primary_key?": false, | ||
"references": null, | ||
"size": null, | ||
"source": "confirmed_at", | ||
"type": "utc_datetime_usec" | ||
}, | ||
{ | ||
"allow_nil?": false, | ||
"default": "fragment(\"gen_random_uuid()\")", | ||
"generated?": false, | ||
"primary_key?": true, | ||
"references": null, | ||
"size": null, | ||
"source": "id", | ||
"type": "uuid" | ||
}, | ||
{ | ||
"allow_nil?": false, | ||
"default": "nil", | ||
"generated?": false, | ||
"primary_key?": false, | ||
"references": null, | ||
"size": null, | ||
"source": "username", | ||
"type": "citext" | ||
}, | ||
{ | ||
"allow_nil?": true, | ||
"default": "nil", | ||
"generated?": false, | ||
"primary_key?": false, | ||
"references": null, | ||
"size": null, | ||
"source": "extra_stuff", | ||
"type": "text" | ||
}, | ||
{ | ||
"allow_nil?": true, | ||
"default": "nil", | ||
"generated?": false, | ||
"primary_key?": false, | ||
"references": null, | ||
"size": null, | ||
"source": "not_accepted_extra_stuff", | ||
"type": "text" | ||
}, | ||
{ | ||
"allow_nil?": true, | ||
"default": "nil", | ||
"generated?": false, | ||
"primary_key?": false, | ||
"references": null, | ||
"size": null, | ||
"source": "hashed_password", | ||
"type": "text" | ||
}, | ||
{ | ||
"allow_nil?": false, | ||
"default": "fragment(\"(now() AT TIME ZONE 'utc')\")", | ||
"generated?": false, | ||
"primary_key?": false, | ||
"references": null, | ||
"size": null, | ||
"source": "created_at", | ||
"type": "utc_datetime_usec" | ||
}, | ||
{ | ||
"allow_nil?": false, | ||
"default": "fragment(\"(now() AT TIME ZONE 'utc')\")", | ||
"generated?": false, | ||
"primary_key?": false, | ||
"references": null, | ||
"size": null, | ||
"source": "updated_at", | ||
"type": "utc_datetime_usec" | ||
}, | ||
{ | ||
"allow_nil?": true, | ||
"default": "nil", | ||
"generated?": false, | ||
"primary_key?": false, | ||
"references": { | ||
"deferrable": false, | ||
"destination_attribute": "id", | ||
"destination_attribute_default": null, | ||
"destination_attribute_generated": null, | ||
"index?": false, | ||
"match_type": null, | ||
"match_with": null, | ||
"multitenancy": { | ||
"attribute": "id", | ||
"global": true, | ||
"strategy": "attribute" | ||
}, | ||
"name": "mt_user_organisation_id_fkey", | ||
"on_delete": null, | ||
"on_update": null, | ||
"primary_key?": true, | ||
"schema": "public", | ||
"table": "mt_organisations" | ||
}, | ||
"size": null, | ||
"source": "organisation_id", | ||
"type": "uuid" | ||
} | ||
], | ||
"base_filter": null, | ||
"check_constraints": [], | ||
"custom_indexes": [], | ||
"custom_statements": [], | ||
"has_create_action": true, | ||
"hash": "E91884DBA76BFF56614A2A94307466EB6BA1605CE6E0D291507A3AADF362892A", | ||
"identities": [ | ||
{ | ||
"all_tenants?": false, | ||
"base_filter": null, | ||
"index_name": "mt_user_username_index", | ||
"keys": [ | ||
{ | ||
"type": "atom", | ||
"value": "username" | ||
} | ||
], | ||
"name": "username", | ||
"nils_distinct?": true, | ||
"where": null | ||
} | ||
], | ||
"multitenancy": { | ||
"attribute": "organisation_id", | ||
"global": true, | ||
"strategy": "attribute" | ||
}, | ||
"repo": "Elixir.Example.Repo", | ||
"schema": null, | ||
"table": "mt_user" | ||
} |
Oops, something went wrong.