Skip to content

Commit

Permalink
Better permisson Fix misskey-dev#2341
Browse files Browse the repository at this point in the history
  • Loading branch information
tamaina committed Mar 30, 2019
1 parent 7987bb4 commit 10e81b7
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 53 deletions.
42 changes: 20 additions & 22 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -296,18 +296,25 @@ common:
ai-chan-kawaii: "藍ちゃかわいい"
you: "あなた"

permissions:
account-read: "アカウントの情報を見る"
account-write: "アカウントの情報を操作する"
drive-read: "ドライブを見る"
drive-write: "ドライブを操作する"
favorite-write: "お気に入りを操作する"
favorites-read: "お気に入りを見る"
following-read: "フォローの情報を見る"
following-write: "フォロー・フォロー解除する"
messaging-read: "トークを操作する"
messaging-write: "トークを操作する"
note-write: "投稿を作成・削除する"
notification-write: "通知を操作する"
reaction-write: "リアクションを操作する"
vote-write: "投票する"

auth/views/form.vue:
share-access: "<i>{name}</i>があなたのアカウントにアクセスすることを許可しますか?"
permission-ask: "このアプリは次の権限を要求しています:"
account-read: "アカウントの情報を見る。"
account-write: "アカウントの情報を操作する。"
note-write: "投稿する。"
like-write: "いいねしたりいいね解除する。"
following-write: "フォローしたりフォロー解除する。"
drive-read: "ドライブを見る。"
drive-write: "ドライブを操作する。"
notification-read: "通知を見る。"
notification-write: "通知を操作する。"
cancel: "キャンセル"
accept: "アクセスを許可"

Expand Down Expand Up @@ -1811,24 +1818,15 @@ dev/views/apps.vue:
app-missing: "アプリなし"

dev/views/new-app.vue:
new-app: "新しいアプリケーション"
new-app-info: "アプリケーションはAPIからでも作成できます。 (app/create)"
create-app: "アプリケーションの作成"
app-name: "アプリケーション名"
app-name-desc: "あなたのアプリの名称。"
app-name-ex: "ex) Misskey for iOS"
app-name-desc: "あなたのアプリの名称。 ex) Misskey for iOS"
app-overview: "アプリの概要"
app-desc: "あなたのアプリの簡単な説明や紹介。"
app-desc-ex: "ex) Misskey iOSクライアント。"
app-desc: "あなたのアプリの簡単な説明や紹介。 ex) Misskey iOSクライアント。"
callback-url: "コールバックURL (オプション)"
callback-url-desc: "ユーザーが認証フォームで認証した際にリダイレクトするURLを設定できます。"
authority: "権限"
authority-desc: "ここで要求した機能だけがAPIからアクセスできます。"
authority-warning: "アプリ作成後も変更できますが、新たな権限を付与する場合、その時点で関連付けられているユーザーキーはすべて無効になります。"
account-read: "アカウントの情報を見る。"
account-write: "アカウントの情報を操作する。"
note-write: "投稿する。"
reaction-write: "リアクションしたりリアクションをキャンセルする。"
following-write: "フォローしたりフォロー解除する。"
drive-read: "ドライブを見る。"
drive-write: "ドライブを操作する。"
notification-read: "通知を見る。"
notification-write: "通知を操作する。"
10 changes: 1 addition & 9 deletions src/client/app/auth/views/form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,7 @@
<h2>{{ $t('permission-ask') }}</h2>
<ul>
<template v-for="p in app.permission">
<li v-if="p == 'account-read'">{{ $t('account-read') }}</li>
<li v-if="p == 'account-write'">{{ $t('account-write') }}</li>
<li v-if="p == 'note-write'">{{ $t('note-write') }}</li>
<li v-if="p == 'like-write'">{{ $t('like-write') }}</li>
<li v-if="p == 'following-write'">{{ $t('following-write') }}</li>
<li v-if="p == 'drive-read'">{{ $t('drive-read') }}</li>
<li v-if="p == 'drive-write'">{{ $t('drive-write') }}</li>
<li v-if="p == 'notification-read'">{{ $t('notification-read') }}</li>
<li v-if="p == 'notification-write'">{{ $t('notification-write') }}</li>
<li :key="p">{{ $t(`@.permissions.${p}`) }}</li>
</template>
</ul>
</section>
Expand Down
28 changes: 12 additions & 16 deletions src/client/app/dev/views/new-app.vue
Original file line number Diff line number Diff line change
@@ -1,29 +1,22 @@
<template>
<mk-ui>
<b-card :header="$t('header')">
<b-card :header="$t('new-app')">
<b-alert show variant="info"><fa icon="info-circle"/> {{ $t('new-app-info') }}</b-alert>
<b-form @submit.prevent="onSubmit" autocomplete="off">
<b-form-group :label="$t('app-name')" :description="$t('description')">
<b-form-group :label="$t('app-name')" :description="$t('app-name-desc')">
<b-form-input v-model="name" type="text" :placeholder="$t('placeholder')" autocomplete="off" required/>
</b-form-group>
<b-form-group :label="$t('app-overview')" :description="$t('description')">
<b-form-group :label="$t('app-overview')" :description="$t('app-overview-desc')">
<b-textarea v-model="description" :placeholder="$t('placeholder')" autocomplete="off" required></b-textarea>
</b-form-group>
<b-form-group :label="$t('callback-url')" :description="$t('description')">
<b-form-group :label="$t('callback-url')" :description="$t('callback-url-desc')">
<b-input v-model="cb" type="url" placeholder="ex) https://your.app.example.com/callback.php" autocomplete="off"/>
</b-form-group>
<b-card :header="$t('header')">
<b-form-group :description="$t('description')">
<b-card :header="$t('authority')">
<b-form-group :description="$t('authority-desc')">
<b-alert show variant="warning"><fa icon="exclamation-triangle"/> {{ $t('authority-warning') }}</b-alert>
<b-form-checkbox-group v-model="permission" stacked>
<b-form-checkbox value="account-read">{{ $t('account-read') }}</b-form-checkbox>
<b-form-checkbox value="account-write">{{ $t('account-write') }}</b-form-checkbox>
<b-form-checkbox value="note-write">{{ $t('note-write') }}</b-form-checkbox>
<b-form-checkbox value="reaction-write">{{ $t('reaction-write') }}</b-form-checkbox>
<b-form-checkbox value="following-write">{{ $t('following-write') }}</b-form-checkbox>
<b-form-checkbox value="drive-read">{{ $t('drive-read') }}</b-form-checkbox>
<b-form-checkbox value="drive-write">{{ $t('drive-write') }}</b-form-checkbox>
<b-form-checkbox value="notification-read">{{ $t('notification-read') }}</b-form-checkbox>
<b-form-checkbox value="notification-write">{{ $t('notification-write') }}</b-form-checkbox>
<b-form-checkbox v-for="(text, v) in permissionsList" :value="v" :key="v">{{ text }} ({{ v }})</b-form-checkbox>
</b-form-checkbox-group>
</b-form-group>
</b-card>
Expand All @@ -37,6 +30,8 @@
<script lang="ts">
import Vue from 'vue';
import i18n from '../../i18n';
import { locale } from '../../config';
export default Vue.extend({
i18n: i18n('dev/views/new-app.vue'),
data() {
Expand All @@ -45,7 +40,8 @@ export default Vue.extend({
description: '',
cb: '',
nidState: null,
permission: []
permission: [],
permissionsList: locale.common.permissions
};
},
methods: {
Expand Down
2 changes: 1 addition & 1 deletion src/server/api/endpoints/mute/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const meta = {

requireCredential: true,

kind: 'account/write',
kind: 'account-write',

params: {
userId: {
Expand Down
2 changes: 1 addition & 1 deletion src/server/api/endpoints/mute/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const meta = {

requireCredential: true,

kind: 'account/write',
kind: 'account-write',

params: {
userId: {
Expand Down
2 changes: 1 addition & 1 deletion src/server/api/endpoints/mute/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const meta = {

requireCredential: true,

kind: 'account/read',
kind: 'account-read',

params: {
limit: {
Expand Down
3 changes: 2 additions & 1 deletion src/server/api/openapi/description.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import config from '../../../config';

export const description = `
export const description = `**Misskey is a decentralized microblogging platform.**
## Usage
**APIはすべてPOSTでリクエスト/レスポンスともにJSON形式です。**
一部のAPIはリクエストに認証情報(APIキー)が必要です。リクエストの際に\`i\`というパラメータでAPIキーを添付してください。
Expand Down
19 changes: 17 additions & 2 deletions src/server/api/openapi/gen-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function genOpenapiSpec(lang = 'ja-JP') {
info: {
version: 'v1',
title: 'Misskey API',
description: '**Misskey is a decentralized microblogging platform.**\n\n' + description,
description,
'x-logo': { url: '/assets/api-doc.png' }
},

Expand Down Expand Up @@ -80,6 +80,8 @@ export function genOpenapiSpec(lang = 'ja-JP') {
};
}

const kinds = {} as { [x: string]: string[] };

for (const endpoint of endpoints.filter(ep => !ep.meta.secure)) {
const porops = {} as any;
const errors = {} as any;
Expand Down Expand Up @@ -110,7 +112,13 @@ export function genOpenapiSpec(lang = 'ja-JP') {

let desc = (endpoint.meta.desc ? endpoint.meta.desc[lang] : 'No description provided.') + '\n\n';
desc += `**Credential required**: *${endpoint.meta.requireCredential ? 'Yes' : 'No'}*`;
if (endpoint.meta.kind) desc += ` / **Permission**: *${endpoint.meta.kind}*`;
if (endpoint.meta.kind) {
const kind = endpoint.meta.kind;
desc += ` / **Permission**: *${kind}*`;

if (kind in kinds) kinds[kind].push(endpoint.name);
else kinds[kind] = [endpoint.name];
}

const info = {
operationId: endpoint.name,
Expand Down Expand Up @@ -231,5 +239,12 @@ export function genOpenapiSpec(lang = 'ja-JP') {
};
}

spec.info.description += `## Permissions\n|Permisson (kind)|Endpoints|\n|:--|:--|\n${
Object.entries(kinds)
.sort((a, b) => a[0] > b[0] ? 1 : -1)
.map(e => `|${e[0]}|${e[1].map(f => `[${f}](#operation/${f})`).join(', ')}|`)
.join('\n')
}\n`;

return spec;
}

0 comments on commit 10e81b7

Please sign in to comment.