forked from nbenbarak-okta/okta.github.io-1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpysaml2.html
More file actions
718 lines (416 loc) · 28.6 KB
/
Copy pathpysaml2.html
File metadata and controls
718 lines (416 loc) · 28.6 KB
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
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
<!doctype html>
<html class="no-js" lang="en" dir="ltr">
<head>
<script>
var searchDomain = 'https://developer.okta.com';
var isProduction = window.location.hostname === 'developer.okta.com';
if (isProduction) {
// TypeKit
(function(d) {
var config = {
kitId: 'jff5neq',
scriptTimeout: 3000,
async: true
},
h=d.documentElement,t=setTimeout(function(){h.className=h.className.replace(/bwf-loadingb/g,"")+" wf-inactive";},config.scriptTimeout),tk=d.createElement("script"),f=false,s=d.getElementsByTagName("script")[0],a;h.className+=" wf-loading";tk.src='https://use.typekit.net/'+config.kitId+'.js';tk.async=true;tk.onload=tk.onreadystatechange=function(){a=this.readyState;if(f||a&&a!="complete"&&a!="loaded")return;f=true;clearTimeout(t);try{Typekit.load(config)}catch(e){}};s.parentNode.insertBefore(tk,s)
})(document);
// Google analytics
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-15777010-3', 'auto');
ga('send', 'pageview');
// START Google Tag Manager
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-TJ45R6');
// END Google Tag Manager
}
</script>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="IE=edge,chrome=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link type="text/css" rel="stylesheet" href="https://developer.okta.com/sites/all/themes/developer/css/master.css" media="all" />
<meta class="swiftype" name="title" data-type="string" content="Python | Okta Developer" />
<meta class="swiftype" name="summary" data-type="string" content="Guidance on how to SAML-enable your Python application using open source PySAML2." />
<link type="text/css" rel="stylesheet" href="/assets/animate-ec43d72c3ed45e08a460b8a2966d8dba6006aebfa0530935c3973fa493a8771f.css">
<link type="text/css" rel="stylesheet" href="/assets/okta-e0a2f1567b2617a1ac64c3cfe8f94086456f3fb4e1a8ae52fe18398b4ad2ee3f.css">
<link rel="shortcut icon" type="image/vnd.microsoft.icon" href="/favicon.ico">
<title>Python | Okta Developer</title>
<meta name="description" content="Guidance on how to SAML-enable your Python application using open source PySAML2.">
<link rel="canonical" href="https://developer.okta.com/code/python/pysaml2">
<link rel="alternate" type="application/rss+xml" title="Okta Developer" href="https://developer.okta.com/feed.xml"><!-- GA -->
</head>
<body>
<div class="Page Page--docs-page">
<!-- START Header -->
<header class="Header is-fixed">
<div class="Wrap">
<a class="Logo" href="https://developer.okta.com">
<svg version="1.1" id="OktaLogo" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 431.9 151.4" style="enable-background:new 0 0 431.9 151.4;" xml:space="preserve"><g><g><g><path d="M102.2,41.4c-21,0-38.1,17.1-38.1,38.1s17.1,38.1,38.1,38.1s38.1-17.1,38.1-38.1l0,0C140.3,58.5,123.2,41.4,102.2,41.4z M102.2,98.5c-10.5,0-19-8.5-19-19s8.5-19,19-19s19,8.5,19,19c0.1,10.5-8.4,19-18.9,19.1C102.3,98.6,102.2,98.6,102.2,98.5L102.2,98.5z"/><path d="M169.1,92.3c0-1.9,1.5-3.4,3.4-3.4c0.9,0,1.8,0.4,2.4,1c9.5,9.7,25.3,26.3,25.4,26.4c0.4,0.5,0.8,0.8,1.4,0.9l1.6,0.2h17.2c1.8,0,3.3-1.4,3.4-3.2c0-0.8-0.3-1.5-0.8-2.2l-28.6-29.2l-1.5-1.5c-3.2-3.9-2.9-5.4,0.8-9.3l22.6-25.1c1.1-1.4,0.8-3.5-0.6-4.6c-0.6-0.4-1.3-0.7-2-0.7h-17c-0.6,0.2-1.1,0.5-1.5,0.9L175,64.4c-1.3,1.4-3.4,1.5-4.8,0.2c-0.7-0.6-1.1-1.5-1.1-2.5V18.9c0-1.7-1.3-3-3-3c-0.1,0-0.2,0-0.3,0h-12.7c-2.2,0-3.3,1.5-3.3,2.8v95.8c0,2.2,1.8,2.8,3.3,2.8h12.7c1.7,0.1,3.2-1.2,3.3-2.9c0,0,0,0,0,0V92.3z"/><path d="M273,114l-1.4-12.8c-0.2-1.7-1.7-2.9-3.4-2.7c0,0,0,0-0.1,0l-2.9,0.2c-10.1,0-18.5-7.9-19-18c0-0.3,0-0.7,0-1V64.2c-0.1-2,1.5-3.6,3.5-3.7c0,0,0,0,0,0h17c1.7-0.1,3.1-1.5,3-3.2c0,0,0-0.1,0-0.1v-12c0-2.3-1.5-3.6-2.8-3.6h-17.1c-1.9,0.1-3.5-1.5-3.6-3.4c0,0,0,0,0,0V18.9c-0.1-1.7-1.5-3.1-3.2-3c0,0-0.1,0-0.1,0h-12.7c-1.6-0.1-3,1.1-3.1,2.7c0,0.1,0,0.1,0,0.2c0,0,0,61.7,0,62c0.5,21,17.9,37.6,38.9,37c1.4,0,2.9-0.2,4.3-0.3C272,117.2,273.2,115.7,273,114z"/></g><path d="M364.7,98c-10.8,0-12.4-3.8-12.4-18.3l0,0V44.8c0-1.8-1.4-3.2-3.2-3.2c0,0-0.1,0-0.1,0h-12.8c-1.8,0-3.2,1.4-3.3,3.2v1.6C314.6,36,291.3,42.5,281,60.8c-10.4,18.3-3.9,41.6,14.4,51.9c14,7.9,31.4,6.2,43.5-4.2c3.6,5.5,9.3,9.1,18.3,9.1c1.5,0,9.7,0.3,9.7-3.5v-13.6C367,99.2,366,98.1,364.7,98z M314.2,98.6c-10.5,0-19-8.5-19-19s8.5-19,19-19s19,8.5,19,19l0,0C333.2,90.1,324.7,98.6,314.2,98.6z"/></g><path d="M19.4,74c2.2-1.9,4.1-4.1,5.7-6.6c3.5-5.3,5.4-11.5,5.2-17.9V27c0-4.9,0.9-8.4,2.7-10.5c1.8-2.1,4.8-3,9.2-3h12.6c1.2,0,2.1-0.9,2.2-2.1l0,0V2.2C57,1,56,0,54.8,0c0,0,0,0,0,0H41.5c-7.8,0-12.9,2.1-18,7.6s-7.1,12.3-7.1,21.7v14.2c0,2.2-0.1,4-0.2,5.7v2.2c-0.5,3.2-1.8,6.2-3.6,8.9C9.4,64.7,5.1,70.9,0.9,74l0,0l-0.3,0.3l0,0l-0.2,0.3H0.2v0.3l0,0c-0.1,0.3-0.1,0.7,0,1l0,0v0.3h0.1l0.2,0.3l0,0l0.3,0.3l0,0c4.2,3.1,8.5,9.3,11.3,13.7c1.8,2.7,3.1,5.7,3.6,8.9v2.2c0.1,1.6,0.2,3.5,0.2,5.7v14.3c0,9.4,2.4,16.7,7.1,21.7s10.2,7.6,18,7.6h13.8c1.2,0,2.2-1,2.2-2.2V140l0,0c0-1.2-1-2.2-2.2-2.2H42.2c-4.4,0-7.5-1-9.2-3s-2.7-5.6-2.7-10.5v-22.4c0.2-6.4-1.7-12.6-5.2-17.9c-1.6-2.5-3.5-4.7-5.7-6.6l0,0c-0.9-0.7-1.1-2-0.4-2.9C19.2,74.3,19.3,74.2,19.4,74L19.4,74z"/><path d="M412.5,74c-2.2-1.9-4.1-4.1-5.7-6.6c-3.5-5.3-5.4-11.5-5.2-17.9V27c0-4.9-0.9-8.4-2.7-10.5s-4.8-3-9.2-3h-12.6c-1.2,0-2.2-1-2.2-2.2c0,0,0,0,0,0l0,0V2.2c0-1.2,1-2.2,2.2-2.2c0,0,0,0,0,0h13.4c7.8,0,12.9,2.1,18,7.6s7.1,12.3,7.1,21.7v14.2c0,2.2,0.1,4,0.2,5.7v2.2c0.5,3.2,1.8,6.2,3.6,8.9c2.8,4.5,7.1,10.7,11.3,13.7l0,0l0.3,0.3l0,0l0.2,0.3h0.1v0.3l0,0c0.1,0.3,0.1,0.7,0,1l0,0v0.3h-0.1l-0.2,0.3l0,0l-0.3,0.3l0,0c-4.2,3.1-8.5,9.3-11.3,13.7c-1.8,2.7-3.1,5.7-3.6,8.9v2.2c-0.1,1.6-0.2,3.5-0.2,5.7v14.3c0,9.4-2.4,16.7-7.1,21.7s-10.2,7.6-18,7.6h-13.4c-1.2,0-2.2-1-2.2-2.2c0,0,0,0,0,0V140l0,0c0-1.2,1-2.2,2.2-2.2l0,0h12.7c4.4,0,7.5-1,9.2-3s2.7-5.6,2.7-10.5v-22.4c-0.2-6.3,1.6-12.6,5.1-17.9c1.6-2.5,3.5-4.7,5.7-6.6l0,0c0.9-0.7,1.1-2,0.4-2.9C412.7,74.3,412.6,74.2,412.5,74L412.5,74z"/></g></svg>
</a>
<nav class="Header-nav PrimaryNav">
<ul class="menu">
<li class="first leaf">
<a href="https://developer.okta.com/product/">Product</a>
</li>
<li class="leaf">
<a href="https://developer.okta.com/pricing/">Pricing</a>
</li>
<li class="leaf">
<a href="/blog/">Blog</a>
</li>
<li class="leaf">
<a href="/documentation/" class="active">Docs</a>
</li>
<li class="last expanded">
<span class="nolink">Support</span>
<ul class="menu">
<li class="first leaf"><a href="https://devforum.okta.com/">Okta Developer Forums</a></li>
<li class="last leaf"><a href="mailto:developers@okta.com">developers@okta.com</a></li>
</ul>
</li>
</ul>
<a class="PrimaryNav-toggle" href="#">
<svg width="20px" height="20px" viewBox="0 0 20 20" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g class="MenuIcon" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" stroke-linecap="round">
<path d="M1,16 L19,16" class="MenuIcon-line1" stroke="#FFFFFF" stroke-width="2"></path>
<path d="M1,4 L19,4" class="MenuIcon-line2" stroke="#FFFFFF" stroke-width="2"></path>
<path d="M1,10 L19,10" class="MenuIcon-line3" stroke="#FFFFFF" stroke-width="2"></path>
<path d="M1,10 L19,10" class="MenuIcon-line4" stroke="#FFFFFF" stroke-width="2"></path>
</g>
</svg>
<svg class="CloseIcon" width="16px" height="16px" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="ALl-Boards" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="Desktop" transform="translate(-915.000000, -235.000000)" fill="#FFFFFF">
<g id="Search-bar-Active" transform="translate(30.000000, 26.000000)">
<polygon id="Icon/Cross" points="901 210.6 899.4 209 893 215.4 886.6 209 885 210.6 891.4 217 885 223.4 886.6 225 893 218.6 899.4 225 901 223.4 894.6 217"></polygon>
</g>
</g>
</g>
</svg>
</a>
<div class="PrimaryNav-cta">
<a href="https://developer.okta.com/signup/" class="Button--red">Sign up</a>
</div>
<a class="SearchIcon" href="#"></a>
<form id="form_search" class="SearchBar Formisimo_clocked_69929" method="get" action="https://developer.okta.com/search/" name="form_search" __bizdiag="-784164280" __biza="WJ__">
<input type="text" name="stq" autocomplete="off" id="st-search-input-auto" class="st-search-input" placeholder="Search">
<input type="submit" name="submit" value="GO">
</form>
</nav>
</div>
</header>
<!-- END Header -->
<!-- START Page Center w/Sub Nav & Content -->
<section class="PageContent DynamicSidebar has-tableOfContents">
<!-- START Fixed sidebar -->
<aside class="Sidebar">
<h2 class="Sidebar-location Sidebar-toggle h6">Navigation</h2>
<div class="Sidebar-close Sidebar-toggle"></div>
<div>
<h3 class="Sidebar-title">Client Integrations</h3>
<ul class="Sidebar-nav">
<li >
<a href="/code/angular/">ANGULAR</a>
</li>
<li >
<a href="/code/ios/">IOS</a>
</li>
<li >
<a href="/code/javascript/">JAVASCRIPT</a>
</li>
<li >
<a href="/code/react/">REACT</a>
</li>
</ul>
<h3 class="Sidebar-title">Server Integrations</h3>
<ul class="Sidebar-nav">
<li >
<a href="/code/dotnet/">.NET</a>
</li>
<li >
<a href="/code/java/">JAVA</a>
</li>
<li >
<a href="/code/nodejs/">NODE.JS</a>
</li>
<li >
<a href="/code/php/">PHP</a>
</li>
<li class="is-active">
<a href="/code/python/">PYTHON</a>
</li>
</ul>
</div>
</aside>
<!-- END Fixed sidebar -->
<!-- START Page Content -->
<div class="PageContent-main">
<h1 id="overview">Overview</h1>
<p>This guide describes how to use <a href="https://github.com/rohe/pysaml2">PySAML2</a> to add support
for Okta (via SAML) to applications written in Python. Please note that while the example in this guide uses
<a href="http://flask.pocoo.org/">Flask</a>, the concepts presented here are general enough to use in other Python frameworks.</p>
<p>This guide describes how to install and configure an example
application that demonstrates how to use PySAML2 in a Flask application.
After you have Okta working with the example application,
adapt the example code for your production environment.</p>
<blockquote>
<p>Note: The library is not Okta’s and is not supported by Okta.</p>
</blockquote>
<p>This guide assumes that you are familiar with the basics of Python
software development: using the command line, editing text files,
using <a href="https://virtualenv.pypa.io/en/latest/">virtualenv</a>, and using
<a href="https://en.wikipedia.org/wiki/Pip_%28package_manager%29">pip</a>.</p>
<p>If you’re already familiar with Okta, you can skip to the
section titled “Configuring PySAML2 to work with Okta.”</p>
<ul class="list-unstyled toc" id="markdown-toc">
<li><a href="#overview" id="markdown-toc-overview">Overview</a> <ul>
<li><a href="#configuring-okta-to-work-with-pysaml2" id="markdown-toc-configuring-okta-to-work-with-pysaml2">Configuring Okta to work with PySAML2</a></li>
<li><a href="#configuring-pysaml2-to-work-with-okta" id="markdown-toc-configuring-pysaml2-to-work-with-okta">Configuring PySAML2 to work with Okta</a></li>
<li><a href="#test-the-saml-integration" id="markdown-toc-test-the-saml-integration">Test the SAML integration</a></li>
<li><a href="#next-steps" id="markdown-toc-next-steps">Next Steps</a></li>
</ul>
</li>
</ul>
<h2 id="configuring-okta-to-work-with-pysaml2">Configuring Okta to work with PySAML2</h2>
<p>Before you can configure your application and PySAML2 set up an
Okta “<a href="https://support.okta.com/articles/Knowledge_Article/27838096-Okta-Terminology">chiclet</a>” (application icon) that enables an Okta user to sign in to your to your application with SAML and PySAML2.</p>
<p>To set up Okta to connect to your application, follow the
<a href="/docs/guides/setting_up_a_saml_application_in_okta.html">setting up a SAML application in Okta</a>
guide. As noted in the instructions, there are two steps to change:</p>
<ul>
<li><em>In step #6</em>: Use <strong><em>PySAML2 Example</em></strong> instead of <strong><em>Example SAML application</em></strong> .</li>
<li>
<p><em>In step #7</em>: When entering the URL</p>
<div class="language-shell highlighter-rouge"><pre class="highlight"><code>http://example.com/saml/sso/example-okta-com
</code></pre>
</div>
<p>use the following:</p>
<div class="language-shell highlighter-rouge"><pre class="highlight"><code>http://localhost:5000/saml/sso/example-okta-com
</code></pre>
</div>
<p><strong>Note:</strong> “5000” is the port that Flask uses by default, if you are using a different port number, change “5000” to the port number you are using.</p>
</li>
</ul>
<h2 id="configuring-pysaml2-to-work-with-okta">Configuring PySAML2 to work with Okta</h2>
<p>Now that you have configured the PySAML2 Example “chiclet” in your Okta organization, you
are ready to configure PySAML2 to work with your Okta organization. In this
section we use the “Identity Provider metadata” link from the
section above to configure PySAML2. After completing
the following steps, you will have a working example of connecting Okta to a sample Python application using PySAML2.</p>
<ol>
<li>
<p>Install platform-dependent prerequisites:</p>
<blockquote>
<p>Note: These instructions assume that you are running on a recent version of your operating system.</p>
</blockquote>
<p>For Mac OS X:</p>
<div class="language-shell highlighter-rouge"><pre class="highlight"><code>brew install libffi libxmlsec1
</code></pre>
</div>
<p>For RHEL:</p>
<div class="language-shell highlighter-rouge"><pre class="highlight"><code>sudo yum install libffi-devel xmlsec1 xmlsec1-openssl
</code></pre>
</div>
</li>
<li>
<p>Download the example application for Python:</p>
<div class="language-shell highlighter-rouge"><pre class="highlight"><code><span class="gp">$ </span>git clone git@github.com:jpf/okta-pysaml2-example.git
</code></pre>
</div>
</li>
<li>
<p><code class="highlighter-rouge">cd</code> to the <code class="highlighter-rouge">okta-pysaml2-example</code> directory.</p>
<div class="language-shell highlighter-rouge"><pre class="highlight"><code><span class="gp">$ </span><span class="nb">cd </span>okta-pysaml2-example
</code></pre>
</div>
</li>
<li>
<p>Open the <code class="highlighter-rouge">app.py</code> file in your favorite text editor.</p>
<div class="language-shell highlighter-rouge"><pre class="highlight"><code><span class="gp">$ </span><span class="nv">$EDITOR</span> app.py
</code></pre>
</div>
</li>
<li>
<p>After opening the <code class="highlighter-rouge">app.py</code> file, modify the contents of the <code class="highlighter-rouge">metadata_url_for</code> dictionary as shown below.</p>
<div class="language-python highlighter-rouge"><pre class="highlight"><code><span class="n">metadata_url_for</span> <span class="o">=</span> <span class="p">{</span>
<span class="s">'example-okta-com'</span><span class="p">:</span> <span class="s">'${metadata_url}'</span>
<span class="p">}</span>
</code></pre>
</div>
</li>
<li>
<p>Be sure to replace the contents of <code class="highlighter-rouge">${metdata_url}</code> with the link
that you copied in step #10 of the
“<a href="/docs/guides/setting_up_a_saml_application_in_okta.html">Setting up a SAML application in Okta</a>”
instructions that you followed above!</p>
<p>Note: The contents of <code class="highlighter-rouge">${metadata_url}</code> should look similar to: <code class="highlighter-rouge">https://{yourOktaDomain}.com/app/a0b1c2deFGHIJKLMNOPQ/sso/saml/metadata</code></p>
</li>
<li>
<p>Install the dependencies; for example, Python SAML SP:</p>
<div class="language-shell highlighter-rouge"><pre class="highlight"><code><span class="gp">$ </span>virtualenv venv
<span class="gp">$ </span><span class="nb">source </span>venv/bin/activate
<span class="gp">$ </span>pip install -r requirements.txt
</code></pre>
</div>
</li>
<li>
<p>Start the Python example:</p>
<div class="language-shell highlighter-rouge"><pre class="highlight"><code><span class="gp">$ </span>python app.py
</code></pre>
</div>
</li>
</ol>
<h2 id="test-the-saml-integration">Test the SAML integration</h2>
<p>Now that you have set up an application in your Okta organization and have
configured PySAML2 to work with your Okta organization, it is ready to test.</p>
<p>There are two ways to test a SAML application:</p>
<ol>
<li>Starting from the example Python application (“SP initiated”).</li>
<li>Starting from Okta (“IdP initiated”).</li>
</ol>
<p>You will use both methods to test your application. In each case, you will know iff the
test worked when you see a screen that looks like the one below:</p>
<p><img src="/assets/pysaml2-authenticated-user-d8912d81bbfce1033fc7f3d67c48be56951979a7e747fd2ebcf9976f1299de9a.png" alt="Authenticated user" /></p>
<ol>
<li>
<p>Login from the Okta PySAML2 example application (This is
known as an <strong>SP-initiated login</strong>.)</p>
<ul>
<li>
<p>Start the example application from the command line:</p>
<div class="language-shell highlighter-rouge"><pre class="highlight"><code><span class="gp">$ </span><span class="nb">source </span>venv/bin/activate
<span class="gp">$ </span>python app.py
</code></pre>
</div>
</li>
<li>
<p>Open the example application in your browser:
<a href="http://localhost:5000/">http://localhost:5000/</a></p>
</li>
<li>
<p>Click on the link for your Okta IdP.</p>
</li>
</ul>
</li>
<li>
<p>Login from Okta (This is known as an <strong>IdP-initiated” login</strong>.)</p>
<ul>
<li>
<p>Start the example application from the command line:</p>
<div class="language-shell highlighter-rouge"><pre class="highlight"><code><span class="gp">$ </span><span class="nb">source </span>venv/bin/activate
<span class="gp">$ </span>python app.py
</code></pre>
</div>
</li>
<li>
<p>Sign in to your Okta organization.</p>
</li>
<li>
<p>Click the button for the application you created earlier
“Configuring Okta to work with PySAML2” section
above: <img src="/assets/pysaml2-example-okta-chiclet-3003afce3ef90893a2c73e5bfe8f274bb9ed2facfb075222128d1da7db72281f.png" alt="PySAML2 Example" /></p>
</li>
</ul>
</li>
</ol>
<p>If you can to get to the “Logged in” page using both of the
methods above, the test are successful.</p>
<p>Congratulations on getting Okta working with PySAML2!</p>
<h2 id="next-steps">Next Steps</h2>
<p>At this point, you should be familiar with setting up a SAML enabled application
to work with an Okta organization and how to configure PySAML2 to work with Okta.</p>
<p>After you have your Okta organization working with the example Python
application, the next step is to take the example code and move
it to your production application. The specifics of how this works is
different depending on how your application is set
up. Pay special attention to the notes in the <code class="highlighter-rouge">app.py</code> file. For
example, on a production system, the contents of the
<code class="highlighter-rouge">metadata_url_for</code> dictionary cannot be hard coded, but must come
from a dynamic datastore.</p>
<p>If you want to learn more about SAML and what to consider when writing a SAML implementation, Okta’s
in-depth <a href="/docs/getting_started/saml_guidance.html">SAML guidance</a>
is a great place to learn more.</p>
<p>Finally, if you got this far in this guide and still have questions,
please reach out to me at: joel.franusic@okta.com.</p>
</div>
<!-- END Page Content -->
</section>
<!-- END Page Center w/Sub Nav & Content -->
<!-- START Footer -->
<footer class="Footer">
<div class="Wrap">
<div class="Row">
<div class="Column--3 Column--medium-6 Column--xSmall-12">
<a class="Logo" href="https://www.okta.com/" target="_blank" rel="noopener noreferrer">
<img src="https://developer.okta.com/sites/all/themes/developer/images/logo-footer.png" alt="Okta">
Visit okta.com
</a>
</div>
<div class="Column--3 Column--medium-12 Column--xSmall-12">
<h4>Social</h4>
<ul class="Footer-links Footer-links--social">
<li><a class="Footer-links--github" target="_blank" rel="noopener noreferrer" href="http://github.com/oktadeveloper">Github</a></li>
<li><a class="Footer-links--twitter" target="_blank" rel="noopener noreferrer" href="http://twitter.com/OktaDev">Twitter</a></li>
<li><a class="Footer-links--forum" target="_blank" rel="noopener noreferrer" href="https://devforum.okta.com/">Forum</a></li>
<li><a class="Footer-links--rss" target="_blank" rel="noopener noreferrer" href="http://feeds.feedburner.com/OktaBlog">RSS Blog</a></li>
</ul>
</div>
<div class="Column--3 Column--medium-6 Column--small-12">
<h4>More Info</h4>
<ul class="Footer-links">
<li><a target="_blank" href="https://developer.okta.com/integrate-with-okta/">Integrate with Okta</a></li>
<li><a href="/blog/">Blog</a></li>
<li><a href="/docs/platform-release-notes/platform-release-notes.html">Release Notes</a></li>
<li><a href="/3rd_party_notices/">3rd Party Notices</a></li>
</ul>
</div>
<div class="Column--3 Column--medium-6 Column--small-12">
<h4>Contact & Legal</h4>
<ul class="Footer-links">
<li><a href="/contact/">Contact Sales</a></li>
<li><a target="_blank" rel="noopener noreferrer" href="mailto:developers@okta.com">Contact Support</a></li>
<li><a href="/terms/">Terms & Conditions</a></li>
<li><a href="/privacy/">Privacy Policy</a></li>
</ul>
</div>
</div>
</div>
</footer>
<script type="text/javascript" src="/assets/master-0365dd27cf276cb2a15c0a43906ca592538204cf1ad4557547bf4e50609b411e.js"></script>
<script type="text/javascript" src="/assets/quickstart-26919e2a466e6346d96282973427a3998da81637fd2a2ceb6917a61da7eaf2a8.js"></script>
<script type="text/javascript" src="/assets/docsIndex-aebe0e7212e0f2974ef463f06967cba7144f5eed4f14bb11c346866f3fd4ecb7.js"></script>
<!-- END Footer -->
</div>
<!-- START Post Footer -->
<!-- START Google Tag Manager -->
<!-- https://support.google.com/tagmanager/answer/6103696?hl=en -->
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-TJ45R6" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- END Google Tag Manager -->
<!-- START Google Remarketing Tag -->
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = 1006913831;
var google_custom_params = window.google_tag_params;
var google_remarketing_only = true;
/* ]]> */
</script>
<div style="display:none;"><script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js"></script></div>
<noscript><div style="display:inline;"><img height="1" width="1" style="border-style:none;" alt="" src="//googleads.g.doubleclick.net/pagead/viewthroughconversion/1006913831/?value=0&guid=ON&script=0"></div></noscript>
<!-- END Google Remarketing Tag -->
<!-- START Crazy Egg Tracking -->
<script type="text/javascript">
setTimeout(function(){var a=document.createElement("script");
var b=document.getElementsByTagName("script")[0];
a.src=document.location.protocol+"//script.crazyegg.com/pages/scripts/0021/9333.js?"+Math.floor(new Date().getTime()/3600000);
a.async=true;a.type="text/javascript";b.parentNode.insertBefore(a,b)}, 1);
</script>
<!-- END Crazy Egg Tracking -->
<!-- END Post Footer -->
</body>
</html>