Skip to content
This repository has been archived by the owner on Aug 4, 2020. It is now read-only.

Commit

Permalink
Update Dashboard to use V2 SDB API (#13)
Browse files Browse the repository at this point in the history
* Updates dashboard to use v2 safe-deposit-box API
  • Loading branch information
sdford authored Apr 20, 2017
1 parent d17d9a0 commit 45c6322
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 44 deletions.
3 changes: 1 addition & 2 deletions app/components/CreateSDBoxForm/CreateSDBoxForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ export const fields = [
'owner',
'userGroupPermissions[].name',
'userGroupPermissions[].roleId',
'iamRolePermissions[].accountId',
'iamRolePermissions[].iamRoleName',
'iamRolePermissions[].iamPrincipalArn',
'iamRolePermissions[].roleId'
]

Expand Down
11 changes: 4 additions & 7 deletions app/components/CreateSDBoxForm/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,11 @@ const validateUserGroupPermissions = (permission, index, errors) => {

const validateIamRolePermissions = (permission, index, errors) => {
errors.iamRolePermissions[`${index}`] = {}
if (! permission.accountId) {
errors.iamRolePermissions[`${index}`].accountId = 'Required'
} else if (! /^\d+$/.test(permission.accountId)) {
errors.iamRolePermissions[`${index}`].accountId = 'Numeric only'
}

if (! permission.iamRoleName) {
errors.iamRolePermissions[`${index}`].iamRoleName = 'You must enter a IAM role name for this permission'
if (! permission.iamPrincipalArn) {
errors.iamRolePermissions[`${index}`].iamPrincipalArn = 'You must enter a IAM principal ARN for this permission'
} else if (! /^arn:aws:(iam|sts)::.+$/.test(permission.iamPrincipalArn)) {
errors.iamRolePermissions[`${index}`].iamPrincipalArn = 'Invalid ARN'
}

if (! permission.roleId) {
Expand Down
3 changes: 1 addition & 2 deletions app/components/EditSDBoxForm/EditSDBoxForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ export const fields = [
'owner',
'userGroupPermissions[].name',
'userGroupPermissions[].roleId',
'iamRolePermissions[].accountId',
'iamRolePermissions[].iamRoleName',
'iamRolePermissions[].iamPrincipalArn',
'iamRolePermissions[].roleId'
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,20 @@ export default class IamRolePermissionsFieldSet extends Component {

return (
<div className='iam-role-permissions'>
<div className='iam-role-permissions-label ncss-label'>IAM Role Permissions</div>
<div className='iam-role-permissions-label ncss-label'>IAM Principal Permissions</div>
<div className="iam-role-permissions-perms-container">
<div className="iam-role-permissions-perms-container">
{iamRolePermissions.map((permission, index) =>
<div key={index}>
<div className='iam-role-permissions-permission'>
<div className='role-perm-acct-id'>
<div className={((permission.accountId.touched && permission.accountId.error) ? 'ncss-input-container error' : 'ncss-input-container')}>
<input {...permission.accountId}
type='text'
className='ncss-input pt2-sm pr4-sm pb2-sm pl4-sm'
placeholder='AWS Acct Id' />
{permission.accountId.touched && permission.accountId.error && <div className='ncss-error-msg'>{permission.accountId.error}</div>}
</div>
</div>

<div className='role-perm-role-name'>
<div className={((permission.iamRoleName.touched && permission.iamRoleName.error) ? 'ncss-input-container error' : 'ncss-input-container')}>
<input {...permission.iamRoleName}
<div className='role-perm-principal-arn'>
<div className={((permission.iamPrincipalArn.touched && permission.iamPrincipalArn.error) ? 'ncss-input-container error' : 'ncss-input-container')}>
<input {...permission.iamPrincipalArn}
type='text'
className='ncss-input pt2-sm pr4-sm pb2-sm pl4-sm'
placeholder='Role Name' />
{permission.iamRoleName.touched && permission.iamRoleName.error && <div className='ncss-error-msg'>{permission.iamRoleName.error}</div>}
placeholder='IAM Principal ARN' />
{permission.iamPrincipalArn.touched && permission.iamPrincipalArn.error && <div className='ncss-error-msg'>{permission.iamPrincipalArn.error}</div>}
</div>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,8 @@
padding-top: 10px;
display: flex;

.role-perm-acct-id {
flex: .15;
.ncss-error-msg {
padding-left: 2px;
}
}

.role-perm-role-name {
flex: .70;
.role-perm-principal-arn {
flex: .75;
padding-left: 5px;
.ncss-error-msg {
padding-left: 3px;
Expand Down
10 changes: 4 additions & 6 deletions app/components/ManageSDBox/ManageSDBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,23 +173,21 @@ const readOnlyUserGroupPermissions = (userGroupPermissions, roles) => {

const readOnlyIamRolePermissions = (iamRolePermissions, roles) => {
if (iamRolePermissions == null || iamRolePermissions.length < 1) {
return(<div>No IAM Role Permissions Defined</div>)
return(<div>No IAM Principal Permissions Defined</div>)
} else {
return(
<div className="perm-block">
<div className="read-only-permissions-label">IAM Role Permissions</div>
<div className="read-only-permissions-label">IAM Principal Permissions</div>
<table className="iam-read-only-permission-group">
<tr>
<th className="iam-read-label">Acct ID</th>
<th className="iam-read-label">Role Name</th>
<th className="iam-read-label">IAM Principal ARN</th>
<th className="iam-read-label">Role</th>
</tr>

{iamRolePermissions.map((perm, index) => {
return (
<tr key={perm.id} className={(index + 1) % 2 == 0 ? "iam-read-only-perm even-row" : "iam-read-only-perm odd-row"}>
<td className="iam-read-only-perm-item iam-read-only-perm-acct-id">{perm.accountId}</td>
<td className="iam-read-only-perm-item iam-read-only-perm-role-name">{perm.iamRoleName}</td>
<td className="iam-read-only-perm-item iam-read-only-perm-principal-arn">{perm.iamPrincipalArn}</td>
<td className="iam-read-only-perm-item iam-read-only-perm-role">{roleNameFromId(perm.roleId, roles)}</td>
</tr>
)
Expand Down
2 changes: 1 addition & 1 deletion app/components/SDBMetadata/SDBMetadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default class SDBMetadata extends Component {
</div>
<div className="sdb-metadata">
<div className="sdb-metadata-kv">
<div className="sdb-metadata-label ncss-brand">IAM Role Permissions:</div>
<div className="sdb-metadata-label ncss-brand">IAM Principal Permissions:</div>
<div className="sdb-metadata-value">
{ getPermissionsAsString(sdbMetadata.iam_role_permissions) }
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/constants/cms.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const USER_AUTH_PATH_REFRESH = '/v2/auth/user/refresh'
export const TOKEN_DELETE_PATH = '/v1/auth'
export const RETRIEVE_CATEGORY_PATH = '/v1/category'
export const RETRIEVE_ROLE_PATH = '/v1/role'
export const BUCKET_RESOURCE = '/v1/safe-deposit-box'
export const BUCKET_RESOURCE = '/v2/safe-deposit-box'
export const RETRIEVE_METADATA = '/v1/metadata'
export const MFA_REQUIRED_STATUS = 'mfa_req'

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cerberus-management-dashboard",
"version": "0.6.0",
"version": "0.12.0",
"description": "A management dashboard for Cerberus.",
"main": "index.js",
"repository": {
Expand Down

0 comments on commit 45c6322

Please sign in to comment.