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:
parent
2f4dbe8564
commit
b2e88d12a1
3 changed files with 35 additions and 1 deletions
|
@ -52,7 +52,7 @@
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@commitlint/cli": "6.1.3",
|
"@commitlint/cli": "6.1.3",
|
||||||
"@commitlint/config-conventional": "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-cli": "6.26.0",
|
||||||
"babel-core": "6.26.0",
|
"babel-core": "6.26.0",
|
||||||
"babel-eslint": "8.2.2",
|
"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({
|
const config1: AppConfig = new Config({
|
||||||
storage: './storage',
|
storage: './storage',
|
||||||
self_path: '/home/sotrage'
|
self_path: '/home/sotrage'
|
||||||
|
@ -51,6 +81,7 @@ const options: PluginOptions = {
|
||||||
}
|
}
|
||||||
|
|
||||||
const auth = new ExampleAuthPlugin(config1, options);
|
const auth = new ExampleAuthPlugin(config1, options);
|
||||||
|
const authSub = new ExampleAuthCustomPlugin(config1, options);
|
||||||
const remoteUser: RemoteUser = {
|
const remoteUser: RemoteUser = {
|
||||||
groups: [],
|
groups: [],
|
||||||
real_groups: [],
|
real_groups: [],
|
||||||
|
@ -60,3 +91,6 @@ const remoteUser: RemoteUser = {
|
||||||
auth.authenticate('user', 'pass', () => {});
|
auth.authenticate('user', 'pass', () => {});
|
||||||
auth.allow_access(remoteUser, {}, () => {});
|
auth.allow_access(remoteUser, {}, () => {});
|
||||||
auth.allow_publish(remoteUser, {}, () => {});
|
auth.allow_publish(remoteUser, {}, () => {});
|
||||||
|
authSub.authenticate('user', 'pass', () => {});
|
||||||
|
authSub.allow_access(remoteUser, {sub: true}, () => {});
|
||||||
|
authSub.allow_publish(remoteUser, {sub: true}, () => {});
|
BIN
yarn.lock
BIN
yarn.lock
Binary file not shown.
Loading…
Reference in a new issue