
* fix: fix improper authorization when accessing with third-party application
* refactor: refactor type definitions
* fix: get rid of unnecessary access limitation
* enhance: サードパーティアプリケーションがWebsocket APIを使えるように
* fix: add missing parentheses
* Revert "fix(backend): add missing kind definition for admin endpoints to improve security"
This reverts commit 5150053275
.
* frontend: 翻訳の抜けを訂正, read:adminとwrite:adminはアクセス発行トークンのデフォルトでは非表示にする
* enhance(test): misskey-ghsa-7pxq-6xx9-xpgmに関するテストを追加
* enhance(test): Websocket APIに対するテストも追加
* enhance(refactor): `@/misc/api-permissions.ts`を`misskey-js/permissions`に統合
* fix(frontend): アクセストークン発行UIで全ての権限を有効にした際、管理者用APIへのアクセスも許可してしまう問題を修正
* enhance(backend): Websocketの接続に最低限必要な権限を変更
* fix(backend): `/api/admin/meta`をサードパーティアプリケーションからはアクセスできないように
* fix(backend): エンドポイントにアクセスするために必要な権限を変更
* fix(frontend/locale): Add missing type declaration
* chore: update `misskey-js/src/autogen`
---------
Co-authored-by: tamaina <tamaina@hotmail.co.jp>
69 lines
1.5 KiB
TypeScript
69 lines
1.5 KiB
TypeScript
/*
|
|
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
import { Inject, Injectable } from '@nestjs/common';
|
|
import type { UserIpsRepository } from '@/models/_.js';
|
|
import { Endpoint } from '@/server/api/endpoint-base.js';
|
|
import { DI } from '@/di-symbols.js';
|
|
import { IdService } from '@/core/IdService.js';
|
|
|
|
export const meta = {
|
|
tags: ['admin'],
|
|
|
|
requireCredential: true,
|
|
requireModerator: true,
|
|
kind: 'read:admin:user-ips',
|
|
res: {
|
|
type: 'array',
|
|
optional: false,
|
|
nullable: false,
|
|
items: {
|
|
type: 'object',
|
|
optional: false,
|
|
nullable: false,
|
|
properties: {
|
|
ip: { type: 'string' },
|
|
createdAt: {
|
|
type: 'string',
|
|
optional: false,
|
|
nullable: false,
|
|
format: 'date-time',
|
|
},
|
|
},
|
|
},
|
|
},
|
|
} as const;
|
|
|
|
export const paramDef = {
|
|
type: 'object',
|
|
properties: {
|
|
userId: { type: 'string', format: 'misskey:id' },
|
|
},
|
|
required: ['userId'],
|
|
} as const;
|
|
|
|
@Injectable()
|
|
export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-disable-line import/no-default-export
|
|
constructor(
|
|
@Inject(DI.userIpsRepository)
|
|
private userIpsRepository: UserIpsRepository,
|
|
|
|
private idService: IdService,
|
|
) {
|
|
super(meta, paramDef, async (ps, me) => {
|
|
const ips = await this.userIpsRepository.find({
|
|
where: { userId: ps.userId },
|
|
order: { id: 'DESC' },
|
|
take: 30,
|
|
});
|
|
|
|
return ips.map(x => ({
|
|
ip: x.ip,
|
|
createdAt: x.createdAt.toISOString(),
|
|
}));
|
|
});
|
|
}
|
|
}
|