mirror of
https://github.com/ansible/awx.git
synced 2026-01-18 05:01:19 -03:30
Prevents the user from adding a token for a user other than themselves
It's possible to maninpulate the URL to get to the add-token screen for a different user, which gives the user the idea that they could possibly add a token for that user, which is not allowed.
This commit is contained in:
parent
1b67755358
commit
02f6fa9b0a
@ -16,6 +16,21 @@ TokensDetailResolve.$inject = [
|
||||
'ApplicationModel'
|
||||
];
|
||||
|
||||
function isMeResolve ($rootScope, $stateParams, $state) {
|
||||
// The user should not be able to add tokens for users other than
|
||||
// themselves. Adding this redirect so that a user is not able to
|
||||
// visit the add-token URL directly for a different user.
|
||||
if (_.has($stateParams, 'user_id') && Number($stateParams.user_id) !== $rootScope.current_user.id) {
|
||||
$state.go('users');
|
||||
}
|
||||
}
|
||||
|
||||
isMeResolve.$inject = [
|
||||
'$rootScope',
|
||||
'$stateParams',
|
||||
'$state'
|
||||
];
|
||||
|
||||
export default {
|
||||
url: '/add-token',
|
||||
name: 'users.edit.tokens.add',
|
||||
@ -37,6 +52,7 @@ export default {
|
||||
}
|
||||
},
|
||||
resolve: {
|
||||
resolvedModels: TokensDetailResolve
|
||||
resolvedModels: TokensDetailResolve,
|
||||
isMe: isMeResolve
|
||||
}
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user