-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
362 lines (309 loc) · 15.5 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>OAuth 2.0 - Grand Types and Associated Workflows</title>
<meta name="author" content="Charles Sarrazin">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="css/reveal.min.css">
<link rel="stylesheet" href="css/theme/solarized.css" id="theme">
<!-- For syntax highlighting -->
<link rel="stylesheet" href="lib/css/zenburn.css">
<!-- If the query includes 'print-pdf', include the PDF print sheet -->
<script>
if( window.location.search.match( /print-pdf/gi ) ) {
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = 'css/print/pdf.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
}
</script>
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<section>
<h1>OAuth 2.0</h1>
<h3>Grant types and associated workflows</h3>
<p>
<small>Created by Charles Sarrazin / <a href="http://twitter.com/csarrazi">@csarrazi</a></small>
</p>
</section>
<section>
<section>
<h2>What is OAuth 2.0?</h2>
<p>
OAuth 2.0 is the next evolution of the OAuth protocol which was originally created in late 2006.
</p>
</section>
<section>
<h2>What OAuth 2.0 focuses on</h2>
<p>
<ul>
<li>Client developer simplicity</li>
<li>Specific authorization flows for:
<ul>
<li>web applications</li>
<li>desktop applications</li>
<li>mobile phones</li>
<li>living room devices</li>
</ul>
</li>
</ul>
</p>
</section>
</section>
<section>
<section>
<h2>Authentication</h2>
</section>
<section>
<h3>Browser-based or mobile applications</h3>
<p>Authentication is accomplished by displaying an interface provided by the service to the user</p>
<img src="images/authentication_fb.png" alt="Facebook">
<img src="images/authentication.png" alt="Facebook">
</section>
<section>
<h3>Authorize access to the information (scopes)</h3>
<p>Scopes let the user authorize or deny access to specific information. Some implementation let the user chose which information he wishes to share (facebook, for example).</p>
<img src="images/authorization_fb.png" alt="Authorization">
<img src="images/authorization.png" alt="Authorization">
</section>
<section>
<h3>Other applications</h3>
<p>Authentication can be accomplished using client credentials, or username and password</p>
</section>
</section>
<section>
<section>
<h2>Grant types</h2>
</section>
<section>
<h3>Default grant types</h3>
<ul>
<li><strong>Authorization Code</strong> for apps running on a web server</li>
<li><strong>Implicit</strong> for browser-based or mobile apps</li>
<li><strong>Password</strong> for logging in with a username and password</li>
<li><strong>Client credentials</strong> for application access</li>
<li><strong>Refresh token</strong> for simplifying user re-authentication</li>
</ul>
</section>
</section>
<section>
<section>
<h2>Authorization Code workflow</h2>
<h3>(3-legged authorization flow)</h3>
</section>
<section>
<h3>Schema</h3>
<img src="images/3_legged.png" alt="Authorization code">
</section>
<section>
<h3>Redirection to the provider</h3>
<ul>
<li>response_type (mandatory)</li>
<li>client_id (mandatory)</li>
<li>scope (mandatory)</li>
<li>redirect_uri (mandatory)</li>
<li>state (optional, think CSRF)</li>
</ul>
<pre><code class="http" data-trim>GET /oauth/authorize
?response_type=code
&client_id=0d5e5af7-420c-4241-8cff-0cfd9d806e59
&scope=profile%20email
&state=48389488
&redirect_uri=https%3A%2F%2Fwww.example.com%3A8443%2Fcallback
Host: server.example.com</code></pre>
</section>
<section>
<h3>Redirection to the client</h3>
<pre><code class="http" data-trim>HTTP/1.1 302 Found
Location: https://server2.example.com
?code=MF2AAQGBBlpxSGUtUYJQo2oB1p1kw3CNcM5QRmok-vzKYVltlykXrZE2AG0F3J3mQjUYOSP3dCOaIeYEUWSKm4QVx6mCTmT9gztIn45K9KKJ22p8IiJHiLXGEg2oUV
&state=48389488</code></pre>
<p>The code should be used by the client to retrieve an access token</p>
</section>
<section>
<h3>Retrieve an access token with the code</h3>
<p>Issue a <code>POST</code> request to <code>/auth/token</code> with the code, redirect_uri and authorization_code grant_type, using Basic authentication</p>
<pre><code class="http" data-trim>POST /oauth/token HTTP/1.1
Host: server.example.com
Content-Type: application/w-www-form-urlencoded
Authorization: Basic <Base64-encoded client_id:client_secret>
grant_type=authorization_code
&code=MF2AAQGBBlpxSGUtUYJQo2oB1p1kw3CNcM5QRmok-vzKYVltlykXrZ E2AG0F3J3mQjUYOSP3dCOaIeYEUWSKnav_aXvvyuxT3ogtZT-dgNZEnk6X0XaoPf6BVlVRibA
&redirect_uri=https%3A%2F%2Fserver2%2Eexample%2Ecom</code></pre>
<pre><code class="http" data-trim>HTTP/1.1 200 OK
Cache-Control: no-store
Pragma: no-cache
Content-Type: applicaton/json;charset=UTF-8 Transfer-Encoding: chunked
Server: Jetty(8.1.12.v20130726)
{
"access_token":"MF2AAQGBBlpxSGUtUYJQo2oB1p1kw3CNcM5QRmok-vzKYVltlykXrZE2AG0F3J3mQjUYOSP3dCOaIeYEUWSKMYeiJy-24paR9YLEZpKDc-mwlE4ML8LRqAyhPMtAoBA",
"token_type":"bearer",
"expires_in":41558,
"scope":"email profile"
}</code></pre>
</section>
<section>
<h3>Make requests using the access token</h3>
<pre><code class="http" data-trim>GET /api/me HTTP/1.1
Host: server.example.com
Authorization: Bearer MF2AAQGBBlpxSGUtUYJQo2oB1p1kw3CNcM5QRmok-vzKYVltlykXrZE2AG0F3J3mQjUYOSP3dCOaIeYEUWSKMYeiJy-24paR9YLEZpKDc-mwlE4ML8LRqAyhPMtAoBA</code></pre>
<p>Beware, Apache users!</p>
<p>Apache removes all authorization headers that it doesn't recognize from the request's headers.</p>
<p>Authorization header won't be found in <code>$_SERVER['HTTP_AUTHORIZATION']</code>.</p>
<p>You will need to use the <code>apache_request_headers()</code> function.</p>
</section>
</section>
<section>
<section>
<h2>Implicit workflow</h2>
<h3>(2-legged authorization flow)</h3>
</section>
<section>
<h3>Schema</h3>
<img src="images/2_legged.png" alt="Implicit">
</section>
<section>
<h3>Redirection to the provider</h3>
<ul>
<li>response_type (mandatory)</li>
<li>client_id (mandatory)</li>
<li>scope (mandatory)</li>
<li>redirect_uri (mandatory)</li>
<li>state (optional, think CSRF)</li>
</ul>
<pre><code class="http" data-trim>GET /oauth/authorize
?response_type=token
&client_id=0d5e5af7-420c-4241-8cff-0cfd9d806e59
&scope=profile%20email
&state=48389488
&redirect_uri=https%3A%2F%2Fwww.example.com%3A8443%2Fcallback
Host: server.example.com</code></pre>
</section>
<section>
<h3>Redirection to the client</h3>
<pre><code class="http" data-trim>HTTP/1.1 302 Found
Location: https://server2.example.com
#access_token=1MF2AAQGBBlpxSGUtUYJQo2oB1p1kw3CNcM5QRmok-vzKYVltlykXrZE2AG0F3J3mQjUYOSP3dCOaIeYEUWSKMYeiJy-24paR9YLEZpKDc-mwlE4ML8LRqAyhPMtAoBA
&token_type=bearer
&state=4848573984983
&expires_in=43062</code></pre>
<p>Note that the access token information is sent through the hash, which is not transferrable to any webserver.</p>
</section>
<section>
<h3>Make requests using the access token</h3>
<pre><code class="http" data-trim>GET /api/me HTTP/1.1
Host: server.example.com
Authorization: Bearer 1MF2AAQGBBlpxSGUtUYJQo2oB1p1kw3CNcM5QRmok-vzKYVltlykXrZE2AG0F3J3mQjUYOSP3dCOaIeYEUWSKMYeiJy-24paR9YLEZpKDc-mwlE4ML8LRqAyhPMtAoBA</code></pre>
</section>
</section>
<section>
<section>
<h2>Password</h2>
</section>
<section>
<h3>Schema</h3>
<img src="images/password.png" alt="Password">
</section>
<section>
<h3>Retrieve an access token with the user's credentials</h3>
<pre><code class="http" data-trim>POST /oauth/token?grant_type=password&username=marysmith&password=123456
Host: server.example.com
Authorization: Basic <Base64-encoded client_id:client_secret>
Content-Type: application/w-www-form-urlencoded</code></pre>
<pre><code class="http" data-trim>HTTP/1.1 200 OK
Cache-Control: no-store
Pragma: no-cache
Content-Type: applicaton/json;charset=UTF-8 Transfer-Encoding: chunked
Server: Jetty(8.1.12.v20130726)
{
"access_token":"MF2AAQGBBlpxSGUtUYJQo2oB1p1kw3CNcM5QRmok-vzKYVltlykXrZE2AG0F3J3mQjUYOSP3dCOaIeYEUWSKMYeiJy-24paR9YLEZpKDc-mwlE4ML8LRqAyhPMtAoBA",
"token_type":"bearer",
"expires_in":41558,
"scope":"profile"
}</code></pre>
</section>
</section>
<section>
<section>
<h2>Client credentials</h2>
</section>
<section>
<h3>Schema</h3>
<img src="images/client_credentials.png" alt="Client credentials">
</section>
<section>
<h3>Retrieving an access token with the client's credentials</h3>
<pre><code class="http" data-trim>POST /oauth/token?grant_type=client_credentials Host: server.example.com
Authorization: Basic czQER9k3dD94aIdplr957Udk8 Content-Type: application/w-www-form-urlencoded</code></pre>
<pre><code class="http" data-trim>HTTP/1.1 200 OK
Cache-Control: no-store
Pragma: no-cache
Content-Type: applicaton/json;charset=UTF-8
Transfer-Encoding: chunked
Server: Jetty(8.1.12v20130726)
{
"access_token": "MF2AAQGBBlpxSGUtUYJQo2oB1p1kw3CNcM5QRmok-vzKYVltlykXrZE2AG0F3J3mQjUYOSP3dCOaIeYEUWSKFEDrIpaEn5N9MfAm1BjZ5OYLHu0L823L2JsMn7i2wug",
"token_type": "bearer",
"expires_in": 42203,
"scope": "profile"
}</code></pre>
</section>
</section>
<!--
<section>
<section>
<h2>Refresh token</h2>
</section>
<section>
<h3>Schema</h3>
<img src="images/refresh_token.png" alt="Refresh token">
</section>
</section>
-->
<section>
<h1>Questions?</h1>
</section>
<section>
<h1>That's all, folks!</h1>
<h3>By Charles Sarrazin / @csarrazi</h3>
</section>
</div>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.min.js"></script>
<script>
// Full list of configuration options available here:
// https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
history: true,
center: true,
theme: Reveal.getQueryHash().theme, // available themes are in /css/theme
transition: Reveal.getQueryHash().transition || 'default', // default/cube/page/concave/zoom/linear/fade/none
// Parallax scrolling
// parallaxBackgroundImage: 'https://s3.amazonaws.com/hakim-static/reveal-js/reveal-parallax-1.jpg',
// parallaxBackgroundSize: '2100px 900px',
// Optional libraries used to extend on reveal.js
dependencies: [
{ src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: 'plugin/zoom-js/zoom.js', async: true, condition: function() { return !!document.body.classList; } },
{ src: 'plugin/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } }
]
});
</script>
</body>
</html>