Skip to content

Commit

Permalink
Fix permission checks for non admin users
Browse files Browse the repository at this point in the history
Some components were using wrong permission values, so non-admin users
could never get to do those actions.

Refs #2358
  • Loading branch information
Edmundo Alvarez committed Jun 16, 2016
1 parent e3ebd96 commit c2fba39
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
22 changes: 11 additions & 11 deletions graylog2-web-interface/src/components/navigation/Navigation.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ const Navigation = React.createClass({
</Navbar.Header>
<Navbar.Collapse eventKey={0}>
<Nav navbar>
{this.isPermitted(this.props.permissions, ['SEARCHES_ABSOLUTE', 'SEARCHES_RELATIVE', 'SEARCHES_KEYWORD']) &&
{this.isPermitted(this.props.permissions, ['searches:absolute', 'searches:relative', 'searches:keyword']) &&
<LinkContainer to={Routes.SEARCH}>
<NavItem to="search">Search</NavItem>
</LinkContainer>
Expand All @@ -155,7 +155,7 @@ const Navigation = React.createClass({
<NavItem >Dashboards</NavItem>
</LinkContainer>

{this.isPermitted(this.props.permissions, ['SOURCES_READ']) &&
{this.isPermitted(this.props.permissions, ['sources:read']) &&
<LinkContainer to={Routes.SOURCES}>
<NavItem>Sources</NavItem>
</LinkContainer>
Expand All @@ -167,50 +167,50 @@ const Navigation = React.createClass({
<LinkContainer to={Routes.SYSTEM.OVERVIEW}>
<MenuItem>Overview</MenuItem>
</LinkContainer>
{this.isPermitted(this.props.permissions, ['CLUSTER_CONFIG_ENTRY_READ']) &&
{this.isPermitted(this.props.permissions, ['clusterconfigentry:read']) &&
<LinkContainer to={Routes.SYSTEM.CONFIGURATIONS}>
<MenuItem>Configurations</MenuItem>
</LinkContainer>
}
<LinkContainer to={Routes.SYSTEM.NODES.LIST}>
<MenuItem>Nodes</MenuItem>
</LinkContainer>
{this.isPermitted(this.props.permissions, ['INPUTS_READ']) &&
{this.isPermitted(this.props.permissions, ['inputs:read']) &&
<LinkContainer to={Routes.SYSTEM.INPUTS}>
<MenuItem>Inputs</MenuItem>
</LinkContainer>
}
{this.isPermitted(this.props.permissions, ['OUTPUTS_READ']) &&
{this.isPermitted(this.props.permissions, ['outputs:read']) &&
<LinkContainer to={Routes.SYSTEM.OUTPUTS}>
<MenuItem>Outputs</MenuItem>
</LinkContainer>
}
{this.isPermitted(this.props.permissions, ['INDICES_READ']) &&
{this.isPermitted(this.props.permissions, ['indices:read']) &&
<LinkContainer to={Routes.SYSTEM.INDICES.LIST}>
<MenuItem>Indices</MenuItem>
</LinkContainer>
}
{this.isPermitted(this.props.permissions, ['LOGGERS_READ']) &&
{this.isPermitted(this.props.permissions, ['loggers:read']) &&
<LinkContainer to={Routes.SYSTEM.LOGGING}>
<MenuItem>Logging</MenuItem>
</LinkContainer>
}
{this.isPermitted(this.props.permissions, ['USERS_READ']) &&
{this.isPermitted(this.props.permissions, ['users:list']) &&
<LinkContainer to={Routes.SYSTEM.USERS.LIST}>
<MenuItem>Users</MenuItem>
</LinkContainer>
}
{this.isPermitted(this.props.permissions, ['ROLES_READ']) &&
{this.isPermitted(this.props.permissions, ['roles:read']) &&
<LinkContainer to={Routes.SYSTEM.ROLES}>
<MenuItem>Roles</MenuItem>
</LinkContainer>
}
{this.isPermitted(this.props.permissions, ['DASHBOARDS_CREATE', 'INPUTS_CREATE', 'STREAMS_CREATE']) &&
{this.isPermitted(this.props.permissions, ['dashboards:create', 'inputs:create', 'streams:create']) &&
<LinkContainer to={Routes.SYSTEM.CONTENTPACKS.LIST}>
<MenuItem>Content Packs</MenuItem>
</LinkContainer>
}
{this.isPermitted(this.props.permissions, ['INPUTS_EDIT']) &&
{this.isPermitted(this.props.permissions, ['inputs:edit']) &&
<LinkContainer to={Routes.SYSTEM.GROKPATTERNS}>
<MenuItem>Grok Patterns</MenuItem>
</LinkContainer>
Expand Down
2 changes: 1 addition & 1 deletion graylog2-web-interface/src/components/users/UserForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ const UserForm = React.createClass({
onChange={this._bindValue} labelClassName="col-sm-3" wrapperClassName="col-sm-9"
label="Email Address" help="Give the contact email address." required />

{this.isPermitted(permissions, 'USERS_EDIT') &&
{this.isPermitted(permissions, 'users:edit') &&
<span>
<div className="form-group">
<Col sm={9} smOffset={3}>
Expand Down
4 changes: 2 additions & 2 deletions graylog2-web-interface/src/pages/StartPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const StartPage = React.createClass({
},
_redirectToStartpage() {
// Show getting started page if user is an admin and getting started wasn't dismissed
if (PermissionsMixin.isPermitted(this.state.currentUser.permissions, ['INPUTS_CREATE'])) {
if (PermissionsMixin.isPermitted(this.state.currentUser.permissions, ['inputs:create'])) {
if (!!this.state.gettingStarted.show) {
this._redirect(Routes.GETTING_STARTED);
return;
Expand All @@ -58,7 +58,7 @@ const StartPage = React.createClass({
}

// Show search page if permitted, or streams page in other case
if (PermissionsMixin.isAnyPermitted(this.state.currentUser.permissions, ['SEARCHES_ABSOLUTE', 'SEARCHES_RELATIVE', 'SEARCHES_KEYWORD'])) {
if (PermissionsMixin.isAnyPermitted(this.state.currentUser.permissions, ['searches:absolute', 'searches:keyword', 'searches:relative'])) {
this._redirect(Routes.SEARCH);
} else {
this._redirect(Routes.STREAMS);
Expand Down
6 changes: 3 additions & 3 deletions graylog2-web-interface/src/pages/UsersPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ const UsersPage = React.createClass({

<span>Read more about user management in the <DocumentationLink page={DocsHelper.PAGES.USERS_ROLES} text="documentation"/>.</span>
<span>
{this.isPermitted(permissions, 'LDAP_EDIT') &&
{this.isPermitted(permissions, 'ldap:edit') &&
<LinkContainer to={Routes.SYSTEM.LDAP.SETTINGS}>
<Button bsStyle="info">Configure LDAP</Button>
</LinkContainer>
}
{' '}
{this.isPermitted(permissions, 'LDAPGROUPS_EDIT') &&
{this.isPermitted(permissions, 'ldapgroups:edit') &&
<LinkContainer to={Routes.SYSTEM.LDAP.GROUPS}>
<Button bsStyle="info">LDAP Group Mapping</Button>
</LinkContainer>
}
{' '}
{this.isPermitted(permissions, 'USERS_CREATE') &&
{this.isPermitted(permissions, 'users:create') &&
<LinkContainer to={Routes.SYSTEM.USERS.CREATE}>
<Button bsStyle="success">Add new user</Button>
</LinkContainer>
Expand Down

0 comments on commit c2fba39

Please sign in to comment.