0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-16 21:56:25 -05:00

chore: add sub type example with flow

This commit is contained in:
Juan Picado @jotadeveloper 2018-07-16 20:50:29 +02:00
parent 2f4dbe8564
commit b2e88d12a1
No known key found for this signature in database
GPG key ID: 18AC54485952D158
3 changed files with 35 additions and 1 deletions

View file

@ -52,7 +52,7 @@
"devDependencies": {
"@commitlint/cli": "6.1.3",
"@commitlint/config-conventional": "6.1.3",
"@verdaccio/types": "3.4.0",
"@verdaccio/types": "3.4.1",
"babel-cli": "6.26.0",
"babel-core": "6.26.0",
"babel-eslint": "8.2.2",

View file

@ -40,6 +40,36 @@ class ExampleAuthPlugin implements IPluginAuth {
}
}
type SubTypePackageAccess = PackageAccess & {
sub?: boolean
}
class ExampleAuthCustomPlugin implements IPluginAuth {
config: AppConfig;
logger: Logger;
constructor(config: AppConfig, options: PluginOptions) {
this.config = config;
this.logger = options.logger;
}
adduser(user: string, password: string, cb: verdaccio$Callback): void {
cb();
}
authenticate(user: string, password: string, cb: verdaccio$Callback): void {
cb();
}
allow_access(user: RemoteUser, pkg: SubTypePackageAccess, cb: verdaccio$Callback): void {
cb();
}
allow_publish(user: RemoteUser, pkg: SubTypePackageAccess, cb: verdaccio$Callback): void {
cb();
}
}
const config1: AppConfig = new Config({
storage: './storage',
self_path: '/home/sotrage'
@ -51,6 +81,7 @@ const options: PluginOptions = {
}
const auth = new ExampleAuthPlugin(config1, options);
const authSub = new ExampleAuthCustomPlugin(config1, options);
const remoteUser: RemoteUser = {
groups: [],
real_groups: [],
@ -60,3 +91,6 @@ const remoteUser: RemoteUser = {
auth.authenticate('user', 'pass', () => {});
auth.allow_access(remoteUser, {}, () => {});
auth.allow_publish(remoteUser, {}, () => {});
authSub.authenticate('user', 'pass', () => {});
authSub.allow_access(remoteUser, {sub: true}, () => {});
authSub.allow_publish(remoteUser, {sub: true}, () => {});

BIN
yarn.lock

Binary file not shown.