Merge pull request #2555 from mei23/mei-0831-vali3

HTTP Signature ホスト検証エラーメッセージの調整
This commit is contained in:
syuilo 2018-08-31 18:07:08 +09:00 committed by GitHub
commit e89e76076a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -38,7 +38,7 @@ export default async (job: bq.Job, done: any): Promise<void> => {
try { try {
ValidateActivity(activity, host); ValidateActivity(activity, host);
} catch (e) { } catch (e) {
console.warn(e); console.warn(e.message);
done(); done();
return; return;
} }
@ -55,7 +55,7 @@ export default async (job: bq.Job, done: any): Promise<void> => {
try { try {
ValidateActivity(activity, host); ValidateActivity(activity, host);
} catch (e) { } catch (e) {
console.warn(e); console.warn(e.message);
done(); done();
return; return;
} }
@ -100,7 +100,10 @@ function ValidateActivity(activity: any, host: string) {
// id (if exists) // id (if exists)
if (typeof activity.id === 'string') { if (typeof activity.id === 'string') {
const uriHost = toUnicode(new URL(activity.id).hostname.toLowerCase()); const uriHost = toUnicode(new URL(activity.id).hostname.toLowerCase());
if (host !== uriHost) throw new Error('activity.id has different host'); if (host !== uriHost) {
const diag = activity.signature ? '. Has LD-Signature. Forwarded?' : '';
throw new Error(`activity.id(${activity.id}) has different host(${host})${diag}`);
}
} }
// actor (if exists) // actor (if exists)