-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEpochtalkServer.Auth.Guardian.html
1014 lines (730 loc) · 48.5 KB
/
EpochtalkServer.Auth.Guardian.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
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
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="ExDoc v0.29.4">
<meta name="project" content="epochtalk_server v0.1.0">
<title>EpochtalkServer.Auth.Guardian — epochtalk_server v0.1.0</title>
<link rel="stylesheet" href="dist/html-elixir-HHVY3JYD.css" />
<script src="dist/handlebars.runtime-NWIB6V2M.js"></script>
<script src="dist/handlebars.templates-XWGFFSCD.js"></script>
<script src="dist/sidebar_items-EA60E5D0.js"></script>
<script src="docs_config.js"></script>
<script async src="dist/html-JDI3AVDD.js"></script>
</head>
<body data-type="modules" class="page-module">
<script>
try {
var settings = JSON.parse(localStorage.getItem('ex_doc:settings') || '{}');
if (settings.theme === 'dark' ||
((settings.theme === 'system' || settings.theme == null) &&
window.matchMedia('(prefers-color-scheme: dark)').matches)
) {
document.body.classList.add('dark')
}
} catch (error) { }
</script>
<div class="main">
<button class="sidebar-button sidebar-toggle" aria-label="toggle sidebar">
<i class="ri-menu-line ri-lg" title="Collapse/expand sidebar"></i>
</button>
<section class="sidebar">
<form class="sidebar-search" action="search.html">
<button type="submit" class="search-button" aria-label="Submit Search">
<i class="ri-search-2-line" aria-hidden="true" title="Submit search"></i>
</button>
<button type="button" tabindex="-1" class="search-close-button" aria-label="Cancel Search">
<i class="ri-close-line ri-lg" aria-hidden="true" title="Cancel search"></i>
</button>
<label class="search-label">
<p class="sr-only">Search</p>
<input name="q" type="text" class="search-input" placeholder="Search..." aria-label="Input your search terms" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" />
</label>
</form>
<div class="autocomplete">
<div class="autocomplete-results">
</div>
</div>
<div class="sidebar-header">
<div class="sidebar-projectDetails">
<a href="api-reference.html" class="sidebar-projectName" translate="no">
epochtalk_server
</a>
<div class="sidebar-projectVersion" translate="no">
v0.1.0
</div>
</div>
<ul class="sidebar-listNav">
<li><a id="extras-list-link" href="#full-list">Pages</a></li>
<li><a id="modules-list-link" href="#full-list">Modules</a></li>
</ul>
</div>
<div class="gradient"></div>
<ul id="full-list"></ul>
</section>
<section class="content">
<output role="status" id="toast"></output>
<div class="content-outer">
<div id="content" class="content-inner">
<h1>
<button class="icon-action display-settings">
<i class="ri-settings-3-line"></i>
<span class="sr-only">Settings</span>
</button>
<span translate="no">EpochtalkServer.Auth.Guardian</span>
<small class="app-vsn" translate="no">(epochtalk_server v0.1.0)</small>
</h1>
<section id="moduledoc">
<p>Guardian provides a singular interface for authentication in Elixir applications
that is <code class="inline">token</code> based.
Tokens should be:</p><ul><li>tamper proof</li><li>include a payload (claims)
JWT tokens (the default) fit this description.
When using Guardian, you'll need an implementation module.<pre><code class="makeup elixir" translate="no"><span class="kd">defmodule</span><span class="w"> </span><span class="nc">MyApp.Guardian</span><span class="w"> </span><span class="k" data-group-id="0858376414-1">do</span><span class="w">
</span><span class="kn">use</span><span class="w"> </span><span class="nc">Guardian</span><span class="p">,</span><span class="w"> </span><span class="ss">otp_app</span><span class="p">:</span><span class="w"> </span><span class="ss">:my_app</span><span class="w">
</span><span class="kd">def</span><span class="w"> </span><span class="nf">subject_for_token</span><span class="p" data-group-id="0858376414-2">(</span><span class="n">resource</span><span class="p">,</span><span class="w"> </span><span class="c">_claims</span><span class="p" data-group-id="0858376414-2">)</span><span class="p">,</span><span class="w"> </span><span class="ss">do</span><span class="p">:</span><span class="w"> </span><span class="p" data-group-id="0858376414-3">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="n">to_string</span><span class="p" data-group-id="0858376414-4">(</span><span class="n">resource</span><span class="o">.</span><span class="n">id</span><span class="p" data-group-id="0858376414-4">)</span><span class="p" data-group-id="0858376414-3">}</span><span class="w">
</span><span class="kd">def</span><span class="w"> </span><span class="nf">resource_from_claims</span><span class="p" data-group-id="0858376414-5">(</span><span class="n">claims</span><span class="p" data-group-id="0858376414-5">)</span><span class="w"> </span><span class="k" data-group-id="0858376414-6">do</span><span class="w">
</span><span class="n">find_me_a_resource</span><span class="p" data-group-id="0858376414-7">(</span><span class="n">claims</span><span class="p" data-group-id="0858376414-8">[</span><span class="s">"sub"</span><span class="p" data-group-id="0858376414-8">]</span><span class="p" data-group-id="0858376414-7">)</span><span class="w"> </span><span class="c1"># {:ok, resource} or {:error, reason}</span><span class="w">
</span><span class="k" data-group-id="0858376414-6">end</span><span class="w">
</span><span class="k" data-group-id="0858376414-1">end</span></code></pre>This module is what you will use to interact with tokens in your application.
When you <code class="inline">use</code> Guardian, the <code class="inline">:otp_app</code> option is required.
Any other option provided will be merged with the configuration in the config
files.
The Guardian module contains some generated functions and some callbacks.</li></ul><h2 id="module-generated-functions" class="section-heading">
<a href="#module-generated-functions" class="hover-link"><i class="ri-link-m" aria-hidden="true"></i>
<p class="sr-only">generated-functions</p>
</a>
Generated functions
</h2>
<h3 id="module-default_token_type" class="section-heading">
<a href="#module-default_token_type" class="hover-link"><i class="ri-link-m" aria-hidden="true"></i>
<p class="sr-only">default_token_type</p>
</a>
<code class="inline">default_token_type()</code>
</h3>
<p>Overridable.
Provides the default token type for the token - <code class="inline">"access"</code>
Token types allow a developer to mark a token as having a particular purpose.
Different types of tokens can then be used specifically in your app.
Types may include (but are not limited to):</p><ul><li><code class="inline">"access"</code></li><li><code class="inline">"refresh"</code>
Access tokens should be short lived and are used to access resources on your API.
Refresh tokens should be longer lived and whose only purpose is to exchange
for a shorter lived access token.
To specify the type of token, use the <code class="inline">:token_type</code> option in
the <code class="inline">encode_and_sign</code> function.
Token type is encoded into the token in the <code class="inline">"typ"</code> field.
Return - a string.</li></ul><h3 id="module-peek-token" class="section-heading">
<a href="#module-peek-token" class="hover-link"><i class="ri-link-m" aria-hidden="true"></i>
<p class="sr-only">peek-token</p>
</a>
<code class="inline">peek(token)</code>
</h3>
<p>Inspect a tokens payload. Note that this function does no verification.
Return - a map including the <code class="inline">:claims</code> key.</p><h3 id="module-config-config-key-default-nil" class="section-heading">
<a href="#module-config-config-key-default-nil" class="hover-link"><i class="ri-link-m" aria-hidden="true"></i>
<p class="sr-only">config-config-key-default-nil</p>
</a>
<code class="inline">config()</code>, <code class="inline">config(key, default \\ nil)</code>
</h3>
<p>Without argument <code class="inline">config</code> will return the full configuration Keyword list.
When given a <code class="inline">key</code> and optionally a default, <code class="inline">config</code> will fetch a resolved value
contained in the key.
See <a href="https://hexdocs.pm/guardian/2.3.2/Guardian.Config.html#resolve_value/1"><code class="inline">Guardian.Config.resolve_value/1</code></a></p><h3 id="module-encode_and_sign-resource-claims-opts" class="section-heading">
<a href="#module-encode_and_sign-resource-claims-opts" class="hover-link"><i class="ri-link-m" aria-hidden="true"></i>
<p class="sr-only">encode_and_sign-resource-claims-opts</p>
</a>
<code class="inline">encode_and_sign(resource, claims \\ %{}, opts \\ [])</code>
</h3>
<p>Creates a signed token.
Arguments:</p><ul><li><code class="inline">resource</code> - The resource to represent in the token (i.e. the user)</li><li><code class="inline">claims</code> - Any custom claims that you want to use in your token</li><li><code class="inline">opts</code> - Options for the token module and callbacks
For more information on options see the documentation for your token module.<pre><code class="makeup elixir" translate="no"><span class="c1"># Provide a token using the defaults including the default_token_type</span><span class="w">
</span><span class="p" data-group-id="4638149086-1">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="n">token</span><span class="p">,</span><span class="w"> </span><span class="n">full_claims</span><span class="p" data-group-id="4638149086-1">}</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">MyApp.Guardian</span><span class="o">.</span><span class="n">encode_and_sign</span><span class="p" data-group-id="4638149086-2">(</span><span class="n">user</span><span class="p" data-group-id="4638149086-2">)</span><span class="w">
</span><span class="c1"># Provide a token including custom claims</span><span class="w">
</span><span class="p" data-group-id="4638149086-3">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="n">token</span><span class="p">,</span><span class="w"> </span><span class="n">full_claims</span><span class="p" data-group-id="4638149086-3">}</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">MyApp.Guardian</span><span class="o">.</span><span class="n">encode_and_sign</span><span class="p" data-group-id="4638149086-4">(</span><span class="n">user</span><span class="p">,</span><span class="w"> </span><span class="p" data-group-id="4638149086-5">%{</span><span class="ss">some</span><span class="p">:</span><span class="w"> </span><span class="s">"claim"</span><span class="p" data-group-id="4638149086-5">}</span><span class="p" data-group-id="4638149086-4">)</span><span class="w">
</span><span class="c1"># Provide a token including custom claims and a different token type/ttl</span><span class="w">
</span><span class="p" data-group-id="4638149086-6">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="n">token</span><span class="p">,</span><span class="w"> </span><span class="n">full_claims</span><span class="p" data-group-id="4638149086-6">}</span><span class="w"> </span><span class="o">=</span><span class="w">
</span><span class="nc">MyApp.Guardian</span><span class="o">.</span><span class="n">encode_and_sign</span><span class="p" data-group-id="4638149086-7">(</span><span class="n">user</span><span class="p">,</span><span class="w"> </span><span class="p" data-group-id="4638149086-8">%{</span><span class="ss">some</span><span class="p">:</span><span class="w"> </span><span class="s">"claim"</span><span class="p" data-group-id="4638149086-8">}</span><span class="p">,</span><span class="w"> </span><span class="ss">token_type</span><span class="p">:</span><span class="w"> </span><span class="s">"refresh"</span><span class="p">,</span><span class="w"> </span><span class="ss">ttl</span><span class="p">:</span><span class="w"> </span><span class="p" data-group-id="4638149086-9">{</span><span class="mi">4</span><span class="p">,</span><span class="w"> </span><span class="ss">:weeks</span><span class="p" data-group-id="4638149086-9">}</span><span class="p" data-group-id="4638149086-7">)</span></code></pre>The <code class="inline">encode_and_sign</code> function calls a number of callbacks on
your implementation module. See <a href="https://hexdocs.pm/guardian/2.3.2/Guardian.html#encode_and_sign/4"><code class="inline">Guardian.encode_and_sign/4</code></a></li></ul><h3 id="module-decode_and_verify-token-claims_to_check-opts" class="section-heading">
<a href="#module-decode_and_verify-token-claims_to_check-opts" class="hover-link"><i class="ri-link-m" aria-hidden="true"></i>
<p class="sr-only">decode_and_verify-token-claims_to_check-opts</p>
</a>
<code class="inline">decode_and_verify(token, claims_to_check \\ %{}, opts \\ [])</code>
</h3>
<p>Decodes a token and verifies the claims are valid.
Arguments:</p><ul><li><code class="inline">token</code> - The token to decode</li><li><code class="inline">claims_to_check</code> - A map of the literal claims that should be matched. If
any of the claims do not literally match verification fails.</li><li><code class="inline">opts</code> - The options to pass to the token module and callbacks
Callbacks:
<code class="inline">decode_and_verify</code> calls a number of callbacks on your implementation module,
See <a href="https://hexdocs.pm/guardian/2.3.2/Guardian.html#decode_and_verify/4"><code class="inline">Guardian.decode_and_verify/4</code></a><pre><code class="makeup elixir" translate="no"><span class="c1"># Decode and verify using the defaults</span><span class="w">
</span><span class="p" data-group-id="7361607453-1">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="n">claims</span><span class="p" data-group-id="7361607453-1">}</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">MyApp.Guardian</span><span class="o">.</span><span class="n">decode_and_verify</span><span class="p" data-group-id="7361607453-2">(</span><span class="n">token</span><span class="p" data-group-id="7361607453-2">)</span><span class="w">
</span><span class="c1"># Decode and verify with literal claims check.</span><span class="w">
</span><span class="c1"># If the claims in the token do not match those given verification will fail</span><span class="w">
</span><span class="p" data-group-id="7361607453-3">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="n">claims</span><span class="p" data-group-id="7361607453-3">}</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">MyApp.Guardian</span><span class="o">.</span><span class="n">decode_and_verify</span><span class="p" data-group-id="7361607453-4">(</span><span class="n">token</span><span class="p">,</span><span class="w"> </span><span class="p" data-group-id="7361607453-5">%{</span><span class="ss">match</span><span class="p">:</span><span class="w"> </span><span class="s">"claim"</span><span class="p" data-group-id="7361607453-5">}</span><span class="p" data-group-id="7361607453-4">)</span><span class="w">
</span><span class="c1"># Decode and verify with literal claims check and options.</span><span class="w">
</span><span class="c1"># Options are passed to your token module and callbacks</span><span class="w">
</span><span class="p" data-group-id="7361607453-6">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="n">claims</span><span class="p" data-group-id="7361607453-6">}</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">MyApp.Guardian</span><span class="o">.</span><span class="n">decode_and_verify</span><span class="p" data-group-id="7361607453-7">(</span><span class="n">token</span><span class="p">,</span><span class="w"> </span><span class="p" data-group-id="7361607453-8">%{</span><span class="ss">match</span><span class="p">:</span><span class="w"> </span><span class="s">"claim"</span><span class="p" data-group-id="7361607453-8">}</span><span class="p">,</span><span class="w"> </span><span class="ss">some</span><span class="p">:</span><span class="w"> </span><span class="s">"secret"</span><span class="p" data-group-id="7361607453-7">)</span></code></pre></li></ul><h3 id="module-revoke-token-opts" class="section-heading">
<a href="#module-revoke-token-opts" class="hover-link"><i class="ri-link-m" aria-hidden="true"></i>
<p class="sr-only">revoke-token-opts</p>
</a>
<code class="inline">revoke(token, opts \\ [])</code>
</h3>
<p>Revoke a token.
<em>Note:</em> this is entirely dependent on your token module and implementation
callbacks.</p><pre><code class="makeup elixir" translate="no"><span class="p" data-group-id="9483982140-1">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="n">claims</span><span class="p" data-group-id="9483982140-1">}</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">MyApp.Guardian</span><span class="o">.</span><span class="n">revoke</span><span class="p" data-group-id="9483982140-2">(</span><span class="n">token</span><span class="p">,</span><span class="w"> </span><span class="ss">some</span><span class="p">:</span><span class="w"> </span><span class="s">"option"</span><span class="p" data-group-id="9483982140-2">)</span></code></pre><h3 id="module-refresh-token-opts" class="section-heading">
<a href="#module-refresh-token-opts" class="hover-link"><i class="ri-link-m" aria-hidden="true"></i>
<p class="sr-only">refresh-token-opts</p>
</a>
refresh(token, opts \ [])
</h3>
<p>Refreshes the time on a token. This is used to re-issue a token with
essentially the same claims but with a different expiry.
Tokens are verified before performing the refresh to ensure
only valid tokens may be refreshed.
Arguments:</p><ul><li><code class="inline">token</code> - The old token to refresh</li><li><code class="inline">opts</code> - Options to pass to the Implementation Module and callbacks
Options:</li><li><code class="inline">:ttl</code> - The new ttl. If not specified the default will be used.<pre><code class="makeup elixir" translate="no"><span class="p" data-group-id="5591376375-1">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="p" data-group-id="5591376375-2">{</span><span class="n">old_token</span><span class="p">,</span><span class="w"> </span><span class="n">old_claims</span><span class="p" data-group-id="5591376375-2">}</span><span class="p">,</span><span class="w"> </span><span class="p" data-group-id="5591376375-3">{</span><span class="n">new_token</span><span class="p">,</span><span class="w"> </span><span class="n">new_claims</span><span class="p" data-group-id="5591376375-3">}</span><span class="p" data-group-id="5591376375-1">}</span><span class="w"> </span><span class="o">=</span><span class="w">
</span><span class="nc">MyApp.Guardian</span><span class="o">.</span><span class="n">refresh</span><span class="p" data-group-id="5591376375-4">(</span><span class="n">old_token</span><span class="p">,</span><span class="w"> </span><span class="ss">ttl</span><span class="p">:</span><span class="w"> </span><span class="p" data-group-id="5591376375-5">{</span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">:hour</span><span class="p" data-group-id="5591376375-5">}</span><span class="p" data-group-id="5591376375-4">)</span></code></pre>See <code class="inline">Guardian.refresh</code></li></ul><h3 id="module-exchange-old_token-from_type-to_type-options" class="section-heading">
<a href="#module-exchange-old_token-from_type-to_type-options" class="hover-link"><i class="ri-link-m" aria-hidden="true"></i>
<p class="sr-only">exchange-old_token-from_type-to_type-options</p>
</a>
<code class="inline">exchange(old_token, from_type, to_type, options)</code>
</h3>
<p>Exchanges one token for another of a different type.
Especially useful to trade in a <code class="inline">refresh</code> token for an <code class="inline">access</code> one.
Tokens are verified before performing the exchange to ensure that
only valid tokens may be exchanged.
Arguments:</p><ul><li><code class="inline">old_token</code> - The existing token you wish to exchange.</li><li><code class="inline">from_type</code> - The type the old token must be. Can be given a list of types.</li><li><code class="inline">to_type</code> - The new type of token that you want back.</li><li><code class="inline">options</code> - The options to pass to the token module and callbacks.
Options:
Options may be used by your token module or callbacks.</li><li><code class="inline">ttl</code> - The ttl for the new token
See <code class="inline">Guardian.exchange</code></li></ul><p><strong>Note:</strong> Copied from <a href="https://github.com/ueberauth/guardian">Guardian Docs</a></p>
</section>
<section id="summary" class="details-list">
<h1 class="section-heading">
<a class="hover-link" href="#summary">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this section</span>
</a>
Summary
</h1>
<div class="summary-functions summary">
<h2>
<a href="#functions">Functions</a>
</h2>
<div class="summary-row">
<div class="summary-signature">
<a href="#after_encode_and_sign/4" translate="no">after_encode_and_sign(resource, claims, token, arg4)</a>
</div>
<div class="summary-synopsis"><p>An optional callback invoked after the token has been generated
and signed.</p></div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#after_sign_in/5" translate="no">after_sign_in(conn, r, t, c, o)</a>
</div>
<div class="summary-synopsis"><p>Callback implementation for <a href="https://hexdocs.pm/guardian/2.3.2/Guardian.html#c:after_sign_in/5"><code class="inline">Guardian.after_sign_in/5</code></a>.</p></div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#before_sign_out/3" translate="no">before_sign_out(conn, location, opts)</a>
</div>
<div class="summary-synopsis"><p>Callback implementation for <a href="https://hexdocs.pm/guardian/2.3.2/Guardian.html#c:before_sign_out/3"><code class="inline">Guardian.before_sign_out/3</code></a>.</p></div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#build_claims/3" translate="no">build_claims(c, _, _)</a>
</div>
<div class="summary-synopsis"><p>Callback implementation for <a href="https://hexdocs.pm/guardian/2.3.2/Guardian.html#c:build_claims/3"><code class="inline">Guardian.build_claims/3</code></a>.</p></div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#config/0" translate="no">config()</a>
</div>
<div class="summary-synopsis"><p>Fetches the configuration for this module.</p></div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#config/2" translate="no">config(key, default \\ nil)</a>
</div>
<div class="summary-synopsis"><p>Returns a resolved value of the configuration found at a key.</p></div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#decode_and_verify/3" translate="no">decode_and_verify(token, claims_to_check \\ %{}, opts \\ [])</a>
</div>
<div class="summary-synopsis"><p>Decodes and verifies a token using the configuration on the implementation
module.</p></div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#default_token_type/0" translate="no">default_token_type()</a>
</div>
<div class="summary-synopsis"><p>The default type of token for this module.</p></div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#encode_and_sign/3" translate="no">encode_and_sign(resource, claims \\ %{}, opts \\ [])</a>
</div>
<div class="summary-synopsis"><p>Encodes the claims.</p></div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#exchange/4" translate="no">exchange(token, from_type, to_type, opts \\ [])</a>
</div>
<div class="summary-synopsis"><p>Exchanges a token of one type for another.</p></div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#on_exchange/3" translate="no">on_exchange(old_stuff, new_stuff, options)</a>
</div>
<div class="summary-synopsis"><p>Callback implementation for <a href="https://hexdocs.pm/guardian/2.3.2/Guardian.html#c:on_exchange/3"><code class="inline">Guardian.on_exchange/3</code></a>.</p></div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#on_refresh/3" translate="no">on_refresh(old_stuff, new_stuff, options)</a>
</div>
<div class="summary-synopsis"><p>An optional callback invoked when a token is refreshed.</p></div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#on_revoke/3" translate="no">on_revoke(claims, token, options)</a>
</div>
<div class="summary-synopsis"><p>An optional callback invoked when a token is revoked.</p></div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#on_verify/3" translate="no">on_verify(claims, token, options)</a>
</div>
<div class="summary-synopsis"><p>An optional callback invoked after the claims have been validated.</p></div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#peek/1" translate="no">peek(token)</a>
</div>
<div class="summary-synopsis"><p>Provides the content of the token but without verification
of either the claims or the signature.</p></div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#refresh/2" translate="no">refresh(old_token, opts \\ [])</a>
</div>
<div class="summary-synopsis"><p>Refresh a token.</p></div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#resource_from_claims/1" translate="no">resource_from_claims(claims)</a>
</div>
<div class="summary-synopsis"><p>Fetches the resource that is represented by claims.
For JWT this would normally be found in the <code class="inline">sub</code> field.</p></div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#resource_from_token/3" translate="no">resource_from_token(token, claims_to_check \\ %{}, opts \\ [])</a>
</div>
<div class="summary-synopsis"><p>Fetch the resource and claims directly from a token.</p></div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#revoke/2" translate="no">revoke(token, opts \\ [])</a>
</div>
<div class="summary-synopsis"><p>Revoke a token.</p></div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#sliding_cookie/3" translate="no">sliding_cookie(current_claims, current_resource, opts \\ [])</a>
</div>
<div class="summary-synopsis"><p>If Guardian.Plug.SlidingCookie is used, this callback will be invoked to
return the new claims, or an error (which will mean the cookie will not
be refreshed).</p></div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#subject_for_token/2" translate="no">subject_for_token(arg1, arg2)</a>
</div>
<div class="summary-synopsis"><p>Fetches the subject for a token for the provided resource and claims
The subject should be a short identifier that can be used to identify
the resource.</p></div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#verify_claims/2" translate="no">verify_claims(claims, options)</a>
</div>
<div class="summary-synopsis"><p>Callback implementation for <a href="https://hexdocs.pm/guardian/2.3.2/Guardian.html#c:verify_claims/2"><code class="inline">Guardian.verify_claims/2</code></a>.</p></div>
</div>
</div>
</section>
<section id="functions" class="details-list">
<h1 class="section-heading">
<a class="hover-link" href="#functions">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this section</span>
</a>
Functions
</h1>
<div class="functions-list">
<section class="detail" id="after_encode_and_sign/4">
<div class="detail-header">
<a href="#after_encode_and_sign/4" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">after_encode_and_sign(resource, claims, token, arg4)</h1>
</div>
<section class="docstring">
<p>An optional callback invoked after the token has been generated
and signed.</p>
</section>
</section>
<section class="detail" id="after_sign_in/5">
<div class="detail-header">
<a href="#after_sign_in/5" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">after_sign_in(conn, r, t, c, o)</h1>
</div>
<section class="docstring">
<p>Callback implementation for <a href="https://hexdocs.pm/guardian/2.3.2/Guardian.html#c:after_sign_in/5"><code class="inline">Guardian.after_sign_in/5</code></a>.</p>
</section>
</section>
<section class="detail" id="before_sign_out/3">
<div class="detail-header">
<a href="#before_sign_out/3" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">before_sign_out(conn, location, opts)</h1>
</div>
<section class="docstring">
<p>Callback implementation for <a href="https://hexdocs.pm/guardian/2.3.2/Guardian.html#c:before_sign_out/3"><code class="inline">Guardian.before_sign_out/3</code></a>.</p>
</section>
</section>
<section class="detail" id="build_claims/3">
<div class="detail-header">
<a href="#build_claims/3" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">build_claims(c, _, _)</h1>
</div>
<section class="docstring">
<p>Callback implementation for <a href="https://hexdocs.pm/guardian/2.3.2/Guardian.html#c:build_claims/3"><code class="inline">Guardian.build_claims/3</code></a>.</p>
</section>
</section>
<section class="detail" id="config/0">
<div class="detail-header">
<a href="#config/0" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">config()</h1>
</div>
<section class="docstring">
<div class="specs">
<pre translate="no"><span class="attribute">@spec</span> config() :: <a href="https://hexdocs.pm/elixir/Keyword.html#t:t/0">Keyword.t</a>()</pre>
</div>
<p>Fetches the configuration for this module.</p>
</section>
</section>
<section class="detail" id="config/2">
<span id="config/1"></span>
<div class="detail-header">
<a href="#config/2" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">config(key, default \\ nil)</h1>
</div>
<section class="docstring">
<div class="specs">
<pre translate="no"><span class="attribute">@spec</span> config(<a href="https://hexdocs.pm/elixir/typespecs.html#basic-types">atom</a>() | <a href="https://hexdocs.pm/elixir/String.html#t:t/0">String.t</a>(), <a href="https://hexdocs.pm/elixir/typespecs.html#basic-types">any</a>()) :: <a href="https://hexdocs.pm/elixir/typespecs.html#basic-types">any</a>()</pre>
</div>
<p>Returns a resolved value of the configuration found at a key.</p><p>See <a href="https://hexdocs.pm/guardian/2.3.2/Guardian.Config.html#resolve_value/1"><code class="inline">Guardian.Config.resolve_value/1</code></a>.</p>
</section>
</section>
<section class="detail" id="decode_and_verify/3">
<span id="decode_and_verify/1"></span>
<span id="decode_and_verify/2"></span>
<div class="detail-header">
<a href="#decode_and_verify/3" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">decode_and_verify(token, claims_to_check \\ %{}, opts \\ [])</h1>
</div>
<section class="docstring">
<div class="specs">
<pre translate="no"><span class="attribute">@spec</span> decode_and_verify(
<a href="https://hexdocs.pm/guardian/2.3.2/Guardian.Token.html#t:token/0">Guardian.Token.token</a>(),
<a href="https://hexdocs.pm/guardian/2.3.2/Guardian.Token.html#t:claims/0">Guardian.Token.claims</a>(),
<a href="https://hexdocs.pm/guardian/2.3.2/Guardian.html#t:options/0">Guardian.options</a>()
) ::
{:ok, <a href="https://hexdocs.pm/guardian/2.3.2/Guardian.Token.html#t:claims/0">Guardian.Token.claims</a>()} | {:error, <a href="https://hexdocs.pm/elixir/typespecs.html#basic-types">any</a>()}</pre>
</div>
<p>Decodes and verifies a token using the configuration on the implementation
module.</p><p>See <a href="https://hexdocs.pm/guardian/2.3.2/Guardian.html#decode_and_verify/4"><code class="inline">Guardian.decode_and_verify/4</code></a>.</p>
</section>
</section>
<section class="detail" id="default_token_type/0">
<div class="detail-header">
<a href="#default_token_type/0" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">default_token_type()</h1>
</div>
<section class="docstring">
<div class="specs">
<pre translate="no"><span class="attribute">@spec</span> default_token_type() :: <a href="https://hexdocs.pm/elixir/String.html#t:t/0">String.t</a>()</pre>
</div>
<p>The default type of token for this module.</p>
</section>
</section>
<section class="detail" id="encode_and_sign/3">
<span id="encode_and_sign/1"></span>
<span id="encode_and_sign/2"></span>
<div class="detail-header">
<a href="#encode_and_sign/3" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">encode_and_sign(resource, claims \\ %{}, opts \\ [])</h1>
</div>
<section class="docstring">
<div class="specs">
<pre translate="no"><span class="attribute">@spec</span> encode_and_sign(<a href="https://hexdocs.pm/elixir/typespecs.html#basic-types">any</a>(), <a href="https://hexdocs.pm/guardian/2.3.2/Guardian.Token.html#t:claims/0">Guardian.Token.claims</a>(), <a href="https://hexdocs.pm/guardian/2.3.2/Guardian.html#t:options/0">Guardian.options</a>()) ::
{:ok, <a href="https://hexdocs.pm/guardian/2.3.2/Guardian.Token.html#t:token/0">Guardian.Token.token</a>(), <a href="https://hexdocs.pm/guardian/2.3.2/Guardian.Token.html#t:claims/0">Guardian.Token.claims</a>()} | {:error, <a href="https://hexdocs.pm/elixir/typespecs.html#basic-types">any</a>()}</pre>
</div>
<p>Encodes the claims.</p><p>See <a href="https://hexdocs.pm/guardian/2.3.2/Guardian.html#encode_and_sign/4"><code class="inline">Guardian.encode_and_sign/4</code></a> for more information.</p>
</section>
</section>
<section class="detail" id="exchange/4">
<span id="exchange/3"></span>
<div class="detail-header">
<a href="#exchange/4" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">exchange(token, from_type, to_type, opts \\ [])</h1>
</div>
<section class="docstring">
<div class="specs">
<pre translate="no"><span class="attribute">@spec</span> exchange(
token :: <a href="https://hexdocs.pm/guardian/2.3.2/Guardian.Token.html#t:token/0">Guardian.Token.token</a>(),
from_type :: <a href="https://hexdocs.pm/elixir/String.html#t:t/0">String.t</a>() | [<a href="https://hexdocs.pm/elixir/String.html#t:t/0">String.t</a>(), ...],
to_type :: <a href="https://hexdocs.pm/elixir/String.html#t:t/0">String.t</a>(),
options :: <a href="https://hexdocs.pm/guardian/2.3.2/Guardian.html#t:options/0">Guardian.options</a>()
) ::
{:ok, {<a href="https://hexdocs.pm/guardian/2.3.2/Guardian.Token.html#t:token/0">Guardian.Token.token</a>(), <a href="https://hexdocs.pm/guardian/2.3.2/Guardian.Token.html#t:claims/0">Guardian.Token.claims</a>()},
{<a href="https://hexdocs.pm/guardian/2.3.2/Guardian.Token.html#t:token/0">Guardian.Token.token</a>(), <a href="https://hexdocs.pm/guardian/2.3.2/Guardian.Token.html#t:claims/0">Guardian.Token.claims</a>()}}
| {:error, <a href="https://hexdocs.pm/elixir/typespecs.html#basic-types">any</a>()}</pre>
</div>
<p>Exchanges a token of one type for another.</p><p>See <code class="inline">Guardian.exchange</code> for more information.</p>
</section>
</section>
<section class="detail" id="on_exchange/3">
<div class="detail-header">
<a href="#on_exchange/3" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">on_exchange(old_stuff, new_stuff, options)</h1>
</div>
<section class="docstring">
<p>Callback implementation for <a href="https://hexdocs.pm/guardian/2.3.2/Guardian.html#c:on_exchange/3"><code class="inline">Guardian.on_exchange/3</code></a>.</p>
</section>
</section>
<section class="detail" id="on_refresh/3">
<div class="detail-header">
<a href="#on_refresh/3" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">on_refresh(old_stuff, new_stuff, options)</h1>
</div>
<section class="docstring">
<p>An optional callback invoked when a token is refreshed.</p>
</section>
</section>
<section class="detail" id="on_revoke/3">
<div class="detail-header">
<a href="#on_revoke/3" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">on_revoke(claims, token, options)</h1>
</div>
<section class="docstring">
<p>An optional callback invoked when a token is revoked.</p>
</section>
</section>
<section class="detail" id="on_verify/3">
<div class="detail-header">
<a href="#on_verify/3" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">on_verify(claims, token, options)</h1>
</div>
<section class="docstring">
<p>An optional callback invoked after the claims have been validated.</p>
</section>
</section>
<section class="detail" id="peek/1">
<div class="detail-header">
<a href="#peek/1" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">peek(token)</h1>
</div>
<section class="docstring">
<div class="specs">
<pre translate="no"><span class="attribute">@spec</span> peek(<a href="https://hexdocs.pm/elixir/String.html#t:t/0">String.t</a>()) :: <a href="https://hexdocs.pm/elixir/typespecs.html#basic-types">map</a>()</pre>
</div>
<p>Provides the content of the token but without verification
of either the claims or the signature.</p><p>Claims will be present at the <code class="inline">:claims</code> key.</p><p>See <a href="https://hexdocs.pm/guardian/2.3.2/Guardian.html#peek/2"><code class="inline">Guardian.peek/2</code></a> for more information.</p>
</section>
</section>
<section class="detail" id="refresh/2">
<span id="refresh/1"></span>
<div class="detail-header">
<a href="#refresh/2" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">refresh(old_token, opts \\ [])</h1>
</div>
<section class="docstring">
<div class="specs">
<pre translate="no"><span class="attribute">@spec</span> refresh(<a href="https://hexdocs.pm/guardian/2.3.2/Guardian.Token.html#t:token/0">Guardian.Token.token</a>(), <a href="https://hexdocs.pm/guardian/2.3.2/Guardian.html#t:options/0">Guardian.options</a>()) ::
{:ok, {<a href="https://hexdocs.pm/guardian/2.3.2/Guardian.Token.html#t:token/0">Guardian.Token.token</a>(), <a href="https://hexdocs.pm/guardian/2.3.2/Guardian.Token.html#t:claims/0">Guardian.Token.claims</a>()},
{<a href="https://hexdocs.pm/guardian/2.3.2/Guardian.Token.html#t:token/0">Guardian.Token.token</a>(), <a href="https://hexdocs.pm/guardian/2.3.2/Guardian.Token.html#t:claims/0">Guardian.Token.claims</a>()}}
| {:error, <a href="https://hexdocs.pm/elixir/typespecs.html#basic-types">any</a>()}</pre>
</div>
<p>Refresh a token.</p><p>See <code class="inline">Guardian.refresh</code> for more information.</p>
</section>
</section>
<section class="detail" id="resource_from_claims/1">
<div class="detail-header">
<a href="#resource_from_claims/1" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">resource_from_claims(claims)</h1>
</div>
<section class="docstring">
<p>Fetches the resource that is represented by claims.
For JWT this would normally be found in the <code class="inline">sub</code> field.</p>
</section>
</section>
<section class="detail" id="resource_from_token/3">
<span id="resource_from_token/1"></span>
<span id="resource_from_token/2"></span>
<div class="detail-header">
<a href="#resource_from_token/3" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">resource_from_token(token, claims_to_check \\ %{}, opts \\ [])</h1>
</div>
<section class="docstring">
<div class="specs">
<pre translate="no"><span class="attribute">@spec</span> resource_from_token(
token :: <a href="https://hexdocs.pm/guardian/2.3.2/Guardian.Token.html#t:token/0">Guardian.Token.token</a>(),
claims_to_check :: <a href="https://hexdocs.pm/guardian/2.3.2/Guardian.Token.html#t:claims/0">Guardian.Token.claims</a>() | nil,
opts :: <a href="https://hexdocs.pm/guardian/2.3.2/Guardian.html#t:options/0">Guardian.options</a>()
) :: {:ok, <a href="https://hexdocs.pm/guardian/2.3.2/Guardian.Token.html#t:resource/0">Guardian.Token.resource</a>(), <a href="https://hexdocs.pm/guardian/2.3.2/Guardian.Token.html#t:claims/0">Guardian.Token.claims</a>()} | {:error, <a href="https://hexdocs.pm/elixir/typespecs.html#basic-types">any</a>()}</pre>
</div>
<p>Fetch the resource and claims directly from a token.</p><p>See <code class="inline">Guardian.resource_from_token</code> for more information.</p>
</section>
</section>
<section class="detail" id="revoke/2">
<span id="revoke/1"></span>
<div class="detail-header">
<a href="#revoke/2" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">revoke(token, opts \\ [])</h1>
</div>
<section class="docstring">
<div class="specs">
<pre translate="no"><span class="attribute">@spec</span> revoke(<a href="https://hexdocs.pm/guardian/2.3.2/Guardian.Token.html#t:token/0">Guardian.Token.token</a>(), <a href="https://hexdocs.pm/guardian/2.3.2/Guardian.html#t:options/0">Guardian.options</a>()) ::
{:ok, <a href="https://hexdocs.pm/guardian/2.3.2/Guardian.Token.html#t:claims/0">Guardian.Token.claims</a>()} | {:error, <a href="https://hexdocs.pm/elixir/typespecs.html#basic-types">any</a>()}</pre>
</div>
<p>Revoke a token.</p><p>See <code class="inline">Guardian.revoke</code> for more information.</p>
</section>
</section>
<section class="detail" id="sliding_cookie/3">
<span id="sliding_cookie/2"></span>
<div class="detail-header">
<a href="#sliding_cookie/3" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">sliding_cookie(current_claims, current_resource, opts \\ [])</h1>
</div>
<section class="docstring">
<div class="specs">
<pre translate="no"><span class="attribute">@spec</span> sliding_cookie(
current_claims :: <a href="https://hexdocs.pm/guardian/2.3.2/Guardian.Token.html#t:claims/0">Guardian.Token.claims</a>(),
current_resource :: <a href="https://hexdocs.pm/guardian/2.3.2/Guardian.Token.html#t:resource/0">Guardian.Token.resource</a>(),
options :: <a href="https://hexdocs.pm/guardian/2.3.2/Guardian.html#t:options/0">Guardian.options</a>()
) :: {:ok, new_claims :: <a href="https://hexdocs.pm/guardian/2.3.2/Guardian.Token.html#t:claims/0">Guardian.Token.claims</a>()} | {:error, <a href="https://hexdocs.pm/elixir/typespecs.html#basic-types">any</a>()}</pre>
</div>
<p>If Guardian.Plug.SlidingCookie is used, this callback will be invoked to
return the new claims, or an error (which will mean the cookie will not
be refreshed).</p>
</section>
</section>
<section class="detail" id="subject_for_token/2">
<div class="detail-header">
<a href="#subject_for_token/2" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">subject_for_token(arg1, arg2)</h1>
</div>
<section class="docstring">
<p>Fetches the subject for a token for the provided resource and claims
The subject should be a short identifier that can be used to identify
the resource.</p>
</section>
</section>
<section class="detail" id="verify_claims/2">
<div class="detail-header">
<a href="#verify_claims/2" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">verify_claims(claims, options)</h1>
</div>
<section class="docstring">
<p>Callback implementation for <a href="https://hexdocs.pm/guardian/2.3.2/Guardian.html#c:verify_claims/2"><code class="inline">Guardian.verify_claims/2</code></a>.</p>
</section>
</section>
</div>
</section>
<footer class="footer">
<p>
<span class="line">
<button class="a-main footer-button display-quick-switch" title="Search HexDocs packages">
Search HexDocs
</button>
<a href="epochtalk_server.epub" title="ePub version">
Download ePub version
</a>
</span>
</p>
<p class="built-using">
Built using