mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-13 15:58:50 +00:00
Merge commit '7e98fa9b476fdaed235519f1d527eb956004ba0c' into glitch-soc/merge-upstream
This commit is contained in:
@@ -78,17 +78,6 @@ const parseJSON = (json, req) => {
|
||||
}
|
||||
};
|
||||
|
||||
const PUBLIC_CHANNELS = [
|
||||
'public',
|
||||
'public:media',
|
||||
'public:local',
|
||||
'public:local:media',
|
||||
'public:remote',
|
||||
'public:remote:media',
|
||||
'hashtag',
|
||||
'hashtag:local',
|
||||
];
|
||||
|
||||
// Used for priming the counters/gauges for the various metrics that are
|
||||
// per-channel
|
||||
const CHANNEL_NAMES = [
|
||||
@@ -97,7 +86,14 @@ const CHANNEL_NAMES = [
|
||||
'user:notification',
|
||||
'list',
|
||||
'direct',
|
||||
...PUBLIC_CHANNELS
|
||||
'public',
|
||||
'public:media',
|
||||
'public:local',
|
||||
'public:local:media',
|
||||
'public:remote',
|
||||
'public:remote:media',
|
||||
'hashtag',
|
||||
'hashtag:local',
|
||||
];
|
||||
|
||||
const startServer = async () => {
|
||||
@@ -355,7 +351,7 @@ const startServer = async () => {
|
||||
* @returns {Promise<ResolvedAccount>}
|
||||
*/
|
||||
const accountFromToken = async (token, req) => {
|
||||
const result = await pgPool.query('SELECT oauth_access_tokens.id, oauth_access_tokens.resource_owner_id, users.account_id, users.chosen_languages, oauth_access_tokens.scopes FROM oauth_access_tokens INNER JOIN users ON oauth_access_tokens.resource_owner_id = users.id WHERE oauth_access_tokens.token = $1 AND oauth_access_tokens.revoked_at IS NULL LIMIT 1', [token]);
|
||||
const result = await pgPool.query('SELECT oauth_access_tokens.id, oauth_access_tokens.resource_owner_id, users.account_id, users.chosen_languages, oauth_access_tokens.scopes FROM oauth_access_tokens INNER JOIN users ON oauth_access_tokens.resource_owner_id = users.id WHERE oauth_access_tokens.token = $1 AND oauth_access_tokens.revoked_at IS NULL AND users.disabled IS FALSE LIMIT 1', [token]);
|
||||
|
||||
if (result.rows.length === 0) {
|
||||
throw new AuthenticationError('Invalid access token');
|
||||
@@ -434,12 +430,6 @@ const startServer = async () => {
|
||||
const checkScopes = (req, logger, channelName) => new Promise((resolve, reject) => {
|
||||
logger.debug(`Checking OAuth scopes for ${channelName}`);
|
||||
|
||||
// When accessing public channels, no scopes are needed
|
||||
if (channelName && PUBLIC_CHANNELS.includes(channelName)) {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
// The `read` scope has the highest priority, if the token has it
|
||||
// then it can access all streams
|
||||
const requiredScopes = ['read'];
|
||||
|
||||
Reference in New Issue
Block a user