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

Conversation

Projects
None yet
6 participants
@LegallGuillaume
Copy link
Contributor

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

This comment has been minimized.

Copy link
Contributor Author

LegallGuillaume commented Aug 3, 2017

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

@oleg-nenashev
Copy link
Member

oleg-nenashev left a comment

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 {

This comment has been minimized.

Copy link
@oleg-nenashev

oleg-nenashev Aug 3, 2017

Member

Probably should require POST as well since it may impact internal caching (when we have it, hehe)

@LegallGuillaume

This comment has been minimized.

Copy link
Contributor Author

LegallGuillaume commented Aug 3, 2017

@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

This comment has been minimized.

Copy link
Contributor Author

LegallGuillaume commented Aug 7, 2017

@oleg-nenashev did you tested this pull request ?

@oleg-nenashev

This comment has been minimized.

Copy link
Member

oleg-nenashev commented Aug 8, 2017

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

@oleg-nenashev

This comment has been minimized.

Copy link
Member

oleg-nenashev commented Aug 8, 2017

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

@LegallGuillaume

This comment has been minimized.

Copy link
Contributor Author

LegallGuillaume commented Aug 8, 2017

No problem 👍 :)

@oleg-nenashev
Copy link
Member

oleg-nenashev left a comment

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

@hpejustin

This comment has been minimized.

Copy link

hpejustin commented Sep 19, 2017

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

This comment has been minimized.

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

This comment has been minimized.

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?

@hpejustin

This comment has been minimized.

Copy link

hpejustin commented Sep 19, 2017

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.

@hpejustin

This comment has been minimized.

Copy link

hpejustin commented Sep 19, 2017

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

@fildaben

This comment has been minimized.

Copy link

fildaben commented Dec 14, 2017

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

This comment has been minimized.

Copy link

LahariGuntha commented Feb 13, 2018

Hi,

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

@oleg-nenashev

This comment has been minimized.

Copy link
Member

oleg-nenashev commented Feb 13, 2018

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

This comment has been minimized.

Copy link

angbamfield commented Mar 1, 2018

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
You can’t perform that action at this time.