-
Notifications
You must be signed in to change notification settings - Fork 82
refactor: Validations for ecosystem details exist #1575
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f28c440
13cb21d
8d98969
fb99f72
17dc305
a27bc21
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -691,14 +691,13 @@ export async function createKeycloakUser(): Promise<void> { | |
| 'Missing required environment variables for either PLATFORM_ADMIN_USER_PASSWORD or KEYCLOAK_DOMAIN or KEYCLOAK_REALM or PLATFORM_ADMIN_KEYCLOAK_ID or PLATFORM_ADMIN_KEYCLOAK_SECRET or CRYPTO_PRIVATE_KEY' | ||
| ); | ||
| } | ||
| const decryptedPassword = CryptoJS.AES.decrypt(platformAdminData.password, CRYPTO_PRIVATE_KEY); | ||
| const token = await getKeycloakToken(); | ||
| const user = { | ||
| username: cachedConfig.platformEmail, | ||
| email: cachedConfig.platformEmail, | ||
| firstName: cachedConfig.platformName, | ||
| lastName: cachedConfig.platformName, | ||
| password: decryptedPassword.toString(CryptoJS.enc.Utf8) | ||
| password: 'Password@1' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove hardcoded Keycloak admin password immediately.
🔐 Proposed fix export async function createKeycloakUser(): Promise<void> {
logger.log(`✅ Creating keycloak user for platform admin`);
const { platformAdminData } = JSON.parse(configData);
- if (!platformAdminData?.password) {
- throw new Error('platformAdminData password is missing from credebl-master-table.json');
- }
if (!cachedConfig) {
throw new Error('failed to load platform config data from db');
}
const {
KEYCLOAK_DOMAIN,
KEYCLOAK_REALM,
PLATFORM_ADMIN_KEYCLOAK_ID,
PLATFORM_ADMIN_KEYCLOAK_SECRET,
- CRYPTO_PRIVATE_KEY
+ CRYPTO_PRIVATE_KEY,
+ PLATFORM_ADMIN_USER_PASSWORD
} = process.env;
if (
!KEYCLOAK_DOMAIN ||
!KEYCLOAK_REALM ||
!PLATFORM_ADMIN_KEYCLOAK_ID ||
!PLATFORM_ADMIN_KEYCLOAK_SECRET ||
- !CRYPTO_PRIVATE_KEY
+ !CRYPTO_PRIVATE_KEY ||
+ !PLATFORM_ADMIN_USER_PASSWORD
) {
throw new Error(
- 'Missing required environment variables for either PLATFORM_ADMIN_USER_PASSWORD or KEYCLOAK_DOMAIN or KEYCLOAK_REALM or PLATFORM_ADMIN_KEYCLOAK_ID or PLATFORM_ADMIN_KEYCLOAK_SECRET or CRYPTO_PRIVATE_KEY'
+ 'Missing required environment variables for PLATFORM_ADMIN_USER_PASSWORD, KEYCLOAK_DOMAIN, KEYCLOAK_REALM, PLATFORM_ADMIN_KEYCLOAK_ID, PLATFORM_ADMIN_KEYCLOAK_SECRET, or CRYPTO_PRIVATE_KEY'
);
}
const token = await getKeycloakToken();
const user = {
username: cachedConfig.platformEmail,
email: cachedConfig.platformEmail,
firstName: cachedConfig.platformName,
lastName: cachedConfig.platformName,
- password: 'Password@1'
+ password: PLATFORM_ADMIN_USER_PASSWORD
};Based on learnings: seed data keeps sensitive fields empty and populates them from 🤖 Prompt for AI Agents |
||
| }; | ||
| const res = await fetch(`${KEYCLOAK_DOMAIN}admin/realms/${KEYCLOAK_REALM}/users`, { | ||
| method: 'POST', | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Critical auth bypass in ecosystem path (
return trueignores required roles).After
hasAccesssucceeds, the guard returnstruewithout enforcingrequiredRoles. This lets any user with ecosystem membership pass endpoints that require stronger org roles, and it also treatslead/memberas equivalent.🔧 Suggested fix
🤖 Prompt for AI Agents