/** @jsx React.DOM */
/* global conjur, _, React, ReactBootstrap */
(function(conjur, _, React, ReactBootstrap) {
'use strict';
var TabbedArea = ReactBootstrap.TabbedArea,
TabPane = ReactBootstrap.TabPane,
Tab = conjur.views.mixins.Tab,
AuditBox = window.AuditBox,
AnnotationsBox = conjur.views.AnnotationsBox,
Breadcrumbs = conjur.views.Breadcrumbs,
RoleLink = conjur.views.RoleLink,
Chart = conjur.views.Chart,
ChartHelperMixin = conjur.views.ChartHelperMixin,
FoldableAuditSection = conjur.views.FoldableAuditSection;
var PubkeyItem = React.createClass({
render: function() {
return (
{this.props.pubkey[0]}
-
{this.props.pubkey[2]}
-
{/* TODO: key fingerprint */}
-
{/* TODO: When added, when last time used */}
{/* TODO: Action buttons */}
);
}
});
var PubkeysList = React.createClass({
render: function() {
var login = this.props.login;
var pubkeysList = this.props.pubkeys.map(function(k, idx, coll) {
var tokens = k.split(' ');
var className = 'b-pubkeys__item list-group-item list-group-item-noborder';
if (idx + 1 !== coll.length) {
className = className + ' b-pubkeys__item--headline';
}
return (
);
});
return (
This is list of SSH public keys associated with user {login}.
);
}
});
var PubkeysHelp = React.createClass({
render: function() {
var ret;
if (React.Children.count(this.props.children) > 0) {
ret = (
{this.props.children}
);
} else {
var login = this.props.login;
ret = (
There is no pubkeys registered for this user yet. Use following command to upload one from a file:
$ conjur pubkeys add {login} @userkeyfile.pub
);
}
return ret;
}
});
var PubkeysTabContent = React.createClass({
render: function() {
var body;
if (this.props.pubkeys.length > 0) {
body = (
);
} else {
body = (
);
}
return body;
}
});
var Activity = React.createClass({
mixins: [ChartHelperMixin],
getDefaultProps: function() {
return {
options: {
legend: {
logins: 'Logins',
sudo: 'Sudo calls',
reads: 'Secret reads',
updates: 'Secret updates',
warnings: 'Warnings'
},
axis: {
y: {
label: 'Value'
}
}
}
};
},
getDefaultItem: function() {
return {
logins: 0,
sudo: 0,
reads: 0,
updates: 0,
warnings: 0
};
},
getEventType: function(e) {
if (e.hasOwnProperty('facility') && e.facility === 'ssh') {
if (e.action === 'sudo' && e.allowed === true) {
return 'sudo';
} else if (e.action === 'login' && e.allowed === true) {
return 'logins';
}
}
if (e.hasOwnProperty('error') || e.allowed === false) {
return 'warnings';
}
if (e.action==='check' &&
e.hasOwnProperty('allowed') &&
e.allowed === true) {
if (e.hasOwnProperty('role') &&
e.role === this.props.roleid) {
if (e.hasOwnProperty('resource') &&
e.resource.split(':')[1] === 'variable') {
if (e.privilege === 'update' ) {
return 'updates';
} else if (e.privilege === 'execute') {
return 'reads';
}
}
}
}
return null;
},
render: function() {
var data = this.getData(this.props.audit);
return (
);
}
});
var Details = React.createClass({
render: function() {
// TODO: refactor
// TODO: show public keys
// TODO: actions menu (e.g. 'upload public key', 'add annotation')
// TODO: memberships panel
return (
Details
- Created by
- Owner
- Uidnumber
- {this.props.user.uidnumber}
);
}
});
this.User = React.createClass({
mixins: [Tab],
render: function() {
var user = this.props.data.user;
var pubkeysTab = (
);
var permissionsTab = this.permissionsTab(user.roleid);
var membershipsTab = this.membershipsTab(user.roleid);
var ownedTab = this.ownedTab();
var tabs = _.compact([
pubkeysTab,
ownedTab,
membershipsTab,
permissionsTab
]);
var elems = [
{url: '/ui/users', text: 'Users'},
{url: '', text: this.props.data.user.login},
{url: '', text: '(owned by ' + this.props.data.user.ownerid + ')'}
];
return (
{FoldableAuditSection.warnings(this.props.data.audit)}
Other
{tabs}
);
}
});
}).bind(conjur.views)
(
conjur,
_,
React,
ReactBootstrap
);