UNPKG

moleculer-iam

Version:

Centralized IAM module for moleculer. Including a certified OIDC provider and an Identity provider for user profile, credentials, and custom claims management. Custom claims could be defined/updated by declarative schema which contains claims validation a

50 lines (44 loc) 1.25 kB
"use strict"; const { STRING, JSON, DATE } = require("sequelize"); const OIDCModelNames = [ "Session", "AccessToken", "AuthorizationCode", "RefreshToken", "DeviceCode", "ClientCredentials", "Client", "InitialAccessToken", "RegistrationAccessToken", "Interaction", "ReplayDetection", "PushedAuthorizationRequest", ]; const OIDCGrantModelNames = [ "AccessToken", "AuthorizationCode", "RefreshToken", "DeviceCode", ]; module.exports = { up: async (queryInterface, Sequelize) => { for (const modelName of OIDCModelNames) { await queryInterface.createTable(modelName, { id: {type: STRING, primaryKey: true}, ...(OIDCGrantModelNames.includes(modelName) ? {grantId: {type: STRING}} : undefined), ...(modelName === "DeviceCode" ? {userCode: {type: STRING}} : undefined), ...(modelName === "Session" ? {uid: {type: STRING}} : undefined), data: {type: JSON}, createdAt: {type: DATE}, consumedAt: {type: DATE}, expiresAt: {type: DATE}, updatedAt: {type: DATE}, }); } }, down: async (queryInterface, Sequelize) => { for (const modelName of OIDCModelNames) { await queryInterface.dropTable(modelName); } }, };