mirror of
https://github.com/verdaccio/verdaccio.git
synced 2025-03-18 02:22:46 -05:00
chore: add sub type example with flow
This commit is contained in:
parent
2f4dbe8564
commit
b2e88d12a1
3 changed files with 38 additions and 4 deletions
|
@ -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",
|
||||
|
|
|
@ -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}, () => {});
|
|
@ -234,9 +234,9 @@
|
|||
version "1.0.0"
|
||||
resolved "https://registry.npmjs.org/@verdaccio/streams/-/streams-1.0.0.tgz#d5d24c6747208728b9fd16b908e3932c3fb1f864"
|
||||
|
||||
"@verdaccio/types@3.4.0":
|
||||
version "3.4.0"
|
||||
resolved "https://registry.npmjs.org/@verdaccio/types/-/types-3.4.0.tgz#3915f4b39a8e96e547e4d396bf406d7e32a454d9"
|
||||
"@verdaccio/types@3.4.1":
|
||||
version "3.4.1"
|
||||
resolved "https://registry.npmjs.org/@verdaccio/types/-/types-3.4.1.tgz#be18fb695bcd014c94c89b7805ace36dc9da2636"
|
||||
|
||||
"@webassemblyjs/ast@1.5.9":
|
||||
version "1.5.9"
|
||||
|
|
Loading…
Add table
Reference in a new issue