chore: Plugin registration (#6623)
* first pass * test * test * priority * Reduce boilerplate further * Update server/utils/PluginManager.ts Co-authored-by: Apoorv Mishra <apoorvmishra101092@gmail.com> * fix: matchesNode error in destroyed editor transaction * fix: Individual imported files do not display source correctly in 'Insights' * chore: Add sleep before Slack notification * docs * fix: Error logged about missing plugin.json * Remove email template glob --------- Co-authored-by: Apoorv Mishra <apoorvmishra101092@gmail.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"id": "oidc",
|
||||
"name": "OIDC",
|
||||
"description": "Adds an OpenID compatible authentication provider.",
|
||||
"requiredEnvVars": ["OIDC_CLIENT_ID", "OIDC_CLIENT_SECRET", "OIDC_AUTH_URI", "OIDC_TOKEN_URI", "OIDC_USERINFO_URI"]
|
||||
"priority": 30,
|
||||
"description": "Adds an OpenID compatible authentication provider."
|
||||
}
|
||||
|
||||
@@ -18,10 +18,10 @@ import {
|
||||
getTeamFromContext,
|
||||
getClientFromContext,
|
||||
} from "@server/utils/passport";
|
||||
import config from "../../plugin.json";
|
||||
import env from "../env";
|
||||
|
||||
const router = new Router();
|
||||
const providerName = "oidc";
|
||||
const scopes = env.OIDC_SCOPES.split(" ");
|
||||
|
||||
Strategy.prototype.userProfile = async function (accessToken, done) {
|
||||
@@ -55,14 +55,14 @@ if (
|
||||
env.OIDC_USERINFO_URI
|
||||
) {
|
||||
passport.use(
|
||||
providerName,
|
||||
config.id,
|
||||
new Strategy(
|
||||
{
|
||||
authorizationURL: env.OIDC_AUTH_URI,
|
||||
tokenURL: env.OIDC_TOKEN_URI,
|
||||
clientID: env.OIDC_CLIENT_ID,
|
||||
clientSecret: env.OIDC_CLIENT_SECRET,
|
||||
callbackURL: `${env.URL}/auth/${providerName}.callback`,
|
||||
callbackURL: `${env.URL}/auth/${config.id}.callback`,
|
||||
passReqToCallback: true,
|
||||
scope: env.OIDC_SCOPES,
|
||||
// @ts-expect-error custom state store
|
||||
@@ -134,7 +134,7 @@ if (
|
||||
avatarUrl: profile.picture,
|
||||
},
|
||||
authenticationProvider: {
|
||||
name: providerName,
|
||||
name: config.id,
|
||||
providerId: domain,
|
||||
},
|
||||
authentication: {
|
||||
@@ -153,11 +153,8 @@ if (
|
||||
)
|
||||
);
|
||||
|
||||
router.get(providerName, passport.authenticate(providerName));
|
||||
|
||||
router.get(`${providerName}.callback`, passportMiddleware(providerName));
|
||||
router.get(config.id, passport.authenticate(config.id));
|
||||
router.get(`${config.id}.callback`, passportMiddleware(config.id));
|
||||
}
|
||||
|
||||
export const name = env.OIDC_DISPLAY_NAME;
|
||||
|
||||
export default router;
|
||||
|
||||
16
plugins/oidc/server/index.ts
Normal file
16
plugins/oidc/server/index.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { PluginManager, PluginType } from "@server/utils/PluginManager";
|
||||
import config from "../plugin.json";
|
||||
import router from "./auth/oidc";
|
||||
import env from "./env";
|
||||
|
||||
PluginManager.register(PluginType.AuthProvider, router, {
|
||||
...config,
|
||||
name: env.OIDC_DISPLAY_NAME || config.name,
|
||||
enabled: !!(
|
||||
env.OIDC_CLIENT_ID &&
|
||||
env.OIDC_CLIENT_SECRET &&
|
||||
env.OIDC_AUTH_URI &&
|
||||
env.OIDC_TOKEN_URI &&
|
||||
env.OIDC_USERINFO_URI
|
||||
),
|
||||
});
|
||||
Reference in New Issue
Block a user