I am trying to implement a role based access control system with react-redux. So far I've been reading up on it and have seen some general methods along the lines of:
<View>
{!user && <LoginScreen />}
{user && <WelcomeScreen user={user} />}
</View>
which is basically using variables or the state to test conditions and grant access to certain components. My predicament occurs when I came across this post:
Can react state be tampered with to bypass security measures?
If the user can tamper the state and view the components where they don't have permissions, what is the proper way to ensure role based access? Storing the user data as position: employee
could be changed to position: manager
in the client, and then they would be able to see what options are available to managers, even if no REST requests have been made.
I am currently using session cookies to validate the user server side, and any data-sensitive REST get/posts are authenticated - but how does this translate to the client?
user logs in
-> server verifies
-> server sends back session variable that holds user.position / or sends json(user)
-> client looks at session from server or json(user), stores user.position in state.user.position
-> state.user.position is used in conditional if to determine whether or not to display components as above
---*but*---> client goes in and changes state state.user.position and gets access to components anyways
If we can change state in the client, how can we securely use conditional tests in react/redux?