Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create "App" Schema/CRUD then Link API Keys and Roles #95

Closed
11 tasks done
nelsonic opened this issue Aug 26, 2020 · 4 comments
Closed
11 tasks done

Create "App" Schema/CRUD then Link API Keys and Roles #95

nelsonic opened this issue Aug 26, 2020 · 4 comments
Assignees
Labels
enhancement New feature or enhancement of existing functionality priority-2 Second highest priority, should be worked on as soon as the Priority-1 issues are finished T1d Time Estimate 1 Day technical A technical issue that requires understanding of the code, infrastructure or dependencies

Comments

@nelsonic
Copy link
Member

nelsonic commented Aug 26, 2020

While preparing to create the function that returns the List of Roles for an App https://github.com/dwyl/rbac/issues/3,
I noted that we don't actually have the concept of different "Applications" in Auth right now ... 🙄
Our original idea for the Auth API Key #42 was to allow people to run the DWYL App on their localhost without having to setup an Auth server. That goal was achieved. ✅
However if we want Auth to be a turnkey multi-app auth solution, we need the concept of "Apps".

Gonna transfer a few of the fields over from the API key specifically:

  • name
  • description
  • url
  • person_id

auth/lib/auth/apikey.ex

Lines 9 to 16 in fafc5e0

schema "apikeys" do
field :client_secret, :binary
field :client_id, :binary
field :description, :string
field :name, :string
field :url, :binary
field :person_id, :id
field :status, :id

Todo

  • Create App schema

    • belongs_to person
    • name
    • description
    • url
    • status
    • has_many apikeys
  • Migrate data from API Key to App

  • Update apikeys schema to have a belongs_to so the app owns the key.

Once this is done we will need to:

@nelsonic nelsonic added enhancement New feature or enhancement of existing functionality priority-2 Second highest priority, should be worked on as soon as the Priority-1 issues are finished T1h Time Estimate 1 Hour technical A technical issue that requires understanding of the code, infrastructure or dependencies labels Aug 26, 2020
@nelsonic nelsonic self-assigned this Aug 26, 2020
@nelsonic nelsonic added T1d Time Estimate 1 Day and removed T1h Time Estimate 1 Hour labels Aug 26, 2020
@nelsonic
Copy link
Member Author

After reading through the code that creates API keys, I've realised that it's a bit more work than T1h so I have revised up my estimate. I think think this feature and the corresponding refactor/rework will take me a day. It's at least a couple of hundred lines of code and tests need to be updated/re-written too ... ⏳

@nelsonic nelsonic changed the title Add app_id to role schema/table to separate roles for different apps Create "App" Schema/CRUD then Link API Keys and Roles Aug 26, 2020
@nelsonic
Copy link
Member Author

nelsonic commented Sep 1, 2020

mix phx.gen.html Ctx App apps person_id:references:people name:binary description:binary url:binary status:references:status apikey_id:references:api end:naive_datetime

Default UI for creating an App:
image

Obviously this UI is hideous so I'm going to tidy it up.

@nelsonic
Copy link
Member Author

nelsonic commented Sep 1, 2020

The "end" field is not relevant for now, so this is what the /apps/new form looks like:
image

nelsonic added a commit that referenced this issue Sep 1, 2020
nelsonic added a commit that referenced this issue Sep 1, 2020
@nelsonic
Copy link
Member Author

This issue is complete. #85

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or enhancement of existing functionality priority-2 Second highest priority, should be worked on as soon as the Priority-1 issues are finished T1d Time Estimate 1 Day technical A technical issue that requires understanding of the code, infrastructure or dependencies
Projects
None yet
Development

No branches or pull requests

1 participant