sinopia-gitlab-api-v4
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").
ALterado para suportar uma nova versão da API do gitlab
Configuration
auth:
gitlab:
gitlab_server: https://git.example.com/api/vX
gitlab_admin_private_token: XXXXXXXXXXXX
gitlab_use_scope_as_group: false
gitlab_project_prefix: npm-
gitlab_retain_group: false
packages:
'@*/*':
gitlab: true
'scope-*':
gitlab: true
'prefix-*':
gitlab: true
'*':
allow_access: $authenticated
allow_publish: []
proxy: npmjs
Test your configuration
var SinopiaGitlab = require('sinopia-gitlab');
var sinopiaGitlab = SinopiaGitlab({
gitlab_project_prefix: '',
gitlab_use_scope_as_group: false,
gitlab_namespaces: [],
gitlab_retain_group: false
}, {
_test_config: true
});
var packageName = '@ns/scope-name';
sinopiaGitlab._testConfig(packageName, function(err, result) {
console.log(result);
});
Package name to GitLab project name conversion
i = 0
if (gitlab_use_scope_as_group)
namespace = gitlab_retain_group ? 'ns/scope' : 'scope'
else
namespace = 'ns'
project = gitlab_project_prefix + 'name'
if (gitlab_namespaces[i])
namespace = gitlab_retain_group ? namespace + '/' + gitlab_namespaces[i] : gitlab_namespaces[i]
Configuration examples
Default:
gitlab_project_prefix: ''
gitlab_use_scope_as_group: false
gitlab_namespaces: []
gitlab_retain_group: false
NPM Project Name | GitLab Project Name |
---|
project-a | project-a |
@mysterious/project-b | mysterious/project-b |
Config 1: prefixed
gitlab_project_prefix: 'my-'
gitlab_use_scope_as_group: false
gitlab_namespaces: []
gitlab_retain_group: false
NPM Project Name | GitLab Project Name |
---|
project-a | my-project-a |
@mysterious/project-b | mysterious/my-project-b |
Config 2: use scope as group
gitlab_project_prefix: ''
gitlab_use_scope_as_group: true
gitlab_namespaces: []
gitlab_retain_group: false
NPM Project Name | GitLab Project Name |
---|
project-a | project/a |
@mysterious/project-b | project/b |
Config 3: namespace
gitlab_project_prefix: ''
gitlab_use_scope_as_group: false
gitlab_namespaces: [npm]
gitlab_retain_group: false
NPM Project Name | GitLab Project Name |
---|
project-a | npm/project-a |
@mysterious/project-b | npm/project-b |
Config 4: namespace, use scope as group, prefixed
gitlab_project_prefix: 'my-'
gitlab_use_scope_as_group: true
gitlab_namespaces: [npm]
gitlab_retain_group: false
NPM Project Name | GitLab Project Name |
---|
project-a | npm/my-a |
@mysterious/project-b | npm/my-b |
Config 5: retain group, namespace, prefixed
gitlab_project_prefix: 'my-'
gitlab_use_scope_as_group: false
gitlab_namespaces: [npm]
gitlab_retain_group: true
NPM Project Name | GitLab Project Name |
---|
project-a | npm/my-project-a |
@mysterious/project-b | npm/mysterious/my-project-b |
Config 6: retain group, use scope as group namespace, prefixed
gitlab_project_prefix: 'my-'
gitlab_use_scope_as_group: true
gitlab_namespaces: [npm]
gitlab_retain_group: true
NPM Project Name | GitLab Project Name |
---|
project-a | npm/project/my-a |
@mysterious/project-b | npm/mysterious/project/my-b |