-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This will allow us to enable api-driven oidc provider generation in a more general way. It can also help us unify the basics of the legacy OSS provisioning w/ our current fleet management approach, while also allowing users to support internal apps w/ it.
- Loading branch information
1 parent
6a735f7
commit 89e1013
Showing
16 changed files
with
445 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
defmodule Core.Policies.OAuth do | ||
use Piazza.Policy | ||
alias Core.Schema.{User, OIDCProvider} | ||
|
||
def can?(%User{id: id}, %OIDCProvider{owner_id: id}, _), do: :pass | ||
|
||
def can?(user, %Ecto.Changeset{} = cs, action), | ||
do: can?(user, apply_changes(cs), action) | ||
|
||
def can?(_, _, _), do: {:error, :forbidden} | ||
end |
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
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
11 changes: 11 additions & 0 deletions
11
apps/core/priv/repo/migrations/20241005171529_add_owner_id_oidc_provider.exs
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,11 @@ | ||
defmodule Core.Repo.Migrations.AddOwnerIdOidcProvider do | ||
use Ecto.Migration | ||
|
||
def change do | ||
alter table(:oidc_providers) do | ||
add :name, :string | ||
add :description, :string | ||
add :owner_id, references(:users, type: :uuid, on_delete: :delete_all) | ||
end | ||
end | ||
end |
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
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
Oops, something went wrong.