API returns code 403 when accessing pipeline schedule variables with a project access token.

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Summary

API returns code 403 when accessing pipeline schedule variables with a project access token.

Steps to reproduce

  1. Create a project and note its project_id
  2. Add some form of CI
  3. Create a schedule and note its schedule_id
  4. Create a project access token with scope "api".
  5. Try to create/update/delete a pipeline schedule variable following the examples of https://docs.gitlab.com/ee/api/pipeline_schedules.html#pipeline-schedule-variables, using your freshly generated project access token for <your_access_token>, your API URL, your project-id and your pipeline_schedule_id.

Example Project

Try the examples in https://docs.gitlab.com/ee/api/pipeline_schedules.html#pipeline-schedule-variables with a project access token.

What is the current bug behavior?

  • If I use the above mentioned project access token, the API call returns {"message":"403 Forbidden"}
  • If I use a user's access token with scope "api", the API call returns 200 OK.

Not sure if it is an expected limitation though.

What is the expected correct behavior?

When using a project access token, the API call shall create/update/delete the schedule variable and return 200 (OK)

More details

  • API to update a project variable
    • curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/variables/MY_VARIABLE" --form "value=updated value"
    • works with either a project access token and a personal access token.
  • API for to update a pipeline schedule variable
    • curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" --form "value=updated value" "https://gitlab.example.com/api/v4/projects/29/pipeline_schedules/13/variables/MY_VARIABLE"
    • works with a personal access token
    • does not work with a project access token

Results of GitLab environment info

Gitlab deployed as docker container on private infrastructure.

Expand for output related to the GitLab environment info
System information
System:
Current User:   git
Using RVM:      no
Ruby Version:   2.7.5p203
Gem Version:    3.1.4
Bundler Version:2.3.15
Rake Version:   13.0.6
Redis Version:  6.2.7
Sidekiq Version:6.4.0
Go Version:     unknown

GitLab information Version: 15.2.2 Revision: 4ecb014a935 Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: PostgreSQL DB Version: 14.2 URL: https://BASE_URL HTTP Clone URL: https://BASE_URL/some-group/some-project.git SSH Clone URL: ssh://BASE_URL/some-group/some-project.git Using LDAP: no Using Omniauth: yes Omniauth Providers: openid_connect

GitLab Shell Version: 14.9.0 Repository storage paths:

  • default: /var/opt/gitlab/git-data/repositories GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell

Results of GitLab application Check

Expand for output related to the GitLab application check
Checking GitLab subtasks ...

Checking GitLab Shell ...

GitLab Shell: ... GitLab Shell version >= 14.9.0 ? ... OK (14.9.0) Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Internal API available: OK Redis available via internal API: OK gitlab-shell self-check successful

Checking GitLab Shell ... Finished

Checking Gitaly ...

Gitaly: ... default ... OK

Checking Gitaly ... Finished

Checking Sidekiq ...

Sidekiq: ... Running? ... yes Number of Sidekiq processes (cluster/worker) ... 1/1

Checking Sidekiq ... Finished

Checking Incoming Email ...

Incoming Email: ... Reply by email is disabled in config/gitlab.yml

Checking Incoming Email ... Finished

Checking LDAP ...

LDAP: ... LDAP is disabled in config/gitlab.yml

Checking LDAP ... Finished

Checking GitLab App ...

Database config exists? ... yes All migrations up? ... yes Database contains orphaned GroupMembers? ... no GitLab config exists? ... yes GitLab config up to date? ... yes Log directory writable? ... yes Tmp directory writable? ... yes Uploads directory exists? ... yes Uploads directory has correct permissions? ... yes Uploads directory tmp has correct permissions? ... yes Systemd unit files or init script exist? ... skipped (omnibus-gitlab has neither init script nor systemd units) Systemd unit files or init script up-to-date? ... skipped (omnibus-gitlab has neither init script nor systemd units) Projects have namespace: ... 2/1 ... yes 7/4 ... yes 7/5 ... yes 61/6 ... yes 7/7 ... yes 7/8 ... yes 7/9 ... yes 7/10 ... yes 30/11 ... yes 30/12 ... yes 30/13 ... yes 61/15 ... yes 7/16 ... yes 7/17 ... yes 49/18 ... yes 49/19 ... yes 62/20 ... yes 62/21 ... yes 62/22 ... yes 66/23 ... yes 67/24 ... yes 70/25 ... yes 61/26 ... yes 67/27 ... yes 70/28 ... yes Redis version >= 6.0.0? ... yes Ruby version >= 2.7.2 ? ... yes (2.7.5) Git user has default SSH configuration? ... yes Active users: ... 33 Is authorized keys file accessible? ... yes GitLab configured to store new projects in hashed storage? ... yes All projects are in hashed storage? ... yes

Checking GitLab App ... Finished

Checking GitLab subtasks ... Finished

Possible fixes

No idea.

Edited by 🤖 GitLab Bot 🤖