Git Product home page Git Product logo

gitlab_composer_token_handler's Introduction

gitlab_composer_token_handler

The reasons for creating this tool are:

  • gitlab deploy tokens can be generated per repository only (cannot be shared between more repositories)
  • composer cannot declare repo-specific basic auth (at least for gitlab)

There are two approaches to mitigate the problem:

  1. create deploy user for all repositories that will be given access to particular environment (production, staging, UAT, ...) and generate a token for him. Cons are gitlab service is paid per user which means: the more environments you need the more money you have to spend for deployment (this isn't a problem w/ comunity edition which is free of charge)
  2. manage the tokens per environment AND repository

This tool was created in order to manage the tokens (point 2) automatically while maintaining the same level of security as of the default basic auth model.

auth.json file has to have a bit different structure. The contents of it should look like this (ie. to contain full repository URL instead of just a FQDN):

{
    "http-basic": {
        "gitlab.selfhosted.domain.tld/repository1.git": {
            "password": "AAAAAAAAAAAAAAAAAAAA",
            "username": "gitlab+deploy-token-11"
        },
        "gitlab.selfhosted.domain.tld/repository2.git": {
            "password": "BBBBBBBBBBBBBBBBBBBB",
            "username": "gitlab+deploy-token-16"
        },
        "gitlab.selfhosted.domain.tld/repository3.git": {
            "password": "CCCCCCCCCCCCCCCCCCCC",
            "username": "gitlab+deploy-token-15"
        },
        "gitlab.selfhosted.domain.tld/repository4.git": {
            "password": "DDDDDDDDDDDDDDDDDDDD",
            "username": "gitlab+deploy-token-12"
        },
        "gitlab.selfhosted.domain.tld/repository5.git": {
            "password": "EEEEEEEEEEEEEEEEEEEE",
            "username": "gitlab+deploy-token-13"
        },
        "gitlab.selfhosted.domain.tld/repository6.git": {
            "password": "FFFFFFFFFFFFFFFFFFFF",
            "username": "gitlab+deploy-token-14"
        }
    }
}

This simple OOP tool allows you to rewrite the composer json files in order to be able to download all dependencies while not storing sensitive data within your repository.

The tool was actually created for use w/ docker so that specific COMPOSER env var is set to the same value as the target file of this script. But works w/out the docker as well.

Example snippet from docker-compose.yml file:

version: '3'
services:
  composer:
    image: composer:1.4
    volumes:
      - htdocs:/app
    environment:
      - COMPOSER=/app/composer_gitignore.json
    command: >
      sh -c "/app/docker/composer_gitlab &&
      composer install --no-suggest --no-interaction"

This way, the script is run just before the composer starts and does all the necessary replacement.

gitlab_composer_token_handler's People

Contributors

helvete avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.