ffd16dfec6
* Top nav auth dropdown (#15055) * Basic dropdown styles * Some cleanup * delog * Default nomad hover state styles * Component separation-of-concerns and acceptance tests for auth dropdown * lintfix * [ui, sso] Handle token expiry 500s (#15073) * Handle error states generally * Dont direct, just redirect * no longer need explicit error on controller * Redirect on token-doesnt-exist * Forgot to import our time lib * Linting on _blank * Redirect tests * changelog * [ui, sso] warn user about pending token expiry (#15091) * Handle error states generally * Dont direct, just redirect * no longer need explicit error on controller * Linting on _blank * Custom notification actions and shift the template to within an else block * Lintfix * Make the closeAction optional * changelog * Add a mirage token that will always expire in 11 minutes * Test for token expiry with ember concurrency waiters * concurrency handling for earlier test, and button redirect test * [ui] if ACLs are disabled, remove the Sign In link from the top of the UI (#15114) * Remove top nav link if ACLs disabled * Change to an enabled-by-default model since you get no agent config when ACLs are disabled but you lack a token * PR feedback addressed; down with double negative conditionals * lintfix * ember getter instead of ?.prop * [SSO] Auth Methods and Mock OIDC Flow (#15155) * Big ol first pass at a redirect sign in flow * dont recursively add queryparams on redirect * Passing state and code qps * In which I go off the deep end and embed a faux provider page in the nomad ui * Buggy but self-contained flow * Flow auto-delay added and a little more polish to resetting token * secret passing turned to accessor passing * Handle SSO Failure * General cleanup and test fix * Lintfix * SSO flow acceptance tests * Percy snapshots added * Explicitly note the OIDC test route is mirage only * Handling failure case for complete-auth * Leentfeex * Tokens page styles (#15273) * styling and moving columns around * autofocus and enter press handling * Styles refined * Split up manager and regular tests * Standardizing to a binary status state * Serialize auth-methods response to use "name" as primary key (#15380) * Serializer for unique-by-name * Use @classic because of class extension
174 lines
4.4 KiB
JavaScript
174 lines
4.4 KiB
JavaScript
import { Factory } from 'ember-cli-mirage';
|
|
import faker from 'nomad-ui/mirage/faker';
|
|
|
|
export default Factory.extend({
|
|
id: () => faker.random.uuid(),
|
|
accessorId() {
|
|
return this.id;
|
|
},
|
|
secretId: () => faker.random.uuid(),
|
|
name: (i) => `${i === 0 ? 'Manager ' : ''}${faker.name.findName()}`,
|
|
global: () => faker.random.boolean(),
|
|
type: (i) => (i === 0 ? 'management' : 'client'),
|
|
|
|
oneTimeSecret: () => faker.random.uuid(),
|
|
|
|
afterCreate(token, server) {
|
|
const policyIds = Array(faker.random.number({ min: 1, max: 5 }))
|
|
.fill(0)
|
|
.map(() => faker.hacker.verb())
|
|
.uniq();
|
|
|
|
policyIds.forEach((policy) => {
|
|
const dbPolicy = server.db.policies.find(policy);
|
|
if (!dbPolicy) {
|
|
server.create('policy', { id: policy });
|
|
}
|
|
});
|
|
|
|
token.update({ policyIds });
|
|
|
|
// Create a special policy with variables rules in place
|
|
if (token.id === '53cur3-v4r14bl35') {
|
|
const variableMakerPolicy = {
|
|
id: 'Variable Maker',
|
|
rules: `
|
|
# Allow read only access to the default namespace
|
|
namespace "*" {
|
|
policy = "read"
|
|
capabilities = ["list-jobs", "alloc-exec", "read-logs"]
|
|
variables {
|
|
# Base access is to all abilities for all variables
|
|
path "*" {
|
|
capabilities = ["list", "read", "destroy", "create"]
|
|
}
|
|
}
|
|
}
|
|
|
|
node {
|
|
policy = "read"
|
|
}
|
|
`,
|
|
|
|
rulesJSON: {
|
|
Namespaces: [
|
|
{
|
|
Name: '*',
|
|
Capabilities: ['list-jobs', 'alloc-exec', 'read-logs'],
|
|
Variables: {
|
|
Paths: [
|
|
{
|
|
Capabilities: ['write', 'read', 'destroy', 'list'],
|
|
PathSpec: '*',
|
|
},
|
|
],
|
|
},
|
|
},
|
|
],
|
|
},
|
|
};
|
|
server.create('policy', variableMakerPolicy);
|
|
token.policyIds.push(variableMakerPolicy.id);
|
|
}
|
|
if (token.id === 'f3w3r-53cur3-v4r14bl35') {
|
|
const variableViewerPolicy = {
|
|
id: 'Variable Viewer',
|
|
rules: `
|
|
# Allow read only access to the default namespace
|
|
namespace "*" {
|
|
policy = "read"
|
|
capabilities = ["list-jobs", "alloc-exec", "read-logs"]
|
|
variables {
|
|
# Base access is to all abilities for all variables
|
|
path "*" {
|
|
capabilities = ["list"]
|
|
}
|
|
}
|
|
}
|
|
|
|
namespace "namespace-1" {
|
|
policy = "read"
|
|
capabilities = ["list-jobs", "alloc-exec", "read-logs"]
|
|
variables {
|
|
# Base access is to all abilities for all variables
|
|
path "*" {
|
|
capabilities = ["list", "read", "destroy", "create"]
|
|
}
|
|
}
|
|
}
|
|
|
|
namespace "namespace-2" {
|
|
policy = "read"
|
|
capabilities = ["list-jobs", "alloc-exec", "read-logs"]
|
|
variables {
|
|
# Base access is to all abilities for all variables
|
|
path "blue/*" {
|
|
capabilities = ["list", "read", "destroy", "create"]
|
|
}
|
|
path "nomad/jobs/*" {
|
|
capabilities = ["list", "read", "create"]
|
|
}
|
|
}
|
|
}
|
|
|
|
node {
|
|
policy = "read"
|
|
}
|
|
`,
|
|
|
|
rulesJSON: {
|
|
Namespaces: [
|
|
{
|
|
Name: '*',
|
|
Capabilities: ['list-jobs', 'alloc-exec', 'read-logs'],
|
|
Variables: {
|
|
Paths: [
|
|
{
|
|
Capabilities: ['list'],
|
|
PathSpec: '*',
|
|
},
|
|
],
|
|
},
|
|
},
|
|
{
|
|
Name: 'namespace-1',
|
|
Capabilities: ['list-jobs', 'alloc-exec', 'read-logs'],
|
|
Variables: {
|
|
Paths: [
|
|
{
|
|
Capabilities: ['list', 'read', 'destroy', 'create'],
|
|
PathSpec: '*',
|
|
},
|
|
],
|
|
},
|
|
},
|
|
{
|
|
Name: 'namespace-2',
|
|
Capabilities: ['list-jobs', 'alloc-exec', 'read-logs'],
|
|
Variables: {
|
|
Paths: [
|
|
{
|
|
Capabilities: ['list', 'read', 'destroy', 'create'],
|
|
PathSpec: 'blue/*',
|
|
},
|
|
{
|
|
Capabilities: ['list', 'read', 'create'],
|
|
PathSpec: 'nomad/jobs/*',
|
|
},
|
|
],
|
|
},
|
|
},
|
|
],
|
|
},
|
|
};
|
|
server.create('policy', variableViewerPolicy);
|
|
token.policyIds.push(variableViewerPolicy.id);
|
|
}
|
|
if (token.id === '3XP1R35-1N-3L3V3N-M1NU735') {
|
|
token.update({
|
|
expirationTime: new Date(new Date().getTime() + 11 * 60 * 1000),
|
|
});
|
|
}
|
|
},
|
|
});
|