Skip to content

`api/v4/projects` w/ Token w/ "read_user" causes unexpected 401 :-(

Summary

Hello, I'm using the Omnibus from debian packages 12.9.2 on Ubuntu 18.04

I am using the API with a Personal Access Token.

Steps to reproduce

Create access tokens with various permissions and throw them at this endpoint:

$ curl "https://sub.example.com/api/v4/projects/2"
{"message":"404 Project Not Found"}%

$ curl --header "PRIVATE-TOKEN: token_with_all_boxes_checked" "https://sub.example.com/api/v4/projects/2"
{"message":"401 Unauthorized"}%

$ curl --header "PRIVATE-TOKEN: token_with_only_sudo" https://sub.example.com/api/v4/projects/2"
{"error":"insufficient_scope","error_description":"The request requires higher privileges than provided by the access token.","scope":"api"}

$ curl --header "PRIVATE-TOKEN: token_with_everything_but_read_user" "https://sub.example.com/api/v4/projects/2"     
{"id":2,"description":"...

Notice that checking all the boxes is counter-intuitive as it diminishes access.

I'm guessing that wasn't intended and is a permissions check bug in that endpoint.

(For installations with omnibus-gitlab package run and paste the output of: sudo gitlab-rake gitlab:env:info)

System information
System:         Ubuntu 18.04
Current User:   git
Using RVM:      no
Ruby Version:   2.6.5p114
Gem Version:    2.7.10
Bundler Version:1.17.3
Rake Version:   12.3.3
Redis Version:  5.0.7
Git Version:    2.24.1
Sidekiq Version:5.2.7
Go Version:     unknown

GitLab information
Version:        12.9.2
Revision:       ac5568eb5d8
Directory:      /opt/gitlab/embedded/service/gitlab-rails
DB Adapter:     PostgreSQL
DB Version:     10.12
Using LDAP:     no
Using Omniauth: yes
Omniauth Providers:

GitLab Shell
Version:        12.0.0
Repository storage paths:
- default:      /var/opt/gitlab/git-data/repositories
GitLab Shell path:              /opt/gitlab/embedded/service/gitlab-shell
Git:            /opt/gitlab/embedded/bin/git

Results of GitLab application Check

sudo gitlab-rake gitlab:check SANITIZE=true)

Checking GitLab subtasks ...                                                                 
                                                                                             
Checking GitLab Shell ...                                                                    
                                                                                             
GitLab Shell: ... GitLab Shell version >= 12.0.0 ? ... OK (12.0.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 ... 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 ...                                                                      
                                                                                             
Git configured correctly? ... yes                                                            
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? ... skipped (no tmp uploads folder yet)       
Init script exists? ... skipped (omnibus-gitlab has no init script)                          
Init script up-to-date? ... skipped (omnibus-gitlab has no init script)                      
Projects have namespace: ...                                                                 
1/1 ... yes                                                                                  
4/2 ... yes                                                                                  
Redis version >= 2.8.0? ... yes                                                              
Ruby version >= 2.5.3 ? ... yes (2.6.5)                                                      
Git version >= 2.22.0 ? ... yes (2.24.1)                                                     
Git user has default SSH configuration? ... yes                                              
Active users: ... 2                                                                          
Is authorized keys file accessible? ... yes                                                  
                                                                                             
Checking GitLab App ... Finished                                                             
                                                                                             
                                                                                             
Checking GitLab subtasks ... Finished                                                        

Possible fixes

Hugs!

Edited by 🤖 GitLab Bot 🤖