Giter Club home page Giter Club logo

verdaccio-gitlab's Introduction

Verdaccio-GitLab

Use GitLab Community Edition as authentication provider for the private npm registry Verdaccio, the sinopia fork.

npm build dependencies

The main goal and differences from other sinopia/verdaccio plugins are the following:

  • no admin token required
  • user authenticates with Personal Access Token
  • access & publish packages depending on user rights in gitlab

This is experimental!

Use it

You need at least node version 8.x.x, codename carbon.

git clone https://github.com/bufferoverflow/verdaccio-gitlab.git
cd verdaccio-gitlab
yarn install
yarn start

NOTE: Define http_proxy environment variable if you are behind a proxy.

Verdaccio is now up and running. In order the see this plugin in action, you can use the following Verdaccio configuration in your ~/.config/verdaccio/config.yaml.

# Verdaccio storage location relative to $HOME/.config/verdaccio
storage: ./storage

listen:
  - 0.0.0.0:4873

auth:
  gitlab:
    url: https://gitlab.com

uplinks:
  npmjs:
    url: https://registry.npmjs.org/

packages:
  '@*/*':
    # scoped packages
    access: $all
    publish: $maintainer
    proxy: npmjs
    gitlab: true

  '**':
    access: $all
    publish: $maintainer
    proxy: npmjs
    gitlab: true

# Log level can be changed to info, http etc. for less verbose output
logs:
  - {type: stdout, format: pretty, level: debug}

Restart Verdaccio and authenticate into it with your credentials

using the Web UI http://localhost:4873 or via npm CLI:

yarn login --registry http://localhost:4873

and publish packages:

yarn publish --registry http://localhost:4873

Access Levels

Access and publish access rights are mapped following the rules below.

verdaccio-gitlab access control will only be applied to package sections that are marked with gitlab: true as in the configuration sample above. If you wish to disable gitlab authentication to any package config, just remove the element from the config.

Access

access is allowed depending on the following verdaccio package configuration directives:

  • authenticated users are able to access all packages
  • unauthenticated users will be able to access packages marked with either $all or $anonymous access levels at the package group definition

Please note that no group or package name mapping is applied on access, any user successfully authenticated can access all packages.

Publish

publish is allowed if:

  1. the package name matches the GitLab username, or
  2. if the package name or scope of the package matches one of the user's GitLab groups, or
  3. if the package name (possibly scoped) matches on the user's GitLab projects.

For 2. and 3., the GitLab user must have the access rights on the group or project as specified in the auth.gitlab.publish setting.

For instance, assuming the following configuration:

auth:
  gitlab:
    publish = $maintainer

The GitLab user sample_user has access to:

  • Group group1 as $maintainer
  • Group group2 as $reporter
  • Project group3/project as $maintainer

Then this user would be able to:

  • access any package
  • publish any of the following packages:
    • sample_user
    • group1
    • any package under @group1/**
    • @group3/project

There would be an error if the user tried to publish any package under @group2/**.

Configuration Options

The full set of configuration options is:

auth:
  gitlab:
    url: <url>
    authCache:
      enabled: <boolean>
      ttl: <integer>
    publish: <string>
Option Default Type Description
url <empty> url mandatory, the url of the gitlab server
authCache: enabled true boolean activate in-memory authentication cache
authCache: ttl 300 (0=unlimited) integer time-to-live of entries in the authentication cache, in seconds
publish $maintainer [$guest, $reporter, $developer, $maintainer, $owner] group minimum access level of the logged in user required for npm publish operations

Authentication Cache

In order to avoid too many authentication requests to the underlying gitlab instance, the plugin provides an in-memory cache that will save the detected groups of the users for a configurable ttl in seconds.

No clear-text password is saved in-memory, just an SHA-256 hash of the user+password, plus the groups information.

By default, the cache will be enabled and the credentials will be stored for 300 seconds. The ttl is checked on access, but there's also an internal timer that will check expired values regularly, so data of users not actively interacting with the system will also be eventually invalidated.

Please note that this implementation is in-memory and not multi-process; if the cluster module is used for starting several verdaccio processes, each process will store its own copy of the cache, so each user will actually be logged in multiple times.

Docker

git clone https://github.com/bufferoverflow/verdaccio-gitlab.git
cd verdaccio-gitlab
docker-compose up --build -d

The Dockerfile provides a default configuration file that is internally available under /verdaccio/conf/config.yaml. In order to overwrite this configuration you can provide your own file and mount it on docker startup with the --volume option, or equivalent mechanism (e.g. ConfigMaps on Kubernetes / OpenShift with the helm chart).

Development

Contributing

Please adhere to the verdaccio community guidelines and run all the tests before creating a PR. The commit message shall follow the conventional changelog as it is enforced via local commit hook using husky and the @commitlint/config-conventional rule set.

PR's that do not pass CI will not be reviewed.

Create a Release

Run one of the following command to create a release:

yarn release:major
yarn release:minor
yarn release:patch

finally run

yarn publish

Functional Tests

In order to run functional tests with debug output, set the VERDACCIO_DEBUG=true environment variable, as documented by verdaccio:

VERDACCIO_DEBUG=true yarn test:functional

License

MIT

verdaccio-gitlab's People

Contributors

bufferoverflow avatar claudio0603 avatar dependabot[bot] avatar dlouzan avatar ercanucan avatar gfwagnitz avatar jstarry avatar juanpicado avatar max-wittig avatar nicolasbouffard avatar slhck avatar stevenlangbroek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

verdaccio-gitlab's Issues

Use with CI_JOB_TOKEN

Is it possible to login to verdaccio with the gitlab-ci-token user and the $CI_JOB_TOKENenv var during CI builds?

Access to custom scope based on specific gitlab group

I'm trying to allow a custom package prefix based on the same group.

Let's say that telokis-group really exists on Gitlab (and I have full access to it).
I would like to allow a totally unrelated (possibly already existing) scope based on the same permission.
Trying the following config gives me 403 error when I try to publish a package to @totally-different-group.

packages:
    "@totally-different-group/*":
        access: telokis-group
        publish: telokis-group
        gitlab: true
        unpublish:

    "@telokis-group/*":
        access: telokis-group
        publish: telokis-group
        gitlab: true
        unpublish:

The error I get is

npm ERR! code E403
npm ERR! 403 403 Forbidden - PUT http://localhost:4873/@totally-different-group%2ftest2 - must have required permissions:  at package-scope
npm ERR! 403 In most cases, you or one of your dependencies are requesting
npm ERR! 403 a package version that is forbidden by your security policy.

It works fine when I change totally-different-group to telokis-group.

is dumb-init really required?

Today as used within verdaccio docker image, dumb-init is used, see https://github.com/bufferoverflow/verdaccio-gitlab/blob/master/Dockerfile#L39 .

Do we really need that ? How is kubernetes and Openshift handling this?

The node image is using the node user, see https://github.com/nodejs/docker-node/blob/master/docs/BestPractices.md#non-root-user, so using this instead of the verdaccio user would simplify that.

/cc @dlouzan @ercanucan

UncaughtPromiseRejectionWarning: Error: `token` (private-token) or `oauth_token` is mandatory on startup

Hi, when starting the service, I get the following error;

Aug 13 01:18:27 web.jojoxd.nl verdaccio[14116]: warn --- config file  - /opt/npm-repo/config.yaml
Aug 13 01:18:27 web.jojoxd.nl verdaccio[14116]: (node:14116) UnhandledPromiseRejectionWarning: Error: `token` (private-token) or `oauth_token` is mandatory
Aug 13 01:18:27 web.jojoxd.nl verdaccio[14116]: at new BaseModel (/opt/verdaccio/node_modules/gitlab/dist/latest/infrastructure/BaseService.js:33:13)
Aug 13 01:18:27 web.jojoxd.nl verdaccio[14116]: at new Groups (/opt/verdaccio/node_modules/gitlab/dist/latest/services/Groups.js:10:1)
Aug 13 01:18:27 web.jojoxd.nl verdaccio[14116]: at /opt/verdaccio/node_modules/gitlab/dist/latest/infrastructure/Bundler.js:13:22
Aug 13 01:18:27 web.jojoxd.nl verdaccio[14116]: at Array.forEach (<anonymous>)
Aug 13 01:18:27 web.jojoxd.nl verdaccio[14116]: at new Bundle (/opt/verdaccio/node_modules/gitlab/dist/latest/infrastructure/Bundler.js:12:32)
Aug 13 01:18:27 web.jojoxd.nl verdaccio[14116]: at /opt/verdaccio/node_modules/verdaccio/build/lib/plugin-loader.js:114:30
Aug 13 01:18:27 web.jojoxd.nl verdaccio[14116]: at Array.map (<anonymous>)
Aug 13 01:18:27 web.jojoxd.nl verdaccio[14116]: at loadPlugin (/opt/verdaccio/node_modules/verdaccio/build/lib/plugin-loader.js:65:37)
Aug 13 01:18:27 web.jojoxd.nl verdaccio[14116]: at Auth._loadPlugin (/opt/verdaccio/node_modules/verdaccio/build/lib/auth.js:45:39)
Aug 13 01:18:27 web.jojoxd.nl verdaccio[14116]: at new Auth (/opt/verdaccio/node_modules/verdaccio/build/lib/auth.js:35:25)
Aug 13 01:18:27 web.jojoxd.nl verdaccio[14116]: at defineAPI (/opt/verdaccio/node_modules/verdaccio/build/api/index.js:60:16)
Aug 13 01:18:27 web.jojoxd.nl verdaccio[14116]: at /opt/verdaccio/node_modules/verdaccio/build/api/index.js:146:12
Aug 13 01:18:27 web.jojoxd.nl verdaccio[14116]: at Generator.next (<anonymous>)
Aug 13 01:18:27 web.jojoxd.nl verdaccio[14116]: at step (/opt/verdaccio/node_modules/verdaccio/build/api/index.js:53:191)
Aug 13 01:18:27 web.jojoxd.nl verdaccio[14116]: at /opt/verdaccio/node_modules/verdaccio/build/api/index.js:53:361
Aug 13 01:18:27 web.jojoxd.nl verdaccio[14116]: at processTicksAndRejections (internal/process/task_queues.js:85:5)
Aug 13 01:18:27 web.jojoxd.nl verdaccio[14116]: (node:14116) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
Aug 13 01:18:27 web.jojoxd.nl verdaccio[14116]: (node:14116) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Node Version: v12.8.0
Yarn Version: 1.17.3
OS: CentOS 7

I am trying to run the service as a systemd service, and have tried running it as the user itself.

these are my configurations:

storage: /opt/npm-repo/storage

listen:
  - /run/verdaccio/verdaccio.sock

auth:
  gitlab:
    url: https://gitlab.jojoxd.nl
    authCache:
      enabled: true
      ttl: 300
    publish: $maintainer

packages:
  '@jojoxd/*':
    access: $all
    publish: $authenticated
    gitlab: true

logs:
  - {type: stdout, format: pretty, level: debug}
[Unit]
Description=Verdaccio Service (Private NPM Registry)

Wants=network-online.target
After=network-online.target
After=nginx.service

[Service]
Type=simple
User=www-data
Group=www-data
WorkingDirectory=/opt/verdaccio
RuntimeDirectory=verdaccio

PermissionsStartOnly=true

ExecStart=/opt/verdaccio/bin/verdaccio -c /opt/npm-repo/config.yaml

[Install]
WantedBy=multi-user.target

I have run the yarn install job manually, and am running on the v2.2.0 tag. (master does the same).

The /run/verdaccio/verdaccio.sock is an upstream for nginx, which I have been using successfully with normal verdaccio for a long time.

Am I forgetting a configuration option or is this an actual bug?

error: must have required permissions: at package-name

Error case

Publishing with the following command will result in an error.

$ npm publish --registry http://x.x.x.x:4873
npm notice
npm notice package: [email protected]
npm notice === Tarball Contents ===
npm notice 391B package.json
npm notice === Tarball Details ===
npm notice name:          verdaccio-test
npm notice version:       1.0.0
npm notice package size:  327 B
npm notice unpacked size: 391 B
npm notice shasum:        743fdeb588e7f189185a3f9a9781376eb93ea2c3
npm notice integrity:     sha512-Ybd/QdLjDdQwO[...]MemC8wGvNKjNA==
npm notice total files:   1
npm notice
npm ERR! publish Failed PUT 403
npm ERR! code E403
npm ERR! must have required permissions:  at package-name : verdaccio-test

npm ERR! A complete log of this run can be found in:

package.json

{
  "name": "verdaccio-test",
  "version": "1.0.0",
  "description": "",
  //...
}

verdaccio server log

 info <-- x.x.x.x requested 'PUT /verdaccio-test'
 trace--- [gitlab] authenticate called for user: leesanghak
 debug--- [gitlab] user: gm1702846 found in cache, authenticated with groups: { publish:
   [ 'leesanghak',
     'cloud',
     'Yokan-Study',
     'leesanghak/verdaccio-test',
     'Yokan-Study/nightwatch',
     ... // SKIP ] }

Success case

Based on the contents of publish, I thought that the package name should be included in the publish group.

  • leesanghak (gitlab username)
  • cloud (gitlab group name)
  • Yokan-Study (gitlab group name)

package.json

{
  "name": "leesanghak",
  "version": "1.0.0",
  "description": "",
  //...
}

Conclusion

However, what I want is to publish verdaccio-test(leesanghak/verdaccio-test), not leesanghak.

verdaccio-test seems to be getting an error because it belongs to a subgroup of my gitlab account leesanghak, how can I fix this?

Questions before contributing

I'd like to add some features on this package, but I have some questions before contributing.

  1. Could you explain why we initialize a global tunnel in src/verdaccio.js?

  2. I see despite the fact we use verdaccio 3.x in package.json dependencies, we build docker image using 4.x-next base verdaccio docker image. Could this cause instability because we build a plugin for an older version of verdaccio than the one used in the base docker image?

Uppercase authentication issue

It seems you check the username in the login with case sensitivity

NPM CLI ask you to login with a lowercase username
Gitlab doesn't allow you to have the same username with a different case

So if you have an username with an uppercase, you can login in the Web UI but not in the CLI.

Question: Should scope checking be case insensitive ?

Currently scope checking is case sensitive in verdaccio.js

I usually create project and group in gitlab with an uppercase, gitlab by default create the url with the same casing.

Since lowercase URL are redirected, and group creation checks are not case sensitive (so for GroupA, I can't create groupa), we could maybe check the group and scope name as lowercase ?

Allow project maintainers to publish

If I am a maintainer of a project but I am not the maintainer of the parent group. I should still have publish rights for npm packages that match the project name.

error authenticating user

I am using our company's private Gitlab server for authentication and getting this error: error querying gitlab user data: Cannot read property 'headers' of undefined. I tried to change the log level of verdaccio to trace to log more information but it does not help much. What could be the problem? The logs from the plugin are not giving me pertinent information.

Any help would be really apprciated.

P.S: It might be because of the self-signed SSL certificate of the server. I have checked the Gitlab REST API on the server with curl but I got this SSL certificate problem: unable to get local issuer certificate. I made it work passing -k.

node: v8.11.1
verdaccio: 4.0.1
verdaccio-gitlab: v2.2.0

Invalid projects URL prevent authentication

First off, thanks for verdaccio-gitlab it's been great to use!

I just migrated my gitlab from one server to another and moved verdaccio with it. At the same time I upgraded the version of both gitlab and verdaccio but I'm running into some issues now with the authentication.

Looking a bit into it I get this error from verdaccio

[2019-05-10 09:04:20]  info <-- 10.0.1.4 requested 'PUT /-/user/org.couchdb.user:simon-jouet'
[2019-05-10 09:04:20]  error--- [gitlab] user: simon-jouet error querying gitlab: StatusCodeError: 404 - {"error":"404 Not Found"}
[2019-05-10 09:04:20]  http <-- 401, user: null(62.30.156.32 via 10.0.1.4), req: 'PUT /-/user/org.couchdb.user:simon-jouet', error: error authenticating user
[2019-05-10 09:04:20]  http <-- 401, user: null(62.30.156.32 via 10.0.1.4), req: 'PUT /-/user/org.couchdb.user:simon-jouet', error: error authenticating user

and looking into gitlab API logs, I noticed that url called to get the projects is incorrect

10.0.3.4 - - [10/May/2019:09:04:20 +0000] "GET /api/v4/user HTTP/1.1" 200 810 "" "-"
10.0.3.4 - - [10/May/2019:09:04:20 +0000] "GET /api/v4/groups?min_access_level=40 HTTP/1.1" 200 563 "" "-"
10.0.3.4 - - [10/May/2019:09:04:20 +0000] "GET /api/v4/projects?min_access_level=40 HTTP/1.1" 200 39581 "" "-"
10.0.3.4 - - [10/May/2019:09:04:20 +0000] "GET /api/v4/https://<my_gitlab_url>/api/v4/projects?membership=false&min_access_level=40&order_by=created_at&owned=false&page=2&per_page=20&simple=false&sort=desc&starred=false&statistics=false&with_custom_attributes=false&with_issues_enabled=false&with_merge_requests_enabled=false HTTP/1.1" 404 25 "" "-"

In that you can see that the final call is /api/v4 but then the aboslute url to the gitlab project is used.

For the time being I reverted to the previous version of verdaccio-gitlab with image: bufferoverflow/verdaccio-gitlab@sha256:1a5c2e910cff98f2ab3c8030c868c8d2013274f0a0edaf83ba6a01270f5900ef and it seems to be working.

Authenticate is called for every package install

When a package is not scoped we don't need to call authenticate all the time. We DDOSed our private GitLab instance when anyone installed a lot of packages, because GitLab was requested several times even if the package asked for was not scoped and available on public npm.

Request pile up very quickly when installing express for example. It makes a request for every package used by express.

Whitelist specific group/project

Would it be possible to have a way to only allow specific group or projects (or both) so that nobody can publish his own package on my registry?

From what I understood, the current behavior is to allow any gitlab user to authenticate to my verdaccio using his gitlab credentials and then publish any package he owns. Meaning that a user finding my registry can use it to publish his own packages without me being able to prevent it.

Edit:

After a bit more tinkering, I noticed that the plugin reports the list of groupe the user belongs to.
For example, if I have access to a group named telokis-group, it shows it inside the logs.
What I expected given this information was to be able to use telokis-group as a authorization specification like so:

        access: telokis-group
        publish: telokis-group
        gitlab: true
        unpublish:

But it still says I don't have the required permissions to access the specified scope.

Is there a way to make this behavior work?

Kubernetes deployment issues

Hi,

(this isn't a follow up to #74 but quite a different question/issue)

So i've been trying to deploy verdaccio-gitlab in a kubernetes cluster that i'm setting for our next dev environment (migrating from docker swarm). I got most things working but i'm stumbling a bit on verdaccio-gitlab and was hoping to get some insights and maybe if i'm lucky some input from people who have a kubernetes deployments working properly.

I can get verdaccio to load properly, I can get the login to work but once I'm logged in I'm unable to fetch the packages. The issue is that once i'm logged in I get a ERR_CONNECTION_CLOSED/ERR_CONNECTION_RESET when fetching the packages

image

I've first tried to use the helm chart for verdaccio and simply change the the image to verdaccio-gitlab, this worked but I can't fetch the packages after login.

Expecting this to be possibly an issue with the helm chart, I've made my own deployment and also fetched the last copy from the repo to build a new image on top of verdaccio 4.0.0 beta10 instead of the beta3 version which is currently used for the latest tagged docker image. The symptoms are the same again.

Finally I've tried to simply deploy a verdaccio beta10 with just htpasswd and without the gitlab plugin and it looks to be working as it should. I might be missing obvious but I unfortunately can't see any errors in nginx ingress, gitlab or verdaccio


apiVersion: v1
kind: ConfigMap
metadata:
  name: verdaccio
  labels:
    app: verdaccio
data:
  config.yaml: |-
    storage: /verdaccio/storage/data

    plugins: /verdaccio/plugins

    listen:
      - 0.0.0.0:4873

    auth:
      gitlab:
        url: https://gitlab.my-gitlab-server.com
        authCache:
          enabled: true
          ttl: 300

    uplinks:
      npmjs:
        url: https://registry.npmjs.org/

    packages:
      '@*/*':
        # scoped packages
        access: $authenticated
        publish: $authenticated
        proxy: npmjs
        gitlab: true

      '**':
        access: $authenticated
        publish: $authenticated
        proxy: npmjs
        gitlab: true

    # Log level can be changed to info, http etc. for less verbose output
    logs:
      - {type: stdout, format: pretty-timestamped, level: debug}
---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: verdaccio
  name: verdaccio
spec:
  selector:
    matchLabels:
      app: verdaccio
  replicas: 1
  strategy:
    type: Recreate
    rollingUpdate: null
  template:
    metadata:
      labels:
        app: verdaccio
    spec:
      containers:
        - name: verdaccio
          image: simon-jouet/verdaccio-gitlab:latest # that's just a docker build of master
          imagePullPolicy: Never
          ports:
            - containerPort: 4873
              name: http
          livenessProbe:
            httpGet:
              path: /-/ping
              port: http
            initialDelaySeconds: 5
          readinessProbe:
            httpGet:
              path: /-/ping
              port: http
            initialDelaySeconds: 5
          volumeMounts:
            - mountPath: /verdaccio/storage
              name: storage
              readOnly: false
            - mountPath: /verdaccio/conf
              name: config
              readOnly: true
      volumes:
      - name: config
        configMap:
          name: verdaccio
      - name: storage
        persistentVolumeClaim:
          claimName: verdaccio
---
apiVersion: v1
kind: Service
metadata:
  name: verdaccio
  labels:
    app: verdaccio
spec:
  ports:
  - port: 4873
  selector:
    app: verdaccio
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: verdaccio
  labels:
    app: verdaccio
  annotations:
    certmanager.k8s.io/cluster-issuer: letsencrypt
spec:
  tls:
    - hosts:
      - https://gitlab.my-gitlab-server.com
      secretName: tls-verdaccio
  rules:
    - host: https://gitlab.my-gitlab-server.com
      http:
        paths:
        - backend:
            serviceName: verdaccio
            servicePort: 4873

Custom gitlab url

Currently Dockerfile doesn't provide a way to override gitlab url because it intended to be used with own gitlab instance running via docker-compose.yml.

I think it would be great if Dockerfile allow you to use verdaccio-gitlab plugin with remote gitlab instance

Empty auth leads to traceback

In gitlab CI we currently use _auth to pass credentials (username/auth token as base64). While some of the CI users were testing this they forgot to pass credentials which ultimately led to a http 500. This led to some confusion since the expected reply should likely be 400 not authenticated. Steps to reproduce:

$ export NPM_USERNAME="" && export NPM_TOKEN=""
$ npm config set @foo:registry=https://mysite.com/npm
$ export AUTH=$(echo "$NPM_USERNAME:$NPM_TOKEN" | base64)
$ npm config set //mysite.com/npm/:_auth=$AUTH
$ npm install --no-audit
info <-- 10.0.1.5 requested 'GET /@foo/bar/-/bar-1.0.0.tgz'
 error--- unexpected error: `token` (private-token) or `oauth_token` is mandatory
Error: `token` (private-token) or `oauth_token` is mandatory
    at new BaseModel (/opt/verdaccio-gitlab/node_modules/gitlab/dist/latest/infrastructure/BaseService.js:33:13)
    at new Groups (/opt/verdaccio-gitlab/node_modules/gitlab/dist/latest/services/Groups.js:10:1)
    at Bundle.Object.entries.forEach (/opt/verdaccio-gitlab/node_modules/gitlab/dist/latest/infrastructure/Bundler.js:13:22)
    at Array.forEach (<anonymous>)
    at new Bundle (/opt/verdaccio-gitlab/node_modules/gitlab/dist/latest/infrastructure/Bundler.js:12:32)
    at VerdaccioGitLab.authenticate (/opt/verdaccio-gitlab/build/gitlab.js:82:23)
    at next (/opt/verdaccio/build/lib/auth.js:94:14)
    at Auth.authenticate (/opt/verdaccio/build/lib/auth.js:122:7)
    at Auth._handleAESMiddleware (/opt/verdaccio/build/lib/auth.js:299:12)
    at /opt/verdaccio/build/lib/auth.js:258:14
    at Layer.handle [as handle_request] (/opt/verdaccio/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/opt/verdaccio/node_modules/express/lib/router/index.js:317:13)
    at /opt/verdaccio/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/opt/verdaccio/node_modules/express/lib/router/index.js:335:12)
    at next (/opt/verdaccio/node_modules/express/lib/router/index.js:275:10)
    at Function.handle (/opt/verdaccio/node_modules/express/lib/router/index.js:174:3)
    at router (/opt/verdaccio/node_modules/express/lib/router/index.js:47:12)
    at Layer.handle [as handle_request] (/opt/verdaccio/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/opt/verdaccio/node_modules/express/lib/router/index.js:317:13)
    at /opt/verdaccio/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/opt/verdaccio/node_modules/express/lib/router/index.js:335:12)
    at next (/opt/verdaccio/node_modules/express/lib/router/index.js:275:10)

Refactor Dockerfile

Currently, the Dockerfile in verdaccio-gitlab contains a lot of commonalities with verdaccio's Dockerfile.

I believe it would be nice to refactor the verdaccio-gitlab's Dockerfile to use verdaccio' as a base image and customize from there.

@bufferoverflow @dlouzan what do you think?

Logging in breaks subsequent requests w/ Authorization header

It seems that after logging in, if the authenticated GitLab user belongs to a lot of groups/projects, the JWT that is used in the Authorization header can get to a size large enough to cause net::ERR_CONNECTION_CLOSED errors.
Has anyone else run into this?

Inconsistent plugin handling of allow_access and allow_publish

We found in #54 that we are inconsistently returning different true & false values when successfully returning from allow_access and allow_publish. An undocumented feature on the verdaccio plugins handling code distinguishes these two cases, returning false allows to follow the chain of plugins and pass handling to the next plugin, while true allows to exit the chain successfully, short-circuiting further plugins.

Revisit this code and in principle return false on success for both allowing the chain to be executed, checking that there's no unintended side-effects or regressions with this behaviour.

As an extra task out of this issue, we could improve upstream verdaccio's plugin documentation.

Issues with header/personal token

Spent too much time debugging an issue today so I thought I'd share my findings. TBH not sure this is a bug in verdaccio-gitlab or in verdaccio itself, but this oneliner fixed it:

diff --git a/src/gitlab.js b/src/gitlab.js
index eb93b3e..a191482 100644
--- a/src/gitlab.js
+++ b/src/gitlab.js
@@ -98,7 +98,7 @@ export default class VerdaccioGitLab implements IPluginAuth {
 
     const GitlabAPI = new Gitlab({
       url: this.config.url,
-      token: password
+      token: password.trim()
     });
 
     GitlabAPI.Users.current().then(response => {

Steps to reproduce:

  1. use user/password-style or _auth authentication in your .npmrc:
@test:registry=http://localhost:4873/
//localhost:4873/:_auth=myBase64string
  1. attempt to install packages: npm i @test/foo

  2. you will now see something like:

$ cross-env BABEL_ENV=registry babel src/ --out-dir build/ --copy-files --ignore ___tests___ --source-maps
src/authcache.js -> build/authcache.js
src/gitlab.js -> build/gitlab.js
src/index.js -> build/index.js
src/verdaccio.js -> build/verdaccio.js
✨  Done in 1.69s.
 warn --- config file  - /Users/jbergstroem/.config/verdaccio/config.yaml
 info --- [gitlab] url: https://myhostedgitlabinstance.com
 info --- [gitlab] initialized auth cache with ttl: 300 seconds
 info --- [gitlab] publish control level: $maintainer
 warn --- Plugin successfully loaded: gitlab
 warn --- http address - http://0.0.0.0:4873/ - verdaccio/3.8.6
 info <-- 127.0.0.1 requested 'GET /@test%2ffoo'
 info --- basic authentication is deprecated, please use JWT instead
 trace--- [gitlab] authenticate called for user: jbergstroem
 trace--- [gitlab] user: jbergstroem not found in cache
 error--- [gitlab] user: jbergstroem error querying gitlab user data: TypeError [ERR_INVALID_CHAR]: Invalid character in header content ["private-token"]
 debug--- [gitlab] deny access to package: @ci-reuse/fastify-core
 http <-- 401, user: null(127.0.0.1), req: 'GET /@test%2ffoo, error: access denied, user not authenticated and anonymous access disabled
 http <-- 401, user: null(127.0.0.1), req: 'GET /@test%2ffoo', error: access denied, user not authenticated and anonymous access disabled

(note: I updated the gitlab library hence the slightly better debugging)

It appears that my personal access token gets a newline appended to it somehow.

  1. this is tested with both latest git head (which would install verdaccio 3.x) and the dockerfile (verdaccio 4.0.0 alpha)

Not able to publish even though I have access

Hi I am not able to publish a package when I have access according to the logs.

Related logs

debug--- [gitlab] user: bart.delange, with groups: { publish: [ 'bart.delange', 'group' ] }
debug--- [gitlab] user: bart.delange allowed to publish package: @group/package based on package-scope
http <-- 403, user: bart.delange, req: 'PUT /@group%2fpackage', error: user bart.delange is not allowed to publish package @group/package

Config

storage: /verdaccio/storage

plugins: /verdaccio/plugins/

listen:
  - 0.0.0.0:4873

auth:
  gitlab:
    url: https://gitlab.example.com
    publish: $developer

uplinks:
  npmjs:
    url: https://registry.npmjs.org/

middlewares:
  audit:
    enabled: true

packages:
  '@group/*':
    access: $reporter
    publish: $developer
    gitlab: true

  '**':
    access: $authenticated
    publish: $authenticated
    proxy: npmjs
    gitlab: false

web:
  enable: true
  title: NPM Registry
  scope:

logs:
  - {type: stdout, format: pretty, level: debug}

Uncaught SyntaxError: missing ) after argument list

Hi, I install this package using docker pull bufferoverflow/verdaccio-gitlab:latest and I got the image which is built 8 days ago. It seems that something is broken, the web page loaded in plain white. I have been using this package for months and this is the first time I updated it and not the web app is broken. Please help.

Screen Shot 2019-07-05 at 20 43 18

Plans to separate plugin behavior from full Verdaccio installation?

Appreciate your work here, a quick general question:

Based on your docker-compose.yml files and Dockerfile, it seems that this repository is primarily targeted at creating the full stack of services (GitLab, Verdaccio, GitLab Auth Plugin).

Do you have any plans to separate/isolate the plugin specific installation functionality at any point, or would it be better practices for consumers to implement a solution similar to the Dockerfile in verdaccio-ldap where yarn installs the package from npm during their custom image build process?

Question: how do i publish a package

Hi,

I have a group on gitlab.com and my verdaccio is configured but i got a access denied when trying to publish a package.

This is my configuration:

    packages:
      '@*/*':
        # scoped packages
        access: $authenticated
        publish: $authenticated
        proxy: npmjs
        gitlab: true

      '**':
        access: $authenticated
        publish: $authenticated
        proxy: npmjs
        gitlab: true

I successfully logged in with npm adduser --registry <url-here> after that i changed my package name to @GroupName/package-name but when i want to publish it to the registry i got a access denied. user username is not allowed to publish package @GroupName/package-name : @GroupName/package-name

Logs:

 debug--- [gitlab] user found in cache: username authenticated, with groups: username,GroupName
 debug--- [gitlab] user: username denied from publishing package: @GroupName/package-name

So the question is what do i wrong? or is this kind of a bug? also my group name is case sensitive maybe thats the problemen same of the username authentication?

Hope you guys have some ideas ;)

Self hosted gitlab

I just installed this on our self hosted gitlab instance and get 500s when I try to login.
Any help would be greatly appreciated

Authentication using SSH keys/tokens

My team uses ssh keys for pulling and pushing from gitlab.com, and I've made a docker integration that copies those from the user's .ssh folder to the docker environment, gets the private projects and moves on.

We are now experimenting with using verdaccio instead of git for som sub projects and components, and I have it working with PAT, but I can't have this in an automated way, unless we implement some standard for storing the user's name and token.

It would be nice for verdaccio gitlab to work with either SSH keys or deploy keys as an authentication method for this use case, I'm not sure if the gitlab.com infrastructure would allow such thing, but I think many users would appreciate it.

Web interface does not work

When activating the web interface, no static file can be found

log

 warn --- http address - verdaccio/2.7.3
 http <-- 200, user: , req: 'GET /', bytes: 0/642
 http <-- 304, user: , req: 'GET /', bytes: 0/0
 http <-- 404, user: u, req: 'GET /-/static/style.8410f14de467c42d2f6c14c7df197f3f.css', error: File not found
 http <-- 404, user:  req: 'GET /static/main.54a8238b472a2df05ec1.js', error: File not found

I am using the most recent version of verdaccio-gitlab on Debian 8 with npm v5.6.0 and node v9.5.0

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.