indraq_cli 1.9.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +1043 -1517
- package/cloud-api/.env +6 -0
- package/cloud-api/.env.example +14 -14
- package/cloud-api/README.md +145 -141
- package/cloud-api/package.json +29 -29
- package/cloud-api/sql/001_init.sql +8 -8
- package/cloud-api/sql/002_user_providers_and_project_resources.sql +40 -40
- package/cloud-api/sql/003_environment_infrastructure.sql +19 -19
- package/cloud-api/sql/004_managed_aws_credentials.sql +20 -20
- package/cloud-api/sql/005_project_members_and_resource_grants.sql +22 -22
- package/cloud-api/sql/006_catalog_identity_password_security.sql +96 -96
- package/cloud-api/sql/007_aws_access_key_rotation.sql +16 -16
- package/cloud-api/src/index.ts +1329 -1254
- package/cloud-api/tsconfig.json +18 -18
- package/dist/cli/help-content.d.ts.map +1 -1
- package/dist/cli/help-content.js +254 -251
- package/dist/cli/help-content.js.map +1 -1
- package/dist/modules/access/commands/access.command.d.ts +19 -0
- package/dist/modules/access/commands/access.command.d.ts.map +1 -1
- package/dist/modules/access/commands/access.command.js +57 -46
- package/dist/modules/access/commands/access.command.js.map +1 -1
- package/dist/modules/cloud/commands/cloud.command.d.ts.map +1 -1
- package/dist/modules/cloud/commands/cloud.command.js +18 -2
- package/dist/modules/cloud/commands/cloud.command.js.map +1 -1
- package/dist/modules/cloud/config/cloud-config.d.ts +1 -1
- package/dist/modules/cloud/config/cloud-config.js +1 -1
- package/dist/modules/cloud/services/cloud-jenkins.service.d.ts +13 -1
- package/dist/modules/cloud/services/cloud-jenkins.service.d.ts.map +1 -1
- package/dist/modules/cloud/services/cloud-jenkins.service.js +173 -77
- package/dist/modules/cloud/services/cloud-jenkins.service.js.map +1 -1
- package/dist/modules/cloud/services/managed-aws-credential.service.d.ts.map +1 -1
- package/dist/modules/cloud/services/managed-aws-credential.service.js +11 -4
- package/dist/modules/cloud/services/managed-aws-credential.service.js.map +1 -1
- package/dist/modules/jenkins/commands/admin.command.d.ts +3 -0
- package/dist/modules/jenkins/commands/admin.command.d.ts.map +1 -1
- package/dist/modules/jenkins/commands/admin.command.js +91 -1
- package/dist/modules/jenkins/commands/admin.command.js.map +1 -1
- package/dist/modules/jenkins/index.d.ts.map +1 -1
- package/dist/modules/jenkins/index.js +3 -0
- package/dist/modules/jenkins/index.js.map +1 -1
- package/dist/modules/scaffold/services/docker-template.service.js +95 -95
- package/dist/modules/users/commands/user.command.d.ts.map +1 -1
- package/dist/modules/users/commands/user.command.js +290 -44
- package/dist/modules/users/commands/user.command.js.map +1 -1
- package/dist/modules/users/providers/aws-user.provider.d.ts.map +1 -1
- package/dist/modules/users/providers/aws-user.provider.js +9 -2
- package/dist/modules/users/providers/aws-user.provider.js.map +1 -1
- package/dist/modules/users/providers/jenkins-user.provider.d.ts +11 -4
- package/dist/modules/users/providers/jenkins-user.provider.d.ts.map +1 -1
- package/dist/modules/users/providers/jenkins-user.provider.js +174 -72
- package/dist/modules/users/providers/jenkins-user.provider.js.map +1 -1
- package/dist/modules/users/providers/npm-user.provider.d.ts.map +1 -1
- package/dist/modules/users/providers/npm-user.provider.js +3 -1
- package/dist/modules/users/providers/npm-user.provider.js.map +1 -1
- package/dist/shared/config/config-files.js +7 -7
- package/docs/ARCHITECTURE.md +29 -29
- package/docs/CREATE-DEPLOYMENT-reference.groovy +1105 -1105
- package/package.json +77 -76
- package/templates/jenkins/CREATE-DEPLOYMENT.groovy +1105 -1105
- package/templates/jenkins/Jenkinsfile-Mobile-App +759 -759
- package/cloud-api/.dockerignore +0 -18
- package/cloud-api/Dockerfile +0 -19
- package/cloud-api/package-lock.json +0 -2250
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const
|
|
3
|
-
export
|
|
1
|
+
import type { IndraQRole } from '../../cloud/services/cloud-aws.service';
|
|
2
|
+
export declare const buildJenkinsUserScript: (operation: "create" | "update" | "delete", username: string, password?: string, roles?: string[], indraqRole?: IndraQRole) => string;
|
|
3
|
+
export type ManagedJenkinsProvider = 'jenkins-dev' | 'jenkins-prod';
|
|
4
|
+
export declare const configuredManagedJenkinsProviders: () => Promise<ManagedJenkinsProvider[]>;
|
|
5
|
+
export declare const createJenkinsUserForProvider: (provider: ManagedJenkinsProvider, username: string, password: string, indraqRole: IndraQRole, roles: string[]) => Promise<"created" | "reconciled">;
|
|
6
|
+
export declare const createJenkinsUser: (username: string, password: string, indraqRole: IndraQRole, roles: string[]) => Promise<void>;
|
|
7
|
+
export declare const updateJenkinsUserForProvider: (provider: ManagedJenkinsProvider, username: string, password: string | undefined, indraqRole: IndraQRole | undefined, roles: string[]) => Promise<void>;
|
|
8
|
+
export declare const updateJenkinsUser: (username: string, password: string | undefined, indraqRole: IndraQRole | undefined, roles: string[]) => Promise<void>;
|
|
9
|
+
export declare const deleteJenkinsUserForProvider: (provider: ManagedJenkinsProvider, username: string) => Promise<"deleted" | "already-absent">;
|
|
4
10
|
export declare const deleteJenkinsUser: (username: string) => Promise<void>;
|
|
5
|
-
export declare const
|
|
11
|
+
export declare const preflightJenkinsUserManagementForProvider: (provider: ManagedJenkinsProvider, roles?: string[]) => Promise<void>;
|
|
12
|
+
export declare const preflightJenkinsUserManagement: (roles?: string[]) => Promise<ManagedJenkinsProvider[]>;
|
|
6
13
|
//# sourceMappingURL=jenkins-user.provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jenkins-user.provider.d.ts","sourceRoot":"","sources":["../../../../src/modules/users/providers/jenkins-user.provider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"jenkins-user.provider.d.ts","sourceRoot":"","sources":["../../../../src/modules/users/providers/jenkins-user.provider.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AA0EzE,eAAO,MAAM,sBAAsB,GACjC,WAAW,QAAQ,GAAG,QAAQ,GAAG,QAAQ,EACzC,UA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M,EAAO,KAAG,OAAO,CAAC,sBAAsB,EAAE,CAK3G,CAAC"}
|
|
@@ -1,97 +1,199 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.preflightJenkinsUserManagement = exports.deleteJenkinsUser = exports.updateJenkinsUser = exports.createJenkinsUser = exports.buildJenkinsUserScript = void 0;
|
|
3
|
+
exports.preflightJenkinsUserManagement = exports.preflightJenkinsUserManagementForProvider = exports.deleteJenkinsUser = exports.deleteJenkinsUserForProvider = exports.updateJenkinsUser = exports.updateJenkinsUserForProvider = exports.createJenkinsUser = exports.createJenkinsUserForProvider = exports.configuredManagedJenkinsProviders = exports.buildJenkinsUserScript = void 0;
|
|
4
4
|
const cloud_jenkins_service_1 = require("../../cloud/services/cloud-jenkins.service");
|
|
5
5
|
const user_provider_service_1 = require("../../cloud/services/user-provider.service");
|
|
6
6
|
const literal = (value) => JSON.stringify(value);
|
|
7
7
|
const hash = (value) => Math.abs([...value].reduce((total, char) => ((total * 31) + char.charCodeAt(0)) | 0, 0));
|
|
8
|
-
const imports = `import hudson.security.HudsonPrivateSecurityRealm
|
|
9
|
-
import com.michelin.cio.hudson.plugins.rolestrategy.AuthorizationType
|
|
10
|
-
import com.michelin.cio.hudson.plugins.rolestrategy.PermissionEntry
|
|
11
|
-
import com.michelin.cio.hudson.plugins.rolestrategy.RoleBasedAuthorizationStrategy
|
|
12
|
-
import com.michelin.cio.hudson.plugins.rolestrategy.Role
|
|
13
|
-
import com.synopsys.arc.jenkins.plugins.rolestrategy.RoleType
|
|
14
|
-
import hudson.model.Item
|
|
15
|
-
import hudson.security.Permission
|
|
8
|
+
const imports = `import hudson.security.HudsonPrivateSecurityRealm
|
|
9
|
+
import com.michelin.cio.hudson.plugins.rolestrategy.AuthorizationType
|
|
10
|
+
import com.michelin.cio.hudson.plugins.rolestrategy.PermissionEntry
|
|
11
|
+
import com.michelin.cio.hudson.plugins.rolestrategy.RoleBasedAuthorizationStrategy
|
|
12
|
+
import com.michelin.cio.hudson.plugins.rolestrategy.Role
|
|
13
|
+
import com.synopsys.arc.jenkins.plugins.rolestrategy.RoleType
|
|
14
|
+
import hudson.model.Item
|
|
15
|
+
import hudson.security.Permission
|
|
16
16
|
import jenkins.model.Jenkins`;
|
|
17
|
-
const
|
|
18
|
-
def
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
itemMap
|
|
17
|
+
const clearManagedProjectRoles = (username) => `
|
|
18
|
+
def managedPrincipal = new PermissionEntry(AuthorizationType.USER, ${literal(username)})
|
|
19
|
+
def managedProjectMap = Jenkins.get().authorizationStrategy instanceof RoleBasedAuthorizationStrategy
|
|
20
|
+
? Jenkins.get().authorizationStrategy.getRoleMap(RoleType.Project)
|
|
21
|
+
: null
|
|
22
|
+
if (managedProjectMap != null) {
|
|
23
|
+
managedProjectMap.getRoles().keySet().toList().findAll { it.name.startsWith('indraq-') }.each { existingRole ->
|
|
24
|
+
managedProjectMap.unAssignRole(existingRole, managedPrincipal)
|
|
25
|
+
}
|
|
26
|
+
Jenkins.get().save()
|
|
27
|
+
}`;
|
|
28
|
+
const seedRole = (username) => `
|
|
29
|
+
def strategy = Jenkins.get().authorizationStrategy
|
|
30
|
+
if (!(strategy instanceof RoleBasedAuthorizationStrategy)) throw new IllegalStateException('Role Strategy plugin must be the active Jenkins authorization strategy')
|
|
31
|
+
def itemMap = strategy.getRoleMap(RoleType.Project)
|
|
32
|
+
def seedRole = itemMap.getRole('indraq-create-deployment')
|
|
33
|
+
if (seedRole == null) {
|
|
34
|
+
Set<Permission> seedPermissions = new HashSet<Permission>()
|
|
35
|
+
seedPermissions.add(Item.DISCOVER)
|
|
36
|
+
seedPermissions.add(Item.READ)
|
|
37
|
+
seedPermissions.add(Item.BUILD)
|
|
38
|
+
seedPermissions.add(Item.CANCEL)
|
|
39
|
+
seedRole = new Role('indraq-create-deployment', '^CREATE-DEPLOYMENT$', seedPermissions)
|
|
40
|
+
itemMap.addRole(seedRole)
|
|
41
|
+
}
|
|
42
|
+
itemMap.assignRole(seedRole, new PermissionEntry(AuthorizationType.USER, ${literal(username)}))
|
|
32
43
|
Jenkins.get().save()`;
|
|
33
|
-
const
|
|
34
|
-
if (role_${hash(role)} == null) throw new IllegalArgumentException('Unknown Jenkins global role: ' + ${literal(role)})
|
|
35
|
-
strategy.getRoleMap(RoleType.Global).assignRole(role_${hash(role)}, new PermissionEntry(AuthorizationType.USER, ${literal(username)}))`).join('\n')}
|
|
44
|
+
const additionalGlobalRolesBody = (username, roles) => roles.length ? `${roles.map((role) => `def role_${hash(role)} = strategy.getRoleMap(RoleType.Global).getRole(${literal(role)})
|
|
45
|
+
if (role_${hash(role)} == null) throw new IllegalArgumentException('Unknown Jenkins global role: ' + ${literal(role)})
|
|
46
|
+
strategy.getRoleMap(RoleType.Global).assignRole(role_${hash(role)}, new PermissionEntry(AuthorizationType.USER, ${literal(username)}))`).join('\n')}
|
|
36
47
|
Jenkins.get().save()` : '';
|
|
37
|
-
const
|
|
48
|
+
const managedGlobalRoleBody = (username, role, extraRoles) => {
|
|
49
|
+
const managedRole = `indraq-${role}`;
|
|
50
|
+
const permissions = role === 'user'
|
|
51
|
+
? `managedPermissions.add(Jenkins.READ)`
|
|
52
|
+
: `managedPermissions.add(Jenkins.ADMINISTER)`;
|
|
53
|
+
return `def strategy = Jenkins.get().authorizationStrategy
|
|
54
|
+
if (!(strategy instanceof RoleBasedAuthorizationStrategy)) throw new IllegalStateException('Role Strategy plugin is required for Jenkins role synchronization')
|
|
55
|
+
def globalMap = strategy.getRoleMap(RoleType.Global)
|
|
56
|
+
def principal = new PermissionEntry(AuthorizationType.USER, ${literal(username)})
|
|
57
|
+
// The unified IndraQ role is authoritative. Remove stale global roles first so
|
|
58
|
+
// a demoted manager/admin cannot keep an older elevated Jenkins assignment.
|
|
59
|
+
globalMap.getRoles().keySet().toList().each { existingRole -> globalMap.unAssignRole(existingRole, principal) }
|
|
60
|
+
def managedRole = globalMap.getRole(${literal(managedRole)})
|
|
61
|
+
if (managedRole == null) {
|
|
62
|
+
Set<Permission> managedPermissions = new HashSet<Permission>()
|
|
63
|
+
${permissions}
|
|
64
|
+
managedRole = new Role(${literal(managedRole)}, '.*', managedPermissions)
|
|
65
|
+
globalMap.addRole(managedRole)
|
|
66
|
+
}
|
|
67
|
+
globalMap.assignRole(managedRole, principal)
|
|
68
|
+
${extraRoles.map((extra) => `def extra_${hash(extra)} = globalMap.getRole(${literal(extra)})
|
|
69
|
+
if (extra_${hash(extra)} == null) throw new IllegalArgumentException('Unknown Jenkins global role: ' + ${literal(extra)})
|
|
70
|
+
globalMap.assignRole(extra_${hash(extra)}, principal)`).join('\n')}
|
|
71
|
+
Jenkins.get().save()`;
|
|
72
|
+
};
|
|
73
|
+
const buildJenkinsUserScript = (operation, username, password, roles = [], indraqRole) => {
|
|
38
74
|
if (operation === 'delete')
|
|
39
|
-
return `${imports}
|
|
40
|
-
def user = hudson.model.User.getById(${literal(username)}, false)
|
|
41
|
-
if (user == null)
|
|
42
|
-
def strategy = Jenkins.get().authorizationStrategy
|
|
43
|
-
if (strategy instanceof RoleBasedAuthorizationStrategy) {
|
|
44
|
-
def
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
75
|
+
return `${imports}
|
|
76
|
+
def user = hudson.model.User.getById(${literal(username)}, false)
|
|
77
|
+
if (user == null) { println 'already-absent'; return }
|
|
78
|
+
def strategy = Jenkins.get().authorizationStrategy
|
|
79
|
+
if (strategy instanceof RoleBasedAuthorizationStrategy) {
|
|
80
|
+
def principal = new PermissionEntry(AuthorizationType.USER, ${literal(username)})
|
|
81
|
+
[RoleType.Global, RoleType.Project].each { roleType ->
|
|
82
|
+
def roleMap = strategy.getRoleMap(roleType)
|
|
83
|
+
roleMap.getRoles().keySet().toList().each { role -> roleMap.unAssignRole(role, principal) }
|
|
84
|
+
}
|
|
85
|
+
Jenkins.get().save()
|
|
86
|
+
}
|
|
87
|
+
user.delete()
|
|
50
88
|
println 'deleted'`;
|
|
51
|
-
const roleSetup =
|
|
52
|
-
|
|
53
|
-
|
|
89
|
+
const roleSetup = indraqRole
|
|
90
|
+
? managedGlobalRoleBody(username, indraqRole, roles)
|
|
91
|
+
: roles.length
|
|
92
|
+
? `def strategy = Jenkins.get().authorizationStrategy
|
|
93
|
+
if (!(strategy instanceof RoleBasedAuthorizationStrategy)) throw new IllegalStateException('Role Strategy plugin is required for Jenkins role assignment')
|
|
94
|
+
${additionalGlobalRolesBody(username, roles)}`
|
|
95
|
+
: '';
|
|
54
96
|
if (operation === 'create')
|
|
55
|
-
return `${imports}
|
|
56
|
-
def realm = Jenkins.get().securityRealm
|
|
57
|
-
if (!(realm instanceof HudsonPrivateSecurityRealm)) throw new IllegalStateException('Jenkins must use its private security realm to create users')
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
${
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
97
|
+
return `${imports}
|
|
98
|
+
def realm = Jenkins.get().securityRealm
|
|
99
|
+
if (!(realm instanceof HudsonPrivateSecurityRealm)) throw new IllegalStateException('Jenkins must use its private security realm to create users')
|
|
100
|
+
def existing = hudson.model.User.getById(${literal(username)}, false)
|
|
101
|
+
def reconciled = existing != null
|
|
102
|
+
if (!reconciled) {
|
|
103
|
+
realm.createAccount(${literal(username)}, ${literal(password || '')})
|
|
104
|
+
} else {
|
|
105
|
+
// v2.0 creation is deliberately idempotent for identities left behind by an
|
|
106
|
+
// older CLI release. Reclaim the same username, rotate its password, and
|
|
107
|
+
// rebuild only IndraQ-managed role assignments instead of failing forever.
|
|
108
|
+
existing.addProperty(HudsonPrivateSecurityRealm.Details.fromPlainPassword(${literal(password || '')}))
|
|
109
|
+
existing.save()
|
|
110
|
+
}
|
|
111
|
+
${clearManagedProjectRoles(username)}
|
|
112
|
+
${seedRole(username)}
|
|
113
|
+
${roleSetup}
|
|
114
|
+
println reconciled ? 'reconciled' : 'created'`;
|
|
115
|
+
return `${imports}
|
|
116
|
+
def user = hudson.model.User.getById(${literal(username)}, false)
|
|
117
|
+
if (user == null) throw new IllegalStateException('Jenkins user not found')
|
|
118
|
+
${password ? `user.addProperty(HudsonPrivateSecurityRealm.Details.fromPlainPassword(${literal(password)})); user.save()` : ''}
|
|
119
|
+
${seedRole(username)}
|
|
120
|
+
${roleSetup}
|
|
69
121
|
println 'updated'`;
|
|
70
122
|
};
|
|
71
123
|
exports.buildJenkinsUserScript = buildJenkinsUserScript;
|
|
124
|
+
const configuredManagedJenkinsProviders = async () => {
|
|
125
|
+
const profiles = await (0, user_provider_service_1.listUserProviders)();
|
|
126
|
+
return ['jenkins-dev', 'jenkins-prod'].filter((provider) => profiles.some((profile) => profile.provider === provider && profile.has_secret));
|
|
127
|
+
};
|
|
128
|
+
exports.configuredManagedJenkinsProviders = configuredManagedJenkinsProviders;
|
|
129
|
+
const connectionFor = async (provider) => (0, cloud_jenkins_service_1.getCloudJenkins)(provider === 'jenkins-prod' ? 'prod' : 'dev', 'Manage Jenkins user from unified CLI');
|
|
72
130
|
const connection = async () => {
|
|
73
|
-
const providers = await (0,
|
|
74
|
-
const
|
|
75
|
-
|
|
131
|
+
const providers = await (0, exports.configuredManagedJenkinsProviders)();
|
|
132
|
+
const provider = providers.includes('jenkins-prod') ? 'jenkins-prod' : providers[0];
|
|
133
|
+
if (!provider)
|
|
134
|
+
throw new Error('No Jenkins user-management provider is configured. Configure jenkins-dev and/or jenkins-prod first.');
|
|
135
|
+
return connectionFor(provider);
|
|
136
|
+
};
|
|
137
|
+
const createJenkinsUserForProvider = async (provider, username, password, indraqRole, roles) => {
|
|
138
|
+
const output = await (0, cloud_jenkins_service_1.runCloudJenkinsGroovy)(await connectionFor(provider), (0, exports.buildJenkinsUserScript)('create', username, password, roles, indraqRole));
|
|
139
|
+
if (output.split(/\r?\n/).some((line) => line.trim() === 'reconciled'))
|
|
140
|
+
return 'reconciled';
|
|
141
|
+
if (output.split(/\r?\n/).some((line) => line.trim() === 'created'))
|
|
142
|
+
return 'created';
|
|
143
|
+
throw new Error(`${provider} did not confirm Jenkins user creation/reconciliation. Response: ${output.slice(-800) || '(empty response)'}`);
|
|
144
|
+
};
|
|
145
|
+
exports.createJenkinsUserForProvider = createJenkinsUserForProvider;
|
|
146
|
+
const createJenkinsUser = async (username, password, indraqRole, roles) => {
|
|
147
|
+
await (0, cloud_jenkins_service_1.runCloudJenkinsGroovy)(await connection(), (0, exports.buildJenkinsUserScript)('create', username, password, roles, indraqRole));
|
|
76
148
|
};
|
|
77
|
-
const createJenkinsUser = async (username, password, roles) => { await (0, cloud_jenkins_service_1.runCloudJenkinsGroovy)(await connection(), (0, exports.buildJenkinsUserScript)('create', username, password, roles)); };
|
|
78
149
|
exports.createJenkinsUser = createJenkinsUser;
|
|
79
|
-
const
|
|
150
|
+
const updateJenkinsUserForProvider = async (provider, username, password, indraqRole, roles) => {
|
|
151
|
+
await (0, cloud_jenkins_service_1.runCloudJenkinsGroovy)(await connectionFor(provider), (0, exports.buildJenkinsUserScript)('update', username, password, roles, indraqRole));
|
|
152
|
+
};
|
|
153
|
+
exports.updateJenkinsUserForProvider = updateJenkinsUserForProvider;
|
|
154
|
+
const updateJenkinsUser = async (username, password, indraqRole, roles) => {
|
|
155
|
+
await (0, cloud_jenkins_service_1.runCloudJenkinsGroovy)(await connection(), (0, exports.buildJenkinsUserScript)('update', username, password, roles, indraqRole));
|
|
156
|
+
};
|
|
80
157
|
exports.updateJenkinsUser = updateJenkinsUser;
|
|
81
|
-
const
|
|
158
|
+
const deleteJenkinsUserForProvider = async (provider, username) => {
|
|
159
|
+
const output = await (0, cloud_jenkins_service_1.runCloudJenkinsGroovy)(await connectionFor(provider), (0, exports.buildJenkinsUserScript)('delete', username));
|
|
160
|
+
return output.split(/\r?\n/).some((line) => line.trim() === 'already-absent') ? 'already-absent' : 'deleted';
|
|
161
|
+
};
|
|
162
|
+
exports.deleteJenkinsUserForProvider = deleteJenkinsUserForProvider;
|
|
163
|
+
const deleteJenkinsUser = async (username) => {
|
|
164
|
+
await (0, cloud_jenkins_service_1.runCloudJenkinsGroovy)(await connection(), (0, exports.buildJenkinsUserScript)('delete', username));
|
|
165
|
+
};
|
|
82
166
|
exports.deleteJenkinsUser = deleteJenkinsUser;
|
|
83
|
-
const
|
|
167
|
+
const preflightScript = (roles) => {
|
|
84
168
|
const roleCheck = roles.length ? `${roles.map((role) => `if (strategy.getRoleMap(RoleType.Global).getRole(${literal(role)}) == null) throw new IllegalArgumentException('Unknown Jenkins global role: ' + ${literal(role)})`).join('\n')}` : '';
|
|
85
|
-
|
|
86
|
-
def realm = Jenkins.get().securityRealm
|
|
87
|
-
if (!(realm instanceof HudsonPrivateSecurityRealm)) throw new IllegalStateException('Jenkins must use its private security realm to create users')
|
|
88
|
-
def strategy = Jenkins.get().authorizationStrategy
|
|
89
|
-
if (!(strategy instanceof RoleBasedAuthorizationStrategy)) throw new IllegalStateException('Role Strategy plugin must be the active Jenkins authorization strategy')
|
|
90
|
-
${roleCheck}
|
|
169
|
+
return `${imports}
|
|
170
|
+
def realm = Jenkins.get().securityRealm
|
|
171
|
+
if (!(realm instanceof HudsonPrivateSecurityRealm)) throw new IllegalStateException('Jenkins must use its private security realm to create users')
|
|
172
|
+
def strategy = Jenkins.get().authorizationStrategy
|
|
173
|
+
if (!(strategy instanceof RoleBasedAuthorizationStrategy)) throw new IllegalStateException('Role Strategy plugin must be the active Jenkins authorization strategy')
|
|
174
|
+
${roleCheck}
|
|
91
175
|
println 'indraq-user-management-ready'`;
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
176
|
+
};
|
|
177
|
+
const preflightJenkinsUserManagementForProvider = async (provider, roles = []) => {
|
|
178
|
+
let output = '';
|
|
179
|
+
try {
|
|
180
|
+
output = await (0, cloud_jenkins_service_1.runCloudJenkinsGroovy)(await connectionFor(provider), preflightScript(roles));
|
|
181
|
+
}
|
|
182
|
+
catch (error) {
|
|
183
|
+
throw new Error(`${provider} user-management preflight failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
184
|
+
}
|
|
185
|
+
if (!output.includes('indraq-user-management-ready')) {
|
|
186
|
+
throw new Error(`${provider} Groovy preflight did not confirm readiness. Jenkins returned: ${output.slice(-1200) || '(empty response)'}`);
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
exports.preflightJenkinsUserManagementForProvider = preflightJenkinsUserManagementForProvider;
|
|
190
|
+
const preflightJenkinsUserManagement = async (roles = []) => {
|
|
191
|
+
const providers = await (0, exports.configuredManagedJenkinsProviders)();
|
|
192
|
+
if (!providers.length)
|
|
193
|
+
throw new Error('No configured Jenkins controller was found. Configure jenkins-dev and/or jenkins-prod first.');
|
|
194
|
+
for (const provider of providers)
|
|
195
|
+
await (0, exports.preflightJenkinsUserManagementForProvider)(provider, roles);
|
|
196
|
+
return providers;
|
|
95
197
|
};
|
|
96
198
|
exports.preflightJenkinsUserManagement = preflightJenkinsUserManagement;
|
|
97
199
|
//# sourceMappingURL=jenkins-user.provider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jenkins-user.provider.js","sourceRoot":"","sources":["../../../../src/modules/users/providers/jenkins-user.provider.ts"],"names":[],"mappings":";;;AAAA,sFAAoG;AACpG,sFAA+E;
|
|
1
|
+
{"version":3,"file":"jenkins-user.provider.js","sourceRoot":"","sources":["../../../../src/modules/users/providers/jenkins-user.provider.ts"],"names":[],"mappings":";;;AAAA,sFAAoG;AACpG,sFAA+E;AAG/E,MAAM,OAAO,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AACjE,MAAM,IAAI,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC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EAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IACnG,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AALW,QAAA,8BAA8B,kCAKzC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"npm-user.provider.d.ts","sourceRoot":"","sources":["../../../../src/modules/users/providers/npm-user.provider.ts"],"names":[],"mappings":"AAsBA,eAAO,MAAM,oBAAoB,GAAU,UAAU,MAAM,EAAE,OAAO,MAAM,EAAE,UAAU,MAAM,EAAE,MAAM,MAAM,KAAG,OAAO,CAAC,IAAI,CAIxH,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAU,UAAU,MAAM,EAAE,OAAO,MAAM,GAAG,SAAS,EAAE,UAAU,MAAM,GAAG,SAAS,EAAE,MAAM,MAAM,GAAG,SAAS,KAAG,OAAO,CAAC,IAAI,CAO5J,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAU,UAAU,MAAM,KAAG,OAAO,CAAC,IAAI,
|
|
1
|
+
{"version":3,"file":"npm-user.provider.d.ts","sourceRoot":"","sources":["../../../../src/modules/users/providers/npm-user.provider.ts"],"names":[],"mappings":"AAsBA,eAAO,MAAM,oBAAoB,GAAU,UAAU,MAAM,EAAE,OAAO,MAAM,EAAE,UAAU,MAAM,EAAE,MAAM,MAAM,KAAG,OAAO,CAAC,IAAI,CAIxH,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAU,UAAU,MAAM,EAAE,OAAO,MAAM,GAAG,SAAS,EAAE,UAAU,MAAM,GAAG,SAAS,EAAE,MAAM,MAAM,GAAG,SAAS,KAAG,OAAO,CAAC,IAAI,CAO5J,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAU,UAAU,MAAM,KAAG,OAAO,CAAC,IAAI,CAKzE,CAAC"}
|
|
@@ -40,7 +40,9 @@ const updateNpmUnifiedUser = async (identity, email, password, role) => {
|
|
|
40
40
|
exports.updateNpmUnifiedUser = updateNpmUnifiedUser;
|
|
41
41
|
const deleteNpmUnifiedUser = async (identity) => {
|
|
42
42
|
const api = await (0, cloud_npm_service_1.createCloudNpmApi)('Delete Nginx Proxy Manager user');
|
|
43
|
-
const user = await
|
|
43
|
+
const user = (await api.listUsers()).find((item) => item.email.toLowerCase() === identity.toLowerCase() || item.nickname.toLowerCase() === identity.toLowerCase());
|
|
44
|
+
if (!user)
|
|
45
|
+
return; // idempotent delete: already absent is the desired state
|
|
44
46
|
await api.deleteUser(user.id);
|
|
45
47
|
};
|
|
46
48
|
exports.deleteNpmUnifiedUser = deleteNpmUnifiedUser;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"npm-user.provider.js","sourceRoot":"","sources":["../../../../src/modules/users/providers/npm-user.provider.ts"],"names":[],"mappings":";;;AACA,8EAA2E;AAE3E,MAAM,MAAM,GAAG,KAAK,EAAE,GAAkB,EAAE,QAAgB,EAAE,EAAE;IAC5D,MAAM,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,QAAQ,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC,QAAQ,CAAC,WAAW,EAAE,KAAK,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;IAC1J,IAAI,CAAC,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;IAClD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,8EAA8E;AAC9E,+EAA+E;AAC/E,uCAAuC;AACvC,MAAM,mBAAmB,GAAuB;IAC9C,UAAU,EAAE,MAAM;IAClB,WAAW,EAAE,QAAQ;IACrB,YAAY,EAAE,QAAQ;IACtB,YAAY,EAAE,MAAM;IACpB,iBAAiB,EAAE,QAAQ;IAC3B,UAAU,EAAE,QAAQ;IACpB,OAAO,EAAE,QAAQ;CAClB,CAAC;AAEK,MAAM,oBAAoB,GAAG,KAAK,E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AAE,EAAE,mBAAmB,CAAC,CAAC;AAC/F,CAAC,CAAC;AAPW,QAAA,oBAAoB,wBAO/B;AAEK,MAAM,oBAAoB,GAAG,KAAK,EAAE,QAAgB,EAAiB,EAAE;IAC5E,MAAM,GAAG,GAAG,MAAM,IAAA,qCAAiB,EAAC,iCAAiC,CAAC,CAAC;IACvE,MAAM,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,QAAQ,CAAC,WAAW,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,KAAK,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;IACnK,IAAI,CAAC,IAAI;QAAE,OAAO,CAAC,yDAAyD;IAC5E,MAAM,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAChC,CAAC,CAAC;AALW,QAAA,oBAAoB,wBAK/B"}
|
|
@@ -22,13 +22,13 @@ const ROOT_LOCAL_RULES = ['.indraq/jenkins.local.json', '.indraq/aws.local.json'
|
|
|
22
22
|
// This was generated by older IndraQ CLI releases. It ignored every file in
|
|
23
23
|
// .indraq/, which prevented safe project configuration from being shared.
|
|
24
24
|
const LEGACY_INNER_GITIGNORE = '*\n!.gitignore\n';
|
|
25
|
-
const LEGACY_ROOT_SHARED_BLOCK = `# IndraQ CLI shared project configuration
|
|
26
|
-
# These files are safe and intentionally shared with the project.
|
|
27
|
-
!.indraq/
|
|
28
|
-
!.indraq/.gitignore
|
|
29
|
-
!.indraq/jenkins.json
|
|
30
|
-
!.indraq/docker.json
|
|
31
|
-
!.indraq/mobile.json
|
|
25
|
+
const LEGACY_ROOT_SHARED_BLOCK = `# IndraQ CLI shared project configuration
|
|
26
|
+
# These files are safe and intentionally shared with the project.
|
|
27
|
+
!.indraq/
|
|
28
|
+
!.indraq/.gitignore
|
|
29
|
+
!.indraq/jenkins.json
|
|
30
|
+
!.indraq/docker.json
|
|
31
|
+
!.indraq/mobile.json
|
|
32
32
|
`;
|
|
33
33
|
const normaliseLines = (content) => content.replace(/\r\n/g, '\n').split('\n');
|
|
34
34
|
const hasExactRule = (lines, rule) => lines.some((line) => line.trim() === rule);
|
package/docs/ARCHITECTURE.md
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
# IndraQ Architecture
|
|
2
|
-
|
|
3
|
-
## Control plane
|
|
4
|
-
|
|
5
|
-
IndraQ CLI communicates with IndraQ Cloud API. PostgreSQL stores identities, roles, projects, shared environments, encrypted user provider credentials, infrastructure associations, managed AWS IAM credentials, and audit logs.
|
|
6
|
-
|
|
7
|
-
## Credential ownership
|
|
8
|
-
|
|
9
|
-
AWS, NPM, Jenkins, and GHCR credentials belong to an individual IndraQ user and are reusable across that user's projects.
|
|
10
|
-
|
|
11
|
-
They are not organization-wide global secrets and are not copied into each project folder.
|
|
12
|
-
|
|
13
|
-
## Shared environments
|
|
14
|
-
|
|
15
|
-
Admins can create any number of shared environments with arbitrary names. An environment is a reusable named target containing an IP and optional region. Health-check protocol, endpoint, port, path, interval, threshold, latency measurement, and SNI are Route53-resource settings selected when DNS is configured.
|
|
16
|
-
|
|
17
|
-
PRIMARY/SECONDARY is not an environment property. A FAILOVER DNS resource chooses which environment is PRIMARY and which is SECONDARY for that particular Route53 record.
|
|
18
|
-
|
|
19
|
-
## Project resources
|
|
20
|
-
|
|
21
|
-
Projects keep intent and external-resource associations, including GHCR image repositories, Jenkins jobs, Route53 routing/health checks, and NPM proxy hosts. Project membership controls who can discover/re-link a project. Resource grants record access to individual AWS, NPM, and Jenkins resources and are audited.
|
|
22
|
-
|
|
23
|
-
## Prebuild
|
|
24
|
-
|
|
25
|
-
Prebuild reconciles rather than blindly creates. It validates user provider configuration, checks existing project associations, asks for the Route53 routing policy first (SIMPLE, FAILOVER, WEIGHTED, or LATENCY), validates Jenkins host ports, configures/repairs Route53 according to that policy, verifies DNS before NPM, and creates/repairs NPM proxy hosts. SIMPLE records never receive a health check; FAILOVER uses PRIMARY/SECONDARY health checks; WEIGHTED/LATENCY may use health checks when requested.
|
|
26
|
-
|
|
27
|
-
## Local state
|
|
28
|
-
|
|
29
|
-
The project folder stores the Cloud project ID in `.indraq/project.json`. Reusable provider secrets are resolved from the authenticated user's Cloud account only when required.
|
|
1
|
+
# IndraQ Architecture
|
|
2
|
+
|
|
3
|
+
## Control plane
|
|
4
|
+
|
|
5
|
+
IndraQ CLI communicates with IndraQ Cloud API. PostgreSQL stores identities, roles, projects, shared environments, encrypted user provider credentials, infrastructure associations, managed AWS IAM credentials, and audit logs.
|
|
6
|
+
|
|
7
|
+
## Credential ownership
|
|
8
|
+
|
|
9
|
+
AWS, NPM, Jenkins, and GHCR credentials belong to an individual IndraQ user and are reusable across that user's projects.
|
|
10
|
+
|
|
11
|
+
They are not organization-wide global secrets and are not copied into each project folder.
|
|
12
|
+
|
|
13
|
+
## Shared environments
|
|
14
|
+
|
|
15
|
+
Admins can create any number of shared environments with arbitrary names. An environment is a reusable named target containing an IP and optional region. Health-check protocol, endpoint, port, path, interval, threshold, latency measurement, and SNI are Route53-resource settings selected when DNS is configured.
|
|
16
|
+
|
|
17
|
+
PRIMARY/SECONDARY is not an environment property. A FAILOVER DNS resource chooses which environment is PRIMARY and which is SECONDARY for that particular Route53 record.
|
|
18
|
+
|
|
19
|
+
## Project resources
|
|
20
|
+
|
|
21
|
+
Projects keep intent and external-resource associations, including GHCR image repositories, Jenkins jobs, Route53 routing/health checks, and NPM proxy hosts. Project membership controls who can discover/re-link a project. Resource grants record access to individual AWS, NPM, and Jenkins resources and are audited.
|
|
22
|
+
|
|
23
|
+
## Prebuild
|
|
24
|
+
|
|
25
|
+
Prebuild reconciles rather than blindly creates. It validates user provider configuration, checks existing project associations, asks for the Route53 routing policy first (SIMPLE, FAILOVER, WEIGHTED, or LATENCY), validates Jenkins host ports, configures/repairs Route53 according to that policy, verifies DNS before NPM, and creates/repairs NPM proxy hosts. SIMPLE records never receive a health check; FAILOVER uses PRIMARY/SECONDARY health checks; WEIGHTED/LATENCY may use health checks when requested.
|
|
26
|
+
|
|
27
|
+
## Local state
|
|
28
|
+
|
|
29
|
+
The project folder stores the Cloud project ID in `.indraq/project.json`. Reusable provider secrets are resolved from the authenticated user's Cloud account only when required.
|