Skip to content

Commit

Permalink
No IAM - Provide full access (#121)
Browse files Browse the repository at this point in the history
* no IAM full access

Signed-off-by: Mohammed Abdi <moabdi@Mohammeds-MBP-2.attlocal.net>

* print isadmin and withauth

Signed-off-by: Mohammed Abdi <moabdi@Mohammeds-MBP-2.attlocal.net>

* fix without auth bug

Signed-off-by: Mohammed Abdi <moabdi@Mohammeds-MBP-2.attlocal.net>

* nit delete comments

Signed-off-by: Mohammed Abdi <moabdi@Mohammeds-MBP-2.attlocal.net>

---------

Signed-off-by: Mohammed Abdi <moabdi@Mohammeds-MBP-2.attlocal.net>
Co-authored-by: Mohammed Abdi <moabdi@Mohammeds-MBP-2.attlocal.net>
  • Loading branch information
mamy-CS and Mohammed Abdi authored Feb 17, 2023
1 parent f525585 commit d819169
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
11 changes: 8 additions & 3 deletions tornjak-frontend/src/components/RenderOnAdminRole.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import AccessNotAllowed from './AccessNotAllowed'
import { connect } from 'react-redux';
import { RootState } from 'redux/reducers';

const Auth_Server_Uri = process.env.REACT_APP_AUTH_SERVER_URI;

type RenderOnAdminRoleProp = {
// updated user roles
globalUserRoles: string[],
Expand Down Expand Up @@ -37,11 +39,14 @@ class RenderOnAdminRole extends Component<RenderOnAdminRoleProp, RenderOnAdminRo
render() {
return (
<div>
{!Auth_Server_Uri &&
this.props.children // if No IAM return children
}
{this.TornjakHelper.checkRolesAdminUser(this.props.globalUserRoles) &&
this.props.children // if admin role return children
this.props.children // if IAM and admin role return children
}
{!this.TornjakHelper.checkRolesAdminUser(this.props.globalUserRoles) && this.checkPath() &&
<AccessNotAllowed /> // if no admin role return access not allowed
{!this.TornjakHelper.checkRolesAdminUser(this.props.globalUserRoles) && this.checkPath() && Auth_Server_Uri &&
<AccessNotAllowed /> // if IAM and no admin role return access not allowed
}
</div>
);
Expand Down
7 changes: 3 additions & 4 deletions tornjak-frontend/src/components/navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ class NavigationBar extends Component<NavigationBarProp, NavigationBarState> {
<div className="dropdown">
<a href="/server/manage" className="dropbtn">Manage Servers</a>
</div>

return (
<div data-test="nav-bar">
<div className="navigation-bar">
Expand All @@ -82,7 +81,7 @@ class NavigationBar extends Component<NavigationBarProp, NavigationBarState> {
<a href="/clusters" className="dropbtn">Clusters </a>
<div className="dropdown-content">
<a href="/clusters" className="nav-link">Clusters List</a>
{(isAdmin || (withAuth === undefined)) &&
{(isAdmin || !withAuth) &&
<a href="/cluster/clustermanagement" className="nav-link">Cluster Management</a>
}
</div>
Expand All @@ -91,7 +90,7 @@ class NavigationBar extends Component<NavigationBarProp, NavigationBarState> {
<a href="/agents" className="dropbtn">Agents </a>
<div className="dropdown-content">
<a href="/agents" className="nav-link">Agents List</a>
{(isAdmin || (withAuth === undefined)) &&
{(isAdmin || !withAuth) &&
<a href="/agent/createjointoken" className="nav-link">Create Token</a>
}
</div>
Expand All @@ -100,7 +99,7 @@ class NavigationBar extends Component<NavigationBarProp, NavigationBarState> {
<a href="/entries" className="dropbtn">Entries</a>
<div className="dropdown-content">
<a href="/entries" className="nav-link">Entries List</a>
{(isAdmin || (withAuth === undefined)) &&
{(isAdmin || !withAuth) &&
<a href="/entry/create" className="nav-link">Create Entries</a>
}
</div>
Expand Down

0 comments on commit d819169

Please sign in to comment.