-
Notifications
You must be signed in to change notification settings - Fork 153
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
Add GET Roles and UnassignRole to REST API #30
Add GET Roles and UnassignRole to REST API #30
Conversation
@oleg-nenashev hi, don't forget to tell me if it's possible. |
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.
Sorry for missiong the original notification. The change looks good to me Some autotests would be useful, of course
* @since 2.4.1 | ||
*/ | ||
@Restricted(NoExternalUse.class) | ||
public void doGetAllRoles(StaplerRequest req, StaplerResponse rsp) throws IOException { |
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.
Probably should require POST as well since it may impact internal caching (when we have it, hehe)
@oleg-nenashev, I removed unnecessary comments, because we need to get a data from getAllRoles function, we not to send a data with POST. Sorry again I missed it at proofreading |
@oleg-nenashev did you tested this pull request ? |
Nope, I have not. Sorry about the delay, there were lots of activities going in the Jenkins core and security releases. |
I hope to find some time for the plugins on the weekend |
No problem 👍 :) |
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.
LGTM after some testing
When i run jenkins with tomcat, when i try to use this API, i got 404 error. The command: curl -X GET 15.114.100.53:8080/role-strategy/strategy/allRoles or curl -X GET -u admin:devops 15.114.100.53:8080/jenkins/role-strategy/strategy/allRoles, is there any thing wrong? |
hi @hpejustin ,
The maintener has forgotten 'get' in front of allRoles into the doc. |
Hmm, |
Jenkins ver. 2.60.2 @oleg-nenashev , i deploy my jenkins with jenkins.war in the tomcat folder ../webapps/jenkins, so i access it whit http://15.114.100.53:8080/jenkins, but i can not get correct result when i use the command previous write there. |
thanks all, i got the right result now, maybe some proxy reason, it is so nice of you all. |
This is great that we can pull all the global roles using role-strategy/strategy/getAllRoles, however, can you also expose getting all the project or item roles? |
Hi, Is there a rest api call to assign a particular role to a person in a particular project??? |
I think we "just" need to implement export logic for that.
Nope, the plugin operates on regexp basis. You would have to create a new role in order to define permissions for particular project. Ownership-based security works it around by project-specific security |
Has getting item roles/project roles been possible yet? also are we able to add/remove project/item roles or is it just globalroles for now for all aspects for the api? |
I added the unassign to api with
Example: curl -X POST localhost:8080/role-strategy/strategy/unassignRole --data "type=globalRoles&roleName=AMD&sid=username"
and I added the GET function api to return all roles and their groups with
Example: curl -X GET localhost:8080/role-strategy/strategy/getAllRoles
Result json: {roleName: ['group1', 'group2'], roleName : ''}