manager-bh/server/kc.js

39 lines
921 B
JavaScript
Raw Permalink Normal View History

2024-11-04 18:47:17 +03:00
const Keycloak = require("keycloak-connect");
const keycloak = new Keycloak(
{},
{
clientId: "microfrontend-admin",
bearerOnly: true,
serverUrl: "https://kc.bro-js.ru",
realm: "bro-js",
}
);
const kcAdminClientPromise = import("@keycloak/keycloak-admin-client")
.then(
async ({ default: KcAdminClient }) =>
new KcAdminClient({
baseUrl: "https://kc.bro-js.ru",
realmName: "bro-js",
})
)
.then(async (kcAdminClient) => {
const credentials = {
username: process.env['KC.TUZ.USERNAME'],
password: process.env['KC.TUZ.PASSWORD'],
grant_type: "password",
grantType: "password",
clientId: "microfrontend-admin",
}
await kcAdminClient.auth(credentials);
setInterval(() => kcAdminClient.auth(credentials), 3 * 24 * 60 *60 * 1000);
return kcAdminClient;
});
module.exports = {
keycloak,
kcAdminClientPromise,
}