Sinopia plugin for Gitlab authentication and package access/publish authorization.
This plugin allows authentication to Sinopia using a gitlab username and password. It also checks access levels
for users and projects before allowing access to project code (minimum level "Reporter") or publish access
(minimum level "Master").
Configuration
auth:
gitlab:
gitlab_server: https://git.example.comgitlab_admin_private_token: XXXXXXXXXXXX # (Recommended) You can use private token here#gitlab_admin_username: admin # or provide username and password#gitlab_admin_password: password123#gitlab_namespaces: [group, .....] # (Optional) Persistent gitlab group (Default empty => off)gitlab_use_scope_as_group: false # (Optional) Match scope as group (Default false)group/scope-projectgitlab_project_prefix: npm- # (Optional) Use this if you prefix your projects in gitlabgitlab_retain_group: false # (Optional) Use this to retain group name when perform project name conversion#gitlab_ca_file: /path/to/ca/ca.crt # (Optional) Use for self-signed certificatespackages:
'@*/*':
gitlab: true'scope-*':
gitlab: true'prefix-*':
gitlab: true'*':
allow_access: $authenticatedallow_publish: []proxy: npmjs
Test your configuration
// ImportvarSinopiaGitlab=require('sinopia-gitlab');// InitializevarsinopiaGitlab=SinopiaGitlab({// your configuration goes heregitlab_project_prefix: '',gitlab_use_scope_as_group: false,gitlab_namespaces: [],gitlab_retain_group: false},{// Set environment to test config_test_config: true});// Run testvarpackageName='@ns/scope-name';sinopiaGitlab._testConfig(packageName,function(err,result){// Check the conversion resultconsole.log(result);});
Package name to GitLab project name conversion
// This only show the process of conversion of one entry of gitlab_namespaces// package name is '@ns/scope-name'i=0if(gitlab_use_scope_as_group)namespace=gitlab_retain_group ? 'ns/scope' : 'scope'elsenamespace='ns'project=gitlab_project_prefix+'name'if(gitlab_namespaces[i])namespace=gitlab_retain_group ? namespace+'/'+gitlab_namespaces[i] : gitlab_namespaces[i]