forked from FoundKeyGang/FoundKey
server: use foundkey-js permissions definition
This commit is contained in:
parent
bf698987c3
commit
cc776a6b9b
5 changed files with 8 additions and 37 deletions
|
@ -1,29 +0,0 @@
|
|||
export const kinds = [
|
||||
'read:account',
|
||||
'write:account',
|
||||
'read:blocks',
|
||||
'write:blocks',
|
||||
'read:drive',
|
||||
'write:drive',
|
||||
'read:following',
|
||||
'write:following',
|
||||
'read:messaging',
|
||||
'write:messaging',
|
||||
'read:mutes',
|
||||
'write:mutes',
|
||||
'write:notes',
|
||||
'read:notifications',
|
||||
'write:notifications',
|
||||
'read:reactions',
|
||||
'write:reactions',
|
||||
'write:votes',
|
||||
'read:pages',
|
||||
'write:pages',
|
||||
'write:page-likes',
|
||||
'read:page-likes',
|
||||
'read:user-groups',
|
||||
'write:user-groups',
|
||||
'read:channels',
|
||||
'write:channels',
|
||||
];
|
||||
// IF YOU ADD KINDS(PERMISSIONS), YOU MUST ADD TRANSLATIONS (under _permissions).
|
|
@ -1,7 +1,7 @@
|
|||
import { permissions } from 'foundkey-js';
|
||||
import { Apps } from '@/models/index.js';
|
||||
import { genId } from '@/misc/gen-id.js';
|
||||
import { secureRndstr } from '@/misc/secure-rndstr.js';
|
||||
import { kinds } from '@/misc/api-permissions.js';
|
||||
import define from '@/server/api/define.js';
|
||||
|
||||
export const meta = {
|
||||
|
@ -26,7 +26,7 @@ export const paramDef = {
|
|||
uniqueItems: true,
|
||||
items: {
|
||||
type: 'string',
|
||||
enum: kinds,
|
||||
enum: permissions,
|
||||
},
|
||||
},
|
||||
callbackUrl: { type: 'string', nullable: true },
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import * as crypto from 'node:crypto';
|
||||
import { permissions } from 'foundkey-js';
|
||||
import { AuthSessions, AccessTokens, Apps } from '@/models/index.js';
|
||||
import { genId } from '@/misc/gen-id.js';
|
||||
import { secureRndstr } from '@/misc/secure-rndstr.js';
|
||||
import { kinds } from '@/misc/api-permissions.js';
|
||||
import define from '@/server/api/define.js';
|
||||
import { ApiError } from '@/server/api/error.js';
|
||||
|
||||
|
@ -28,7 +28,7 @@ export const paramDef = {
|
|||
uniqueItems: true,
|
||||
items: {
|
||||
type: 'string',
|
||||
enum: kinds,
|
||||
enum: permissions,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { permissions } from 'foundkey-js';
|
||||
import config from '@/config/index.js';
|
||||
import { kinds } from '@/misc/api-permissions.js';
|
||||
import { I18n } from '@/misc/i18n.js';
|
||||
import { errors as errorDefinitions } from '@/server/api/error.js';
|
||||
import { endpoints } from '@/server/api/endpoints.js';
|
||||
|
@ -44,7 +44,7 @@ export function genOpenapiSpec() {
|
|||
authorizationCode: {
|
||||
authorizationUrl: `${config.url}/auth`,
|
||||
tokenUrl: `${config.apiUrl}/auth/session/oauth`,
|
||||
scopes: kinds.reduce((acc, kind) => {
|
||||
scopes: permissions.reduce((acc, kind) => {
|
||||
acc[kind] = i18n.ts['_permissions'][kind];
|
||||
return acc;
|
||||
}, {}),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { kinds } from '@/misc/api-permissions.js';
|
||||
import { permissions } from 'foundkey-js';
|
||||
import config from '@/config/index.js';
|
||||
|
||||
// Since it cannot change while the server is running, we can serialize it once
|
||||
|
@ -7,7 +7,7 @@ export const oauthMeta = JSON.stringify({
|
|||
issuer: config.url,
|
||||
authorization_endpoint: `${config.url}/auth`,
|
||||
token_endpoint: `${config.apiUrl}/auth/session/oauth`,
|
||||
scopes_supported: kinds,
|
||||
scopes_supported: permissions,
|
||||
response_types_supported: ['code'],
|
||||
grant_types_supported: ['authorization_code'],
|
||||
token_endpoint_auth_methods_supported: ['client_secret_basic'],
|
||||
|
|
Loading…
Reference in a new issue