Skip to content
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

Merged
merged 2 commits into from
Aug 15, 2017
Merged

Add GET Roles and UnassignRole to REST API #30

merged 2 commits into from
Aug 15, 2017

Conversation

LegallGuillaume
Copy link
Contributor

@LegallGuillaume LegallGuillaume commented Jul 25, 2017

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 : ''}

@LegallGuillaume
Copy link
Contributor Author

@oleg-nenashev hi, don't forget to tell me if it's possible.

Copy link
Member

@oleg-nenashev oleg-nenashev left a 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 {
Copy link
Member

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)

@LegallGuillaume
Copy link
Contributor Author

@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

@LegallGuillaume
Copy link
Contributor Author

@oleg-nenashev did you tested this pull request ?

@oleg-nenashev
Copy link
Member

Nope, I have not. Sorry about the delay, there were lots of activities going in the Jenkins core and security releases.

@oleg-nenashev
Copy link
Member

I hope to find some time for the plugins on the weekend

@LegallGuillaume
Copy link
Contributor Author

No problem 👍 :)

Copy link
Member

@oleg-nenashev oleg-nenashev left a 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

@oleg-nenashev oleg-nenashev changed the title add GET and unassign to api Add GET Roles and UnassignRole to REST API Aug 15, 2017
@oleg-nenashev oleg-nenashev merged commit c693db0 into jenkinsci:master Aug 15, 2017
@ant-caichu
Copy link

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?

@LegallGuillaume
Copy link
Contributor Author

LegallGuillaume commented Sep 19, 2017

hi @hpejustin ,
it's

curl -X localhost:8080/role-strategy/strategy/getAllRoles

The maintener has forgotten 'get' in front of allRoles into the doc.

@oleg-nenashev
Copy link
Member

oleg-nenashev commented Sep 19, 2017

Hmm, allRoles should work as well... Maybe it depends on the Stapler version in the Jenkins core. @hpejustin which Jenkins version do you use?

@ant-caichu
Copy link

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.

@ant-caichu
Copy link

thanks all, i got the right result now, maybe some proxy reason, it is so nice of you all.

@fildaben
Copy link

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?

@LahariGuntha
Copy link

Hi,

Is there a rest api call to assign a particular role to a person in a particular project???

@oleg-nenashev
Copy link
Member

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?

I think we "just" need to implement export logic for that.

Is there a rest api call to assign a particular role to a person in a particular project???

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

@angbamfield
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants