Skip to content

Commit 3a88927

Browse files
committed
Added Jenkins CCPE E15, and removed Piwik Analytics
1 parent bc4d9a0 commit 3a88927

File tree

5 files changed

+217
-16
lines changed

5 files changed

+217
-16
lines changed

_includes/footer.html

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,3 @@ <h4 class="h h--3 tci">Do you enjoy our videos?</h4>
7070
</div>
7171
</div>
7272
</footer>
73-
74-
<!-- Piwik -->
75-
<script type="text/javascript">
76-
var _paq = _paq || [];
77-
_paq.push(['trackPageView']);
78-
_paq.push(['enableLinkTracking']);
79-
(function() {
80-
var u="//analytics.devopslibrary.com/";
81-
_paq.push(['setTrackerUrl', u+'piwik.php']);
82-
_paq.push(['setSiteId', 1]);
83-
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
84-
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
85-
})();
86-
</script>
87-
<noscript><p><img src="//analytics.devopslibrary.com/piwik.php?idsite=1" style="border:0;" alt="" /></p></noscript>
88-
<!-- End Piwik Code -->
Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
---
2+
layout: post
3+
title: "CCJPE: Jenkins Security"
4+
date: 2016-10-09 12:00:00 -0500
5+
categories: Jenkins
6+
permalink: lessons/jenkins-security
7+
excerpt: "Authentication, Authorization, and RBAC!"
8+
weight: 14
9+
image: 'jenkinscourse.png'
10+
difficulty: easy
11+
12+
---
13+
{% include youtube.html id="1EUcbsychVc" %}
14+
{% include hired3.html %}
15+
16+
1. Table of Contents
17+
{:title="Table of Contents"}
18+
{:toc}
19+
20+
Cloud Config File Downloads
21+
---------------------------
22+
* [Jenkins Master01](https://www.devopslibrary.com/scripts/master01.yaml)
23+
24+
Introduction
25+
------------
26+
Welcome to the DevOps Library, this is Samantha, and in today's lesson we're
27+
going to talk about securing Jenkins, including the difference between
28+
[authentication and authorization](http://searchsecurity.techtarget.com/definition/authentication-authorization-and-accounting),
29+
how to set up different types of [security realms](https://wiki.jenkins-ci.org/display/JENKINS/Securing+Jenkins),
30+
using AD for authentication, and even how to use the Jenkins Role-based access
31+
plugin!
32+
33+
Before we begin though, we'd like to give a quick shout out to
34+
[Hired.com](hired.com/devopslibrary) for being kind enough to sponsor our
35+
Jenkins course. If you aren’t familiar with Hired, it’s a great company that
36+
completely reverses the traditional job search, by having companies apply to
37+
you, instead of you always doing the tedious work of applying.
38+
39+
Thousands of companies look to Hired to connect with the best of the best in our
40+
field, like you! OH.  And if you do end up signing up through our personal link,
41+
and landing a new job, Hired will give you a 2k bonus for being a loyal
42+
supporter of the DevOps library!
43+
44+
3 A's of Security
45+
-----------------
46+
![3As](/images/JenkinSecurity2.png)
47+
48+
Alright, let's begin by talking about the three "A's" of security:
49+
**authentication**, **authorization**, and **auditing**.
50+
- **Authentication** is simply the process of proving that someone is who they
51+
say they are.
52+
- **Authorization** is the process of determining what someone is allowed to do
53+
after they've authenticated.
54+
- **Auditing** is the process of creating a record of everything that happens,
55+
along with who did what.
56+
57+
In this lesson we're going to focus mainly on configuring authentication and
58+
authorization.
59+
60+
Implementing Security in Jenkins
61+
--------------------------------
62+
Let's go ahead and see how to implement these concepts within Jenkins. Pull up
63+
a Jenkins master, then head to "Manage Jenkins", followed by "Configure Global
64+
Security". Alright, first, we'll want to enable security, so go ahead and check
65+
the box if it isn't already.
66+
67+
![Security Realm](/images/realm.png)
68+
69+
Next, we need to choose a security realm, which
70+
is used for the authentication step, so verifying the user, their password, and
71+
what group they belong to is all part of it. As most companies use Active
72+
Directory, we'll use that and go ahead and type our Domain Name in. Make sure
73+
you've set up DNS so that your Jenkins master can resolve the domain, then go
74+
ahead and click "Test" to verify that the connection worked.
75+
76+
Alright, now before we move on, make sure you log into a domain account (or
77+
whatever realm you chose), then return back to the global security page.
78+
79+
Next, it's time to decide on which authorization strategy we'd like to use.
80+
81+
Authorization Strategies
82+
------------------------
83+
- **Anyone can do anything** is pretty self explanatory.
84+
- **Legacy mode** isn't much more useful, as it only gives you two levels of
85+
access, "admin" which has full control, and everyone else (including anonymous
86+
users) have read only.
87+
- **Logged-in users can do anything** is only useful if you'd like everyone to
88+
have auditable admin access, and probably isn't very useful outside of smaller
89+
teams.
90+
- **Matrix-based security** is about the best you can get in the open source
91+
edition of Jenkins, as it really lets you get pretty granular on the
92+
permissions. Let's go ahead and take a look at it real quick. See this really
93+
long line with all the checkboxes? That's how we assign permissions to each
94+
user. While it is extremely granular, you can't assign different rights to
95+
different jobs.
96+
- The **Project-based Matrix Authorization Strategy** is exactly the same, as
97+
the normal matrix-based option, but lets you specify different permissions on
98+
each job's configuration page. You can certainly get by for awhile using this
99+
option, but it does become pretty cumbersome as there's no way to manage groups
100+
of projects.
101+
- Lastly we have the **Role-Based Matrix Authorization Strategy**, which is
102+
unfortunately only available in the enterprise version of Jenkins, but it's
103+
definitely the most flexible and easiest to manage as your team scales.
104+
105+
Role Based Access Strategy
106+
--------------------------
107+
For this lesson, let's go with "Role-Based", as it can do everything the other
108+
models can do and more, and it's also heavily targeted on the Jenkins
109+
certification exams. You'll notice that when you select it, an
110+
"Import Strategy" dropdown appears. Change it to "Typical Initial Setup", then
111+
hit "Save". If you didn't see the initial setup dropdown, make sure you're
112+
logged in otherwise it won't be available. It automatically creates a group of
113+
administrators, of which initially you'll be the only member, as well as a
114+
"Developers" group, and "Browsers" group. Speaking of groups, check out the
115+
menu on the side. We have two new items, one for managing "Groups", and another
116+
for "Roles".
117+
118+
New Terminology
119+
---------------
120+
Before we keep going, let's cover some new terminology.
121+
122+
- A **local group** refers to a set of users, external groups, or even other
123+
local groups, and are defined by the Jenkins RBAC plugin that we're now using.
124+
To manage them, click the "**Groups**" link on the left. Here you can see our
125+
three new groups created by the initial configuration.
126+
- An **external group** also refers to a group of users, but one that is defined
127+
outside of Jenkins, like an Active Directory Group.
128+
- A **permission** is the right to do something, such as starting a job or
129+
creating a new project.
130+
- A **role** is simply a collection of permissions, which makes them MUCH easier
131+
to manage. Let's check them out real quick, go to "Manage Jenkins", followed by
132+
"Manage Roles". On the left side of the table, you can see the names of our
133+
roles, and on the right we can assign permissions to each of them. See the
134+
little green hat by "anonymous" and "authenticated"? That's because those two
135+
roles are built into Jenkins, so you won't be able to delete them. The rest
136+
were all created by the initial setup wizard, so you can do whatever you'd like
137+
with them.
138+
- Lastly, we have **role filters**, which are used at the job level to prevent
139+
roles from being propagated. As an example, let's take our "Browse" group,
140+
whose members have read access to everything, and create a job that they can't
141+
see. To do so, click the job, go to "Roles", followed by "Filter", and set
142+
"Require Explicit Assignment" on the "browse" role. Pretty useful huh?
143+
144+
Real World Use Case
145+
-------------------
146+
Well that's enough new terminology for now, let's try out an actual real world
147+
use case. Pretend we have a QA team that need to be able to create, configure,
148+
and build any job that they'd like. However, we also want to ensure that
149+
they're not able to access anything outside of the jobs that they create for QA
150+
purposes. Don't worry, it's really easy.
151+
152+
First, hop on the domain controller that Jenkins is using for authentication.
153+
Once there, open up Active Directory and add a QA user, we'll name ours
154+
QAUser01. Next, we need to create a security group, let's go with Jenkins-QA.
155+
Now add QAUser01 to the Jenkins-QA group, then switch back to Jenkins.
156+
157+
![Groups](/images/groups.png)
158+
159+
Alright, let's log out and try logging back in with our QAUser01 account.
160+
Oops! While we were able to authenticate ok, our QA User isn't authorized to
161+
do anything yet. Let's switch back to the admin account.
162+
163+
Ok, go to "Manage Jenkins", followed by "Manage Roles". On this page, click
164+
the checkbox for "Overall Read" access for authenticated users, then hit save.
165+
We're giving that to every logged in user as it's the absolute bare minimum
166+
required to successfully open the Jenkins dashboard without an error. Go ahead
167+
and head back to the main Jenkins Dashboard, that way we can create a safe place
168+
for our QA team.
169+
170+
Granting Access to a Folder
171+
---------------------------
172+
Thankfully, the RBAC plugin combines easily with the "Folders" plugin, so we'll
173+
create a "QA" folder which we'll then give full access to the QA team to use.
174+
After creating the folder, select it, then go to "Groups" on the left side of
175+
the page. Next, click "New Quick Group", name it QA Team, and choose
176+
"administrator" for the role, then click "Ok.". On the next page, click "Add
177+
user/group". Remember that external group we just added in Active Directory?
178+
Let's go ahead and type it in here, that way our local Jenkins Group knows which
179+
group of users in AD to provide access to, then hit Ok.
180+
181+
Perfect! Log back in as QAUser01 and check it out. Great job!!! We were able
182+
to successfully set up a new external group in Active Directory, a new local
183+
group on Jenkins, and our QA team is now able to do whatever they'd like without
184+
being able to mess up any other team's jobs in Jenkins.
185+
186+
Conclusion
187+
----------
188+
That’s it for our lesson on Jenkins Security, thank you for watching! We’d like
189+
to give another shout out to Hired for sponsoring this course. If you’re into
190+
DevOps, there’s a pretty good chance you’ve had to deal with pushy recruiters
191+
and countless emails, as well as spent many hours searching for DevOps
192+
opportunities.
193+
194+
The reason we love using Hired is that it completely reverses this situation and
195+
puts the power back in your hands, by having companies send you interview
196+
requests that you can choose to pursue. (They even come with upfront salary
197+
and equity!)
198+
199+
By having you fill out information that is specific to what you’re looking for
200+
and your individual strengths and talents, it ensures that the only companies
201+
you’ll hear from will be a great fit for you. Plus, Hired is entirely free, and
202+
they’ll even give you a $2,000 bonus after you land a job, using our DevOps
203+
Library link!
204+
205+
We highly recommend giving them a shot, they do a fantastic job, especially for
206+
the DevOps community.
207+
208+
If you like our videos, please subscribe to our Youtube channel! If you love
209+
them and want to help support us, visit patreon.com/devopslibrary, we’ll even
210+
list you on our high scores at the end of each video. Thanks again, we'll see
211+
you again soon!
212+
213+
Thanks for Watching!
214+
--------------------
215+
[Subscribe to our YouTube channel](https://www.youtube.com/channel/UCOnioSzUZS-ZqsRnf38V2nA?sub_confirmation=1) or follow [DevOpsLibrary on Twitter](https://twitter.com/intent/user?screen_name=devopslibrary).
216+
217+
{% include subscribe.html %}

images/JenkinSecurity2.png

2.57 MB
Loading

images/groups.png

128 KB
Loading

images/realm.png

84.3 KB
Loading

0 commit comments

Comments
 (0)