-
Notifications
You must be signed in to change notification settings - Fork 232
What can user do #82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What can user do #82
Conversation
if (pageRules) { | ||
_.each(this.rules, function(rule) { | ||
_.each(pageRules, function(verbs, resource) { | ||
if (_.indexOf(rule.resources, resource) !== -1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this work (here and below)?
_.includes(rule.resources, resource)
will add |
I suspect @liggitt will be interested in this one |
So first, keep your existing changes in a side branch since you have them working ...
I've at least run this by @spadgett and @benjaminapetersen and we agree in theory |
// added into the $scope.canI variable. | ||
// In case a resource shall to be added into the $scope.canI variable under a different unique name(eg. not as a | ||
// resource kind) but a different unique name(eg. namespace), use the 'identifier' parameter. | ||
AuthorizationService.prototype.canI = function(ns, verb, kind, $scope, identifier) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be more specific regarding api group, kind, and resource?
this.projectNameRules = null; | ||
} | ||
|
||
AuthorizationService.prototype.reviewUserRules = function($scope) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know we do this in other places, but we shouldn't pass scope to services. Services shouldn't know anything about a controller's scope.
c377e4f
to
701a714
Compare
@jwforres I've updated the PR(not final) to get additional feedback.
|
AuthorizationService.prototype.canI = function(resource, verb) { | ||
var rules = this.getRules(); | ||
if (rules) { | ||
if (resource) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can probably just return _.contains(rules[resource], verb)
here since underscore will return true or false for you.
<!-- Primary Actions --> | ||
<button class="btn btn-default hidden-xs" | ||
ng-click="cancelBuild()" | ||
ng-if="!build.metadata.deletionTimestamp && (build | isIncompleteBuild)">Cancel Build</button> | ||
ng-if="!build.metadata.deletionTimestamp && (build | isIncompleteBuild) && ('builds/clone' | canI : 'create')">Cancel Build</button> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create on builds/clone isnt the right check for cancel build, copy/paste error i'm guessing, same thing on line 42 below. Should just be checking update on builds i think.
Can you go ahead and add this to otherResources.js so that it will only put things in the dropdown that can actually be listed by the user:
You'll also need to include AuthorizationService in the list of deps at the top of the service. You'll know its working if you can't see PetSets. Then in constants.js please remove
from the blacklist, they'll now be cleanly removed from the list because the List verb isn't allowed on them. You need to leave DeploymentConfigRollback for now. |
// - subresource taht contains '/', eg: 'builds/source', 'builds/logs', ... | ||
// - resource ending with 'review' string: 'localsubjectaccessreviews', 'selfsubjectrulesreviews', 'subjectaccessreviews' | ||
var checkResource = function(resource) { | ||
if (resource === "projectrequests" || _.contains(resource, "/") || resource.endsWith("reviews")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checking if it contains /
is fine, but I'd rather not use endsWith... we should have an explicit list (or hash) of resources we don't care about for this
also remove ReplicaSet, PodTemplate, and ThirdPartyResource from the blacklist |
There is another View Log link that needs a canI check here https://github.com/openshift/origin-web-console/pull/82/files#diff-d40b418167447e1277db88f1163bb5d9L117 |
@@ -122,7 +122,7 @@ | |||
<uib-tab active="selectedTab.terminal" | |||
select="terminalTabWasSelected = true" | |||
ng-init="containers = pod.status.containerStatuses" | |||
ng-if="containersRunning(pod.status.containerStatuses) > 0"> | |||
ng-if="containersRunning(pod.status.containerStatuses) > 0 && ('pods/attach' | canI : 'get')"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be pods/exec
cf3e23c
to
155e7ef
Compare
@jwforres @benjaminapetersen @liggitt I've update the PR based on your comments, expect the one that suggests to return the |
Cool, I'm good with that. |
} | ||
}); | ||
if (canAddToProject) { | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this not returning true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ignore this comment, i'd rather see https://github.com/openshift/origin-web-console/pull/82/files#r70297639 happen
[merge] |
looks like it might have just been a flake [merge] |
failed on the same test, @jhadvig can you run |
[merge] will let it go one more time, but i suspect this may be related to additional delay before the delete action is being shown |
Origin Web Console Merge Results: SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_requests_origin_web_console/104/) |
[merge] |
Evaluated for origin web console merge up to 332bffe |
fixed bug ORS-73
Created a new
AuthorizationService
to determine actions that user can/can't do.The new service consists from two main methods:
reviewUserRules
$scope.canI
variable which should be set in each controller which will call this method.canI
$scope.canI
variable, will create one if not present in controller and adds the result of the resource/verb review to it.@jwforres PTAL
Implements https://trello.com/c/UQEUgVrY