86 lines
3.4 KiB
Plaintext
86 lines
3.4 KiB
Plaintext
${
|
|
[1].map(i => {
|
|
const type = `${fake.helpers.randomize(['kubernetes', 'jwt', 'oidc'])}`;
|
|
let sourceType;
|
|
|
|
if (type !== 'kubernetes') {
|
|
sourceType = `${fake.helpers.randomize(['JWTValidationPubKeys', 'JWKSURL', 'OIDCDiscoveryURL'])}`;
|
|
}
|
|
|
|
const claimMappings = {
|
|
"http://example.com/example-1": `${fake.hacker.noun()}`,
|
|
"http://example.com/example-2": `${fake.hacker.noun()}`
|
|
}
|
|
const listClaimMappings = {
|
|
"http://example.com/example-1": `${fake.hacker.noun()}`
|
|
}
|
|
|
|
let config = {};
|
|
switch(type) {
|
|
case 'kubernetes':
|
|
config = {
|
|
Host: `https://${fake.internet.ip()}:8443`,
|
|
CACert: `-----BEGIN CERTIFICATE-----${fake.internet.password(1357)}-----END CERTIFICATE-----`,
|
|
ServiceAccountJWT: `eyJhbGciOiJ${fake.internet.password(25)}.eyJ${fake.internet.password(61)}.${fake.internet.password(32)}`
|
|
};
|
|
break;
|
|
case 'oidc':
|
|
config = {
|
|
OIDCDiscoveryURL: `https://${fake.internet.ip()}:8443`,
|
|
OIDCDiscoveryCACert: `-----BEGIN CERTIFICATE-----${fake.internet.password(1357)}-----END CERTIFICATE-----`,
|
|
OIDCClientID: `${fake.hacker.noun()}-ID`,
|
|
OIDCClientSecret: `${fake.hacker.noun()}-secret`,
|
|
BoundAudiences: ["aud_example_0", "aud_example_1"],
|
|
OIDCScopes: ["scope_01", "scope_02", "scope_03"],
|
|
JWTSupportedAlgs: ["RS256", "RS257"],
|
|
VerboseOIDCLogging: true,
|
|
AllowedRedirectURIs: ["http://example.com/example-1", "http://example.com/example-2", "http://example.com/example-3"],
|
|
ClaimMappings: claimMappings,
|
|
ListClaimMappings: listClaimMappings
|
|
};
|
|
break;
|
|
case 'jwt':
|
|
config = {
|
|
JWTSupportedAlgs: ["RS256", "RS257"],
|
|
BoundAudiences: ["aud_example_0", "aud_example_1"],
|
|
BoundIssuer: `${fake.hacker.noun()}-issuer`,
|
|
ExpirationLeeway: `${fake.random.number({min: 0, max: 60})}`,
|
|
NotBeforeLeeway: `${fake.random.number({min: 0, max: 60})}`,
|
|
ClockSkewLeeway: `${fake.random.number({min: 0, max: 60})}`,
|
|
ClaimMappings: claimMappings,
|
|
ListClaimMappings: listClaimMappings
|
|
};
|
|
break;
|
|
}
|
|
|
|
switch(sourceType) {
|
|
case 'JWTValidationPubKeys':
|
|
config.JWTValidationPubKeys = `-----BEGIN CERTIFICATE-----${fake.internet.password(1357)}-----END CERTIFICATE-----`;
|
|
break;
|
|
case 'JWKSURL':
|
|
config.JWKSURL = `https://${fake.internet.ip()}:8443`;
|
|
config.JWKSCACert = `-----BEGIN CERTIFICATE-----${fake.internet.password(1357)}-----END CERTIFICATE-----`;
|
|
break;
|
|
case 'OIDCDiscoveryURL':
|
|
config.OIDCDiscoveryURL = `https://${fake.internet.ip()}:8443`;
|
|
break;
|
|
}
|
|
|
|
return `{
|
|
"Name": "${location.pathname.get(3)}",
|
|
"Namespace": "${
|
|
typeof location.search.ns !== 'undefined' ? location.search.ns :
|
|
typeof http.body.Namespace !== 'undefined' ? http.body.Namespace : 'default'
|
|
}",
|
|
"Type": "${type}",
|
|
"Description": "${fake.lorem.sentence()}",
|
|
"DisplayName": "${fake.hacker.noun()}",
|
|
"MaxTokenTTL": "${fake.random.number({min: 0, max: 60})}m${fake.random.number({min: 0, max: 60})}s",
|
|
"TokenLocality": "${fake.helpers.randomize(['local', 'global', ''])}",
|
|
"Config": ${JSON.stringify(config)},
|
|
"CreateIndex": ${fake.random.number()},
|
|
"ModifyIndex": 10
|
|
}`
|
|
})
|
|
}
|