From 031bbcd25d0e34668b429590d9c32a1be7b7d4e4 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 28 Jun 2022 15:32:57 +0200 Subject: Upgrade oauth2-server --- server/lib/auth/oauth-model.ts | 2 +- server/lib/auth/oauth.ts | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'server') diff --git a/server/lib/auth/oauth-model.ts b/server/lib/auth/oauth-model.ts index 910fdeec1..d9cf32827 100644 --- a/server/lib/auth/oauth-model.ts +++ b/server/lib/auth/oauth-model.ts @@ -1,5 +1,5 @@ import express from 'express' -import { AccessDeniedError } from 'oauth2-server' +import { AccessDeniedError } from '@node-oauth/oauth2-server' import { PluginManager } from '@server/lib/plugins/plugin-manager' import { ActorModel } from '@server/models/actor/actor' import { MOAuthClient } from '@server/types/models' diff --git a/server/lib/auth/oauth.ts b/server/lib/auth/oauth.ts index 2bf7a6361..fa1887315 100644 --- a/server/lib/auth/oauth.ts +++ b/server/lib/auth/oauth.ts @@ -1,5 +1,5 @@ import express from 'express' -import { +import OAuth2Server, { InvalidClientError, InvalidGrantError, InvalidRequestError, @@ -7,7 +7,7 @@ import { Response, UnauthorizedClientError, UnsupportedGrantTypeError -} from 'oauth2-server' +} from '@node-oauth/oauth2-server' import { randomBytesPromise } from '@server/helpers/core-utils' import { MOAuthClient } from '@server/types/models' import { sha1 } from '@shared/extra-utils' @@ -19,8 +19,7 @@ import { BypassLogin, getClient, getRefreshToken, getUser, revokeToken, saveToke * Reimplement some functions of OAuth2Server to inject external auth methods * */ - -const oAuthServer = new (require('oauth2-server'))({ +const oAuthServer = new OAuth2Server({ accessTokenLifetime: OAUTH_LIFETIME.ACCESS_TOKEN, refreshTokenLifetime: OAUTH_LIFETIME.REFRESH_TOKEN, -- cgit v1.2.3