Kurabu-chan / Kurabu

monorepo for the Kurabu project
BSD 3-Clause "New" or "Revised" License
8 stars 4 forks source link

create public management endpoints #141

Closed rafaeltab closed 2 years ago

rafaeltab commented 2 years ago

Management endpoints

Roles

PUT /api/v1/manage/role

Add a role with a name, and list of scopes

{
  "name": "admin",
  "scopes": [
    "manage:roles",
    "manage:external-applications",
    "..."
  ]
}

returns id of newly created role

DELETE /api/v1/manage/role

Delete a role using its id

PATCH /api/v1/manage/role

Update a role, with name and list of scopes, overrides the current settings.

{
  "name": "admin",
  "scopes": [
    "manage:roles",
    "..."
  ]
}

GET /api/v1/manage/roles

Get a list of all roles and their scopes

returns

[
  {
    "id": "xxx",
    "name": "admin",
    "scopes": [
      "manage:roles",
      "..."
    ]
  },
  {
    "id": "xxx",
    "name": "user",
    "scopes": [
      "anime:details",
      "..."
    ]
  }
]

External applications

PUT /api/v1/manage/externalapplication

Add an external application with name, and configuration

{
  "name": "MyAnimeList",
  "configuration": {
    "baseUrl": "https://api.myanimelist.net/api/v2",
    "authorizationUrl": "https://api.myanimelist.net/api/v2/authorize",
    "...": "..."
  }
}

PATCH /api/v1/manage/externalapplication

Update the configuration for an external application

{
  "configuration": {
     "...": "..."
  } 
} 

DELETE /api/v1/manage/externalapplication

Delete an external api using its id

GET /api/v1/manage/externalapplications

Get all external applications and their confifurations

Clients

PUT /api/v1/manage/client

{
  "name": "kurabu-app",
  "redirectUris": [
    "http://localhost:5000/auth",
    "..."
  ]
}

Create a client with attached redirect uris

DELETE /api/v1/manage/client

Delete a client with attached redirectUris for an id

PATCH /api/v1/manage/client

Update a clients redirect uris for a clientId

GET /api/v1/manage/clients

Get all clients and their redirect uris