Jenkins - Role based authentication - Sing up with default role - jenkins

I am setting up a Jenkins instance to run static-code-analysis for many projects. Each projects, on their own, create their code-analysis-jobs with their SCM and branches. I have the Role Strategy Plugin plugin installed but struck configuring the system with the below criteria.
The project leads should be able to signup the Jenkins and create/view/modify/run the jobs they only created. (Is it possible for this lead-role user to create user of developer role?)
The developers can view/build the jobs which they have privileges.
The project leads can assign the developers with jobs they can view/run.
How to do this, if at all possible? If not, how other ways you all do it considering the Jenkins to allow users signup, create/manage/run only their jobs (securing the jobs from other users)? (Also, the signed user should not be allowed to administer the Jenkins)
EDIT-1: I have an admin role (myself) user who has the all privileges to configure the system, but the admin to perform the role assignment of every user who signup.

The Role Strategy Plugin should suffice your request.
It even has regex pattern based setting where a user can only see certain projects.
I have been using this plugin extensively and its really helpful.

Related

What is the benefit of implementing Active Directory based Security to servers like Jenkins

What is the benefit of implementing Active Directory based Security to servers like Jenkins?
The only benefit I can think is the admin of the sever does not need to add/remove users because user can login themselves using AD credential.
But In my case I do not want to have the whole company access my server. the server is only used by my team. How can I disable the whole company from login in. (case1)
Besides, I want to grant different permissions to different members in my team. The new members get less permission, the experienced team members get more permissions. I believe this is very common. But using Active Directory based Security looks like they get the same permission because they are in the same groups (case2)
So why should I use Active Directory based Security? Can I resolve the above two cases in a server configured with Active Directory based Security?
Some corporate environments make this a security requirement. In said environments they usually have an internal request system where users can request they have their credentials added to an appropriate group for access to Jenkins. This is better than Jenkins own database and having them email you, the Jenkins administrator.
Once AD Authentication is configured in Jenkins and appropriate groups created in AD you can do a one-time setup of those groups with the Role-Based Strategy plugin in Jenkins and define what those groups have authorization to do.
Plan your groups well and it is a function that you will no longer have to worry about.
Warning: Be very careful when switching over from Jenkins own database user authentication to AD authentication. If you don't get the BindDN details just right you can get locked out.

Jenkins role / group based UI to isolate build jobs

We have got a requirement in Jenkins to our new instance, there are around 10 teams who use it and I'm looking if I could setup security strategy setup to separate out users:
Each team/group should be able to view/manage their own build jobs etc.
Should be able to manage their own transformations.
How can this be achieved?
Try Role Strategy Plugin.
From plugin info:
This plugin adds a new role-based strategy to ease and fasten users management. This strategy allows:
Creating global roles, such as admin, job creator, anonymous, etc., allowing to set Overall, Slave, Job, Run, View and SCM permissions on
a global basis.
Creating project roles, allowing to set only Job and Run permissions on a project basis.
Creating slave roles, allowing to set node-related permissions. Assigning these roles to users.
I would recommend Role-based Authorization Strategy plugin. I'm using it and it works well.
This plugin adds a new role-based strategy to ease and fasten users management. This > > strategy allows:
Creating global roles, such as admin, job creator, anonymous, etc.,
allowing to set > Overall, Slave, Job, Run, View and SCM permissions
on a global basis.
Creating project roles, allowing to set only Job
and Run permissions on a project basis.
Creating slave roles,
allowing to set node-related permissions.
Assigning these roles to
users

Jenkins - grant different permissions to different users

I want to be able to distinguish users who are permitted to execute builds on staging env from users who are permitted to deploy on prod.
Is there some kind of roles mechanism in Jenkins? I could not find any reference to it.
Thanks.
You use the Role Strategy plugin to do that.
In the Jenkins admin section, you can create project roles:
Next, you can affect these roles to users or groups (if you are using a user directory like LDAP):
I hope it will help :)

Security options in Jenkins

I am learning Jenkins and i am using version 1.605. I am learning about setting security options in jenkins. I found below options in jenkins configure global security page under the security realms:-
Delegate to servlet container
Jenkins'own user database
LDAP
I want to understand in which scenario, which option should be used?Please help me understand.
The "servlet container" refers to the web server that you are using to host Jenkins, typically Tomcat. The configuration file $CATALINA_BASE/conf/tomcat-users.xml may already be set up and managed by your organization. In this case: "why reinvent the wheel?". Use this if your organization already has a process that manages the Tomcat users configuration. This is also probably the most archaic solution.
The "own user database" is just what it sound like. Instead of relying on something else, Jenkins keeps it's own database of users. You can create and delete users through the Jenkins UI. You can even let new users sign up right from UI. If you don't know what to use, use this one. It's simple and self-contained.
The "LDAP" provides integration with LDAP/ Windows Active Directory. If you are in a corporate/small business environment that already utilizes LDAP for maintaining users and groups, it will be very beneficial to hook into that and off-load user management to the IT team that manages LDAP/AD. Note that unless you are that IT admin, you will need to contact the said admins for connection information/credentials to the LDAP/AD
Slav did a very clear answer.
If you choose the option 2 or 3, you can use the Role Stragegy plugin to create application roles and assign roles to Jenkins users, LDAP users or LDAP static/virtual groups.
If you have a lot of users, this plugin can save your life to assign permissions :)

How do I jenkins permission on a per job basis?

Some jobs push to QA and some jobs push to Production.
Only devs should be allowed to push to QA and only QA should be allowed to push to production. Aside from making two separate build servers (with some way to share artifacts) how do I restrict permissions?
You need Project-based Matrix Authorization Strategy in Global Configuration, and on the Job Configuration, use Enable Project-based Security.
It's all explained here
Standard Security Explained
You have to manage restrictions with the tools that Jenkins provides.
If you have administrator status go to "Jenkins configuration" (picture 1) and then to "Manage and assign roles" (picture 2). Here you will see "Manage roles" and "Assign roles".
Use "Manage roles" to create/update roles and assign permissions to determined projects and also to manage the restrictions of each job.
Use "Manage and Assign roles" to assign roles to users or to other groups.
Role/permission matrix:
Thus you can configure groups to administrate determined jobs, to execute other jobs or to simply have the ability to visit and see job details.
You can use matrix-based security to achieve this.
Make sure the user account is created
Do not add that user to the global configuration security but do have project matrix enabled security enabled and authenticated users read access
Now go to the job and add that user and choose read.
You can now see that the user has only access to that specific job
I just found the ownership based security method for doing per-job and per-node permissions. Not applicable in all situations but sometimes very useful - like when other teams are running few jobs on your team's instance.

Resources