Skip to content

Draft: Add PUT endpoint to Applications API

Ben King requested to merge benjaminking-put-applications into master

What does this MR do and why?

To-do before un-drafting:

  • Write spec tests
  • Update existing documentation to reflect PUT and also that scopes is now included in the output.

Addresses #458617. A customer has expressed interest in managing instance-level Applications via the API. Based on what access is available via the UI, an Administrator should be able to update:

  • Name
  • Redirect URI
  • Trusted (Note: Not currently returned in any API results at the moment?)
  • Confidential
  • Scopes

This MR provides an iteration to achieve this, by reusing existing parameters from another endpoint. As a result, a PUT endpoint is now available to update any of these parameters by providing an :id in the API:

# Update scopes
curl --request PUT --header "PRIVATE-TOKEN: <token>" "https://gitlab.example.com/api/v4/applications/:id" --data "scopes=read_user email"

# Update name
curl --request PUT --header "PRIVATE-TOKEN: <token>" "https://gitlab.example.com/api/v4/applications/:id?name=new-name"

Also, this MR opens up scopes as a returnable value from Entities::Applications. As an administrator can now change the scopes of an Application, they should be able to see the current/changed value of scopes when interacting with the API. Here's an example from a GET request:

{
    "id": 1,
    "application_id": "<id>",
    "application_name": "GitLab Pages",
    "callback_url": "http://pages.gdk.test:3010/auth",
    "confidential": true,
    "scopes": [
      "read_user",
      "email"
    ]
  }

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

  1. On a GDK instance, create a new Application via the UI or API.
  2. Create a PAT and structure a PUT request against the new API endpoint. See above for example queries.

Merge request reports