Skip to content

Group token HTTP authentication

Serena Fang requested to merge group-token-http-authenticate into master

What does this MR do?

Group access tokens should be able to pull/push with git over http: #330718 (closed)

When attempting to use a resource access token to authenticate against git over http, add a check to see if the resource access token belongs to a user in either the project or an ancestor group; if yes, allow authentication.

This MR is an extension of !40635 (merged), which introduced the ability for project access tokens to authenticate over http.

To generate a group access token:

pry(main)> root = User.find(1) # group admin
pry(main)> group = Group.find(109) # the group you want to create a token for
pry(main)> bot = Users::CreateService.new(root, { name: 'group_token', email: 'group_109_bot@example.com', username: 'group_109_bot', user_type: :project_bot }).execute # create the bot user
pry(main)> bot.confirm
pry(main)> group.add_user(bot, :maintainer) # add it to the group
pry(main)> token = bot.personal_access_tokens.create(scopes:[:api, :write_repository], name: 'group_token') # give it a personal access token
pry(main)> gtoken = token.token # get the token value; note that we need the token value and not token_digest

% GROUPTOKEN = <gtoken value from above>

Before:

% git clone http://group_107_bot2:$GROUPTOKEN@127.0.0.1:3000/newgroup/newproject.git
Cloning into 'newproject'...
remote: HTTP Basic: Access denied
fatal: Authentication failed for 'http://127.0.0.1:3000/newgroup/newproject.git/'

After:

% git clone http://group_107_bot2:$GROUPTOKEN@127.0.0.1:3000/newgroup/newproject.git
Cloning into 'newproject'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (3/3), done.
warning: remote HEAD refers to nonexistent ref, unable to checkout.

Screenshots or Screencasts (strongly suggested)

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

Does this MR contain changes to processing or storing of credentials or tokens, authorization and authentication methods or other items described in the security review guidelines? If not, then delete this Security section.

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Serena Fang

Merge request reports