948fef4adc
- vault_broker: always reconcile policy content before serving a cached token (compare-and-skip), so stale stored policies can't cause a recurring 403 'permission denied'; policy content is parsed live by OpenBao, so edits apply to existing tokens immediately. - Shared secrets: publish to secret/shared/<owner>/<slug>; grant read to users and apps by editing the grantee's policy content (live-applied). New SharedSecret/SharedSecretGrant ORM models, /api/shared-secrets router, and a Shared tab in the vault UI. - package.json + lockfile bumped to 1.21.0 to match the tag. Co-Authored-By: Claude <noreply@anthropic.com>
49 lines
1.6 KiB
JavaScript
49 lines
1.6 KiB
JavaScript
'use strict';
|
|
|
|
const conf = require('@simpleworkjs/conf');
|
|
const { setUpTable } = require('model-redis');
|
|
|
|
// Keep model-redis for the ones not yet ported
|
|
const Table = setUpTable(conf.redis);
|
|
module.exports = Table;
|
|
|
|
const { Token, AuthToken, InviteToken, ImpersonationToken, PasswordResetToken, OtpToken, ServiceToken } = require('./token');
|
|
require('./verification');
|
|
require('./oauth_code');
|
|
require('./api_token');
|
|
|
|
const { init } = require('@simpleworkjs/orm');
|
|
const { Resource, ResourceEdge, ResourceGroup } = require('./resource');
|
|
const { AccessRequest } = require('./access_request');
|
|
const { Webhook } = require('./webhook');
|
|
const { PluginInstance } = require('./plugin_instance');
|
|
const { SharedSecret } = require('./shared_secret');
|
|
const { SharedSecretGrant } = require('./shared_secret_grant');
|
|
async function initORM() {
|
|
const ormConf = conf.orm || {
|
|
dialect: 'sqlite',
|
|
storage: './config/inventory.sqlite',
|
|
logging: false
|
|
};
|
|
ormConf.redis = conf.redis;
|
|
|
|
console.log('[initORM] Starting ORM initialization...');
|
|
try {
|
|
await init({
|
|
conf: { orm: ormConf },
|
|
models: [
|
|
Resource, ResourceEdge, ResourceGroup, AccessRequest, Webhook, PluginInstance,
|
|
SharedSecret, SharedSecretGrant,
|
|
Token, AuthToken, InviteToken, ImpersonationToken, PasswordResetToken, OtpToken, ServiceToken
|
|
]
|
|
});
|
|
console.log('[initORM] ORM initialized successfully');
|
|
console.log('[initORM] Resource.orm =', !!Resource.orm, 'Token.orm =', !!Token.orm);
|
|
} catch (err) {
|
|
console.error('[initORM] ORM initialization failed:', err.message);
|
|
throw err;
|
|
}
|
|
}
|
|
|
|
module.exports.initORM = initORM;
|