feat: registerAuthWhitelist 强制增加插件名前缀

避免越权申请白名单的问题(表面防止)
pull/64/head
moonrailgun 3 years ago
parent 8e4908fced
commit 56387371ab

@ -285,15 +285,15 @@ export abstract class TcService extends Service {
/** /**
* token * token
* @param urls * @param urls serviceName
* @example "/user/login" * @example "/login"
*/ */
registerAuthWhitelist(urls: string[]) { registerAuthWhitelist(urls: string[]) {
this.waitForServices('gateway').then(() => { this.waitForServices('gateway').then(() => {
this.broker.broadcast( this.broker.broadcast(
'gateway.auth.addWhitelists', 'gateway.auth.addWhitelists',
{ {
urls, urls: urls.map((url) => `/${this.serviceName}${url}`),
}, },
'gateway' 'gateway'
); );

@ -48,9 +48,7 @@ class GithubSubscribeService extends TcService {
}); });
this.registerAction('webhook.callback', this.webhookHandler); this.registerAction('webhook.callback', this.webhookHandler);
this.registerAuthWhitelist([ this.registerAuthWhitelist(['/webhook/callback']);
'/plugin:com.msgbyte.github.subscribe/webhook/callback',
]);
} }
protected onInited(): void { protected onInited(): void {

@ -68,7 +68,7 @@ class PrettyinviteService extends TcService {
}, },
}); });
this.registerAuthWhitelist(['/plugin:com.msgbyte.prettyinvite/badge']); this.registerAuthWhitelist(['/badge']);
} }
async badge( async badge(

@ -58,9 +58,7 @@ class SimpleNotifyService extends TcService {
}, },
}); });
this.registerAuthWhitelist([ this.registerAuthWhitelist(['/webhook/callback']);
'/plugin:com.msgbyte.simplenotify/webhook/callback',
]);
} }
protected onInited(): void { protected onInited(): void {

@ -42,7 +42,7 @@ class ConfigService extends TcService {
}, },
}); });
this.registerAuthWhitelist(['/config/client']); this.registerAuthWhitelist(['/client']);
} }
/** /**

@ -201,7 +201,7 @@ class UserService extends TcService {
visibility: 'public', visibility: 'public',
}); });
this.registerAuthWhitelist(['/user/forgetPassword', '/user/resetPassword']); this.registerAuthWhitelist(['/forgetPassword', '/resetPassword']);
} }
/** /**

@ -24,7 +24,7 @@ class OpenBotService extends TcService {
visibility: 'public', visibility: 'public',
}); });
this.registerAuthWhitelist(['/openapi/bot/login']); this.registerAuthWhitelist(['/bot/login']);
} }
/** /**

Loading…
Cancel
Save