fastapi-auth-saml-federated 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. fastapi_auth_saml_federated-0.2.0/LICENSE-APACHE +202 -0
  2. fastapi_auth_saml_federated-0.2.0/LICENSE-EUPL +287 -0
  3. fastapi_auth_saml_federated-0.2.0/PKG-INFO +181 -0
  4. fastapi_auth_saml_federated-0.2.0/README.md +127 -0
  5. fastapi_auth_saml_federated-0.2.0/pyproject.toml +104 -0
  6. fastapi_auth_saml_federated-0.2.0/setup.cfg +4 -0
  7. fastapi_auth_saml_federated-0.2.0/src/fastapi_auth/saml/__init__.py +36 -0
  8. fastapi_auth_saml_federated-0.2.0/src/fastapi_auth/saml/discovery/__init__.py +4 -0
  9. fastapi_auth_saml_federated-0.2.0/src/fastapi_auth/saml/discovery/embedded.py +40 -0
  10. fastapi_auth_saml_federated-0.2.0/src/fastapi_auth/saml/discovery/external.py +32 -0
  11. fastapi_auth_saml_federated-0.2.0/src/fastapi_auth/saml/engine/__init__.py +4 -0
  12. fastapi_auth_saml_federated-0.2.0/src/fastapi_auth/saml/engine/authn_context.py +148 -0
  13. fastapi_auth_saml_federated-0.2.0/src/fastapi_auth/saml/engine/client.py +231 -0
  14. fastapi_auth_saml_federated-0.2.0/src/fastapi_auth/saml/engine/config.py +107 -0
  15. fastapi_auth_saml_federated-0.2.0/src/fastapi_auth/saml/engine/enforcement.py +25 -0
  16. fastapi_auth_saml_federated-0.2.0/src/fastapi_auth/saml/engine/entity_categories.py +35 -0
  17. fastapi_auth_saml_federated-0.2.0/src/fastapi_auth/saml/engine/errors.py +19 -0
  18. fastapi_auth_saml_federated-0.2.0/src/fastapi_auth/saml/engine/logout.py +73 -0
  19. fastapi_auth_saml_federated-0.2.0/src/fastapi_auth/saml/factory.py +44 -0
  20. fastapi_auth_saml_federated-0.2.0/src/fastapi_auth/saml/identity/__init__.py +4 -0
  21. fastapi_auth_saml_federated-0.2.0/src/fastapi_auth/saml/identity/identifier.py +29 -0
  22. fastapi_auth_saml_federated-0.2.0/src/fastapi_auth/saml/identity/mapper.py +50 -0
  23. fastapi_auth_saml_federated-0.2.0/src/fastapi_auth/saml/identity/model.py +57 -0
  24. fastapi_auth_saml_federated-0.2.0/src/fastapi_auth/saml/identity/registry.py +133 -0
  25. fastapi_auth_saml_federated-0.2.0/src/fastapi_auth/saml/py.typed +0 -0
  26. fastapi_auth_saml_federated-0.2.0/src/fastapi_auth/saml/redirect.py +27 -0
  27. fastapi_auth_saml_federated-0.2.0/src/fastapi_auth/saml/router.py +198 -0
  28. fastapi_auth_saml_federated-0.2.0/src/fastapi_auth/saml/session/__init__.py +4 -0
  29. fastapi_auth_saml_federated-0.2.0/src/fastapi_auth/saml/session/base.py +28 -0
  30. fastapi_auth_saml_federated-0.2.0/src/fastapi_auth/saml/session/cookie.py +95 -0
  31. fastapi_auth_saml_federated-0.2.0/src/fastapi_auth/saml/session/csrf.py +37 -0
  32. fastapi_auth_saml_federated-0.2.0/src/fastapi_auth/saml/session/jwt.py +89 -0
  33. fastapi_auth_saml_federated-0.2.0/src/fastapi_auth/saml/session/postgres_store.py +168 -0
  34. fastapi_auth_saml_federated-0.2.0/src/fastapi_auth/saml/session/redis_store.py +100 -0
  35. fastapi_auth_saml_federated-0.2.0/src/fastapi_auth/saml/session/store.py +121 -0
  36. fastapi_auth_saml_federated-0.2.0/src/fastapi_auth/saml/settings.py +220 -0
  37. fastapi_auth_saml_federated-0.2.0/src/fastapi_auth/saml/sp.py +118 -0
  38. fastapi_auth_saml_federated-0.2.0/src/fastapi_auth/saml/wayf/__init__.py +4 -0
  39. fastapi_auth_saml_federated-0.2.0/src/fastapi_auth/saml/wayf/templates/logout.html +15 -0
  40. fastapi_auth_saml_federated-0.2.0/src/fastapi_auth/saml/wayf/templates/wayf.html +15 -0
  41. fastapi_auth_saml_federated-0.2.0/src/fastapi_auth_saml_federated.egg-info/PKG-INFO +181 -0
  42. fastapi_auth_saml_federated-0.2.0/src/fastapi_auth_saml_federated.egg-info/SOURCES.txt +59 -0
  43. fastapi_auth_saml_federated-0.2.0/src/fastapi_auth_saml_federated.egg-info/dependency_links.txt +1 -0
  44. fastapi_auth_saml_federated-0.2.0/src/fastapi_auth_saml_federated.egg-info/requires.txt +39 -0
  45. fastapi_auth_saml_federated-0.2.0/src/fastapi_auth_saml_federated.egg-info/top_level.txt +1 -0
  46. fastapi_auth_saml_federated-0.2.0/tests/test_factory.py +31 -0
  47. fastapi_auth_saml_federated-0.2.0/tests/test_factory_missing_extra.py +72 -0
  48. fastapi_auth_saml_federated-0.2.0/tests/test_idp_initiated_flow.py +266 -0
  49. fastapi_auth_saml_federated-0.2.0/tests/test_mount_path.py +30 -0
  50. fastapi_auth_saml_federated-0.2.0/tests/test_redirect.py +36 -0
  51. fastapi_auth_saml_federated-0.2.0/tests/test_router_authn_context.py +107 -0
  52. fastapi_auth_saml_federated-0.2.0/tests/test_router_discovery_flow.py +143 -0
  53. fastapi_auth_saml_federated-0.2.0/tests/test_router_enforcement_flow.py +60 -0
  54. fastapi_auth_saml_federated-0.2.0/tests/test_router_error_handling.py +43 -0
  55. fastapi_auth_saml_federated-0.2.0/tests/test_router_jwt_flow.py +45 -0
  56. fastapi_auth_saml_federated-0.2.0/tests/test_router_login_flow.py +153 -0
  57. fastapi_auth_saml_federated-0.2.0/tests/test_scaffold.py +16 -0
  58. fastapi_auth_saml_federated-0.2.0/tests/test_settings.py +228 -0
  59. fastapi_auth_saml_federated-0.2.0/tests/test_slo.py +377 -0
  60. fastapi_auth_saml_federated-0.2.0/tests/test_sp_identifier.py +33 -0
  61. fastapi_auth_saml_federated-0.2.0/tests/test_sp_mount.py +49 -0
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,287 @@
1
+ EUROPEAN UNION PUBLIC LICENCE v. 1.2
2
+ EUPL © the European Union 2007, 2016
3
+
4
+ This European Union Public Licence (the ‘EUPL’) applies to the Work (as defined
5
+ below) which is provided under the terms of this Licence. Any use of the Work,
6
+ other than as authorised under this Licence is prohibited (to the extent such
7
+ use is covered by a right of the copyright holder of the Work).
8
+
9
+ The Work is provided under the terms of this Licence when the Licensor (as
10
+ defined below) has placed the following notice immediately following the
11
+ copyright notice for the Work:
12
+
13
+ Licensed under the EUPL
14
+
15
+ or has expressed by any other means his willingness to license under the EUPL.
16
+
17
+ 1. Definitions
18
+
19
+ In this Licence, the following terms have the following meaning:
20
+
21
+ - ‘The Licence’: this Licence.
22
+
23
+ - ‘The Original Work’: the work or software distributed or communicated by the
24
+ Licensor under this Licence, available as Source Code and also as Executable
25
+ Code as the case may be.
26
+
27
+ - ‘Derivative Works’: the works or software that could be created by the
28
+ Licensee, based upon the Original Work or modifications thereof. This Licence
29
+ does not define the extent of modification or dependence on the Original Work
30
+ required in order to classify a work as a Derivative Work; this extent is
31
+ determined by copyright law applicable in the country mentioned in Article 15.
32
+
33
+ - ‘The Work’: the Original Work or its Derivative Works.
34
+
35
+ - ‘The Source Code’: the human-readable form of the Work which is the most
36
+ convenient for people to study and modify.
37
+
38
+ - ‘The Executable Code’: any code which has generally been compiled and which is
39
+ meant to be interpreted by a computer as a program.
40
+
41
+ - ‘The Licensor’: the natural or legal person that distributes or communicates
42
+ the Work under the Licence.
43
+
44
+ - ‘Contributor(s)’: any natural or legal person who modifies the Work under the
45
+ Licence, or otherwise contributes to the creation of a Derivative Work.
46
+
47
+ - ‘The Licensee’ or ‘You’: any natural or legal person who makes any usage of
48
+ the Work under the terms of the Licence.
49
+
50
+ - ‘Distribution’ or ‘Communication’: any act of selling, giving, lending,
51
+ renting, distributing, communicating, transmitting, or otherwise making
52
+ available, online or offline, copies of the Work or providing access to its
53
+ essential functionalities at the disposal of any other natural or legal
54
+ person.
55
+
56
+ 2. Scope of the rights granted by the Licence
57
+
58
+ The Licensor hereby grants You a worldwide, royalty-free, non-exclusive,
59
+ sublicensable licence to do the following, for the duration of copyright vested
60
+ in the Original Work:
61
+
62
+ - use the Work in any circumstance and for all usage,
63
+ - reproduce the Work,
64
+ - modify the Work, and make Derivative Works based upon the Work,
65
+ - communicate to the public, including the right to make available or display
66
+ the Work or copies thereof to the public and perform publicly, as the case may
67
+ be, the Work,
68
+ - distribute the Work or copies thereof,
69
+ - lend and rent the Work or copies thereof,
70
+ - sublicense rights in the Work or copies thereof.
71
+
72
+ Those rights can be exercised on any media, supports and formats, whether now
73
+ known or later invented, as far as the applicable law permits so.
74
+
75
+ In the countries where moral rights apply, the Licensor waives his right to
76
+ exercise his moral right to the extent allowed by law in order to make effective
77
+ the licence of the economic rights here above listed.
78
+
79
+ The Licensor grants to the Licensee royalty-free, non-exclusive usage rights to
80
+ any patents held by the Licensor, to the extent necessary to make use of the
81
+ rights granted on the Work under this Licence.
82
+
83
+ 3. Communication of the Source Code
84
+
85
+ The Licensor may provide the Work either in its Source Code form, or as
86
+ Executable Code. If the Work is provided as Executable Code, the Licensor
87
+ provides in addition a machine-readable copy of the Source Code of the Work
88
+ along with each copy of the Work that the Licensor distributes or indicates, in
89
+ a notice following the copyright notice attached to the Work, a repository where
90
+ the Source Code is easily and freely accessible for as long as the Licensor
91
+ continues to distribute or communicate the Work.
92
+
93
+ 4. Limitations on copyright
94
+
95
+ Nothing in this Licence is intended to deprive the Licensee of the benefits from
96
+ any exception or limitation to the exclusive rights of the rights owners in the
97
+ Work, of the exhaustion of those rights or of other applicable limitations
98
+ thereto.
99
+
100
+ 5. Obligations of the Licensee
101
+
102
+ The grant of the rights mentioned above is subject to some restrictions and
103
+ obligations imposed on the Licensee. Those obligations are the following:
104
+
105
+ Attribution right: The Licensee shall keep intact all copyright, patent or
106
+ trademarks notices and all notices that refer to the Licence and to the
107
+ disclaimer of warranties. The Licensee must include a copy of such notices and a
108
+ copy of the Licence with every copy of the Work he/she distributes or
109
+ communicates. The Licensee must cause any Derivative Work to carry prominent
110
+ notices stating that the Work has been modified and the date of modification.
111
+
112
+ Copyleft clause: If the Licensee distributes or communicates copies of the
113
+ Original Works or Derivative Works, this Distribution or Communication will be
114
+ done under the terms of this Licence or of a later version of this Licence
115
+ unless the Original Work is expressly distributed only under this version of the
116
+ Licence — for example by communicating ‘EUPL v. 1.2 only’. The Licensee
117
+ (becoming Licensor) cannot offer or impose any additional terms or conditions on
118
+ the Work or Derivative Work that alter or restrict the terms of the Licence.
119
+
120
+ Compatibility clause: If the Licensee Distributes or Communicates Derivative
121
+ Works or copies thereof based upon both the Work and another work licensed under
122
+ a Compatible Licence, this Distribution or Communication can be done under the
123
+ terms of this Compatible Licence. For the sake of this clause, ‘Compatible
124
+ Licence’ refers to the licences listed in the appendix attached to this Licence.
125
+ Should the Licensee's obligations under the Compatible Licence conflict with
126
+ his/her obligations under this Licence, the obligations of the Compatible
127
+ Licence shall prevail.
128
+
129
+ Provision of Source Code: When distributing or communicating copies of the Work,
130
+ the Licensee will provide a machine-readable copy of the Source Code or indicate
131
+ a repository where this Source will be easily and freely available for as long
132
+ as the Licensee continues to distribute or communicate the Work.
133
+
134
+ Legal Protection: This Licence does not grant permission to use the trade names,
135
+ trademarks, service marks, or names of the Licensor, except as required for
136
+ reasonable and customary use in describing the origin of the Work and
137
+ reproducing the content of the copyright notice.
138
+
139
+ 6. Chain of Authorship
140
+
141
+ The original Licensor warrants that the copyright in the Original Work granted
142
+ hereunder is owned by him/her or licensed to him/her and that he/she has the
143
+ power and authority to grant the Licence.
144
+
145
+ Each Contributor warrants that the copyright in the modifications he/she brings
146
+ to the Work are owned by him/her or licensed to him/her and that he/she has the
147
+ power and authority to grant the Licence.
148
+
149
+ Each time You accept the Licence, the original Licensor and subsequent
150
+ Contributors grant You a licence to their contributions to the Work, under the
151
+ terms of this Licence.
152
+
153
+ 7. Disclaimer of Warranty
154
+
155
+ The Work is a work in progress, which is continuously improved by numerous
156
+ Contributors. It is not a finished work and may therefore contain defects or
157
+ ‘bugs’ inherent to this type of development.
158
+
159
+ For the above reason, the Work is provided under the Licence on an ‘as is’ basis
160
+ and without warranties of any kind concerning the Work, including without
161
+ limitation merchantability, fitness for a particular purpose, absence of defects
162
+ or errors, accuracy, non-infringement of intellectual property rights other than
163
+ copyright as stated in Article 6 of this Licence.
164
+
165
+ This disclaimer of warranty is an essential part of the Licence and a condition
166
+ for the grant of any rights to the Work.
167
+
168
+ 8. Disclaimer of Liability
169
+
170
+ Except in the cases of wilful misconduct or damages directly caused to natural
171
+ persons, the Licensor will in no event be liable for any direct or indirect,
172
+ material or moral, damages of any kind, arising out of the Licence or of the use
173
+ of the Work, including without limitation, damages for loss of goodwill, work
174
+ stoppage, computer failure or malfunction, loss of data or any commercial
175
+ damage, even if the Licensor has been advised of the possibility of such damage.
176
+ However, the Licensor will be liable under statutory product liability laws as
177
+ far such laws apply to the Work.
178
+
179
+ 9. Additional agreements
180
+
181
+ While distributing the Work, You may choose to conclude an additional agreement,
182
+ defining obligations or services consistent with this Licence. However, if
183
+ accepting obligations, You may act only on your own behalf and on your sole
184
+ responsibility, not on behalf of the original Licensor or any other Contributor,
185
+ and only if You agree to indemnify, defend, and hold each Contributor harmless
186
+ for any liability incurred by, or claims asserted against such Contributor by
187
+ the fact You have accepted any warranty or additional liability.
188
+
189
+ 10. Acceptance of the Licence
190
+
191
+ The provisions of this Licence can be accepted by clicking on an icon ‘I agree’
192
+ placed under the bottom of a window displaying the text of this Licence or by
193
+ affirming consent in any other similar way, in accordance with the rules of
194
+ applicable law. Clicking on that icon indicates your clear and irrevocable
195
+ acceptance of this Licence and all of its terms and conditions.
196
+
197
+ Similarly, you irrevocably accept this Licence and all of its terms and
198
+ conditions by exercising any rights granted to You by Article 2 of this Licence,
199
+ such as the use of the Work, the creation by You of a Derivative Work or the
200
+ Distribution or Communication by You of the Work or copies thereof.
201
+
202
+ 11. Information to the public
203
+
204
+ In case of any Distribution or Communication of the Work by means of electronic
205
+ communication by You (for example, by offering to download the Work from a
206
+ remote location) the distribution channel or media (for example, a website) must
207
+ at least provide to the public the information requested by the applicable law
208
+ regarding the Licensor, the Licence and the way it may be accessible, concluded,
209
+ stored and reproduced by the Licensee.
210
+
211
+ 12. Termination of the Licence
212
+
213
+ The Licence and the rights granted hereunder will terminate automatically upon
214
+ any breach by the Licensee of the terms of the Licence.
215
+
216
+ Such a termination will not terminate the licences of any person who has
217
+ received the Work from the Licensee under the Licence, provided such persons
218
+ remain in full compliance with the Licence.
219
+
220
+ 13. Miscellaneous
221
+
222
+ Without prejudice of Article 9 above, the Licence represents the complete
223
+ agreement between the Parties as to the Work.
224
+
225
+ If any provision of the Licence is invalid or unenforceable under applicable
226
+ law, this will not affect the validity or enforceability of the Licence as a
227
+ whole. Such provision will be construed or reformed so as necessary to make it
228
+ valid and enforceable.
229
+
230
+ The European Commission may publish other linguistic versions or new versions of
231
+ this Licence or updated versions of the Appendix, so far this is required and
232
+ reasonable, without reducing the scope of the rights granted by the Licence. New
233
+ versions of the Licence will be published with a unique version number.
234
+
235
+ All linguistic versions of this Licence, approved by the European Commission,
236
+ have identical value. Parties can take advantage of the linguistic version of
237
+ their choice.
238
+
239
+ 14. Jurisdiction
240
+
241
+ Without prejudice to specific agreement between parties,
242
+
243
+ - any litigation resulting from the interpretation of this License, arising
244
+ between the European Union institutions, bodies, offices or agencies, as a
245
+ Licensor, and any Licensee, will be subject to the jurisdiction of the Court
246
+ of Justice of the European Union, as laid down in article 272 of the Treaty on
247
+ the Functioning of the European Union,
248
+
249
+ - any litigation arising between other parties and resulting from the
250
+ interpretation of this License, will be subject to the exclusive jurisdiction
251
+ of the competent court where the Licensor resides or conducts its primary
252
+ business.
253
+
254
+ 15. Applicable Law
255
+
256
+ Without prejudice to specific agreement between parties,
257
+
258
+ - this Licence shall be governed by the law of the European Union Member State
259
+ where the Licensor has his seat, resides or has his registered office,
260
+
261
+ - this licence shall be governed by Belgian law if the Licensor has no seat,
262
+ residence or registered office inside a European Union Member State.
263
+
264
+ Appendix
265
+
266
+ ‘Compatible Licences’ according to Article 5 EUPL are:
267
+
268
+ - GNU General Public License (GPL) v. 2, v. 3
269
+ - GNU Affero General Public License (AGPL) v. 3
270
+ - Open Software License (OSL) v. 2.1, v. 3.0
271
+ - Eclipse Public License (EPL) v. 1.0
272
+ - CeCILL v. 2.0, v. 2.1
273
+ - Mozilla Public Licence (MPL) v. 2
274
+ - GNU Lesser General Public Licence (LGPL) v. 2.1, v. 3
275
+ - Creative Commons Attribution-ShareAlike v. 3.0 Unported (CC BY-SA 3.0) for
276
+ works other than software
277
+ - European Union Public Licence (EUPL) v. 1.1, v. 1.2
278
+ - Québec Free and Open-Source Licence — Reciprocity (LiLiQ-R) or Strong
279
+ Reciprocity (LiLiQ-R+).
280
+
281
+ The European Commission may update this Appendix to later versions of the above
282
+ licences without producing a new version of the EUPL, as long as they provide
283
+ the rights granted in Article 2 of this Licence and protect the covered Source
284
+ Code from exclusive appropriation.
285
+
286
+ All other changes or additions to this Appendix require the production of a new
287
+ EUPL version.
@@ -0,0 +1,181 @@
1
+ Metadata-Version: 2.4
2
+ Name: fastapi-auth-saml-federated
3
+ Version: 0.2.0
4
+ Summary: Federated SAML2 Service Provider for FastAPI (Shibboleth/eduGAIN/NREN AAIs)
5
+ Author-email: Alexander Loechel <Alexander.Loechel@lmu.de>
6
+ License-Expression: Apache-2.0 OR EUPL-1.2
7
+ Project-URL: Repository, https://github.com/edutap-collective/fastapi-auth-saml-federated
8
+ Project-URL: Changelog, https://github.com/edutap-collective/fastapi-auth-saml-federated/blob/main/CHANGELOG.md
9
+ Keywords: saml,saml2,shibboleth,edugain,fastapi,sso,federation,eduperson,schac
10
+ Classifier: Framework :: FastAPI
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Classifier: Topic :: System :: Systems Administration :: Authentication/Directory
14
+ Requires-Python: >=3.12
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE-APACHE
17
+ License-File: LICENSE-EUPL
18
+ Requires-Dist: fastapi>=0.115
19
+ Requires-Dist: pydantic>=2.7
20
+ Requires-Dist: pydantic-settings>=2.3
21
+ Requires-Dist: pysaml2>=7.5.4
22
+ Requires-Dist: itsdangerous>=2.2
23
+ Requires-Dist: anyio>=4
24
+ Requires-Dist: httpx>=0.27
25
+ Requires-Dist: python-multipart>=0.0.9
26
+ Requires-Dist: pyjwt>=2.8
27
+ Requires-Dist: jinja2>=3.1
28
+ Provides-Extra: redis
29
+ Requires-Dist: redis>=5; extra == "redis"
30
+ Provides-Extra: postgres
31
+ Requires-Dist: sqlmodel>=0.0.22; extra == "postgres"
32
+ Requires-Dist: asyncpg>=0.29; extra == "postgres"
33
+ Requires-Dist: greenlet; extra == "postgres"
34
+ Provides-Extra: docs
35
+ Requires-Dist: sphinx>=7; extra == "docs"
36
+ Requires-Dist: myst-parser>=3; extra == "docs"
37
+ Requires-Dist: furo>=2024.0; extra == "docs"
38
+ Provides-Extra: dev
39
+ Requires-Dist: pytest>=8; extra == "dev"
40
+ Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
41
+ Requires-Dist: anyio>=4; extra == "dev"
42
+ Requires-Dist: respx>=0.21; extra == "dev"
43
+ Requires-Dist: responses>=0.25; extra == "dev"
44
+ Requires-Dist: httpx>=0.27; extra == "dev"
45
+ Requires-Dist: ruff>=0.6; extra == "dev"
46
+ Requires-Dist: ty; extra == "dev"
47
+ Requires-Dist: pdbp>=1.5; extra == "dev"
48
+ Requires-Dist: fakeredis>=2.20; extra == "dev"
49
+ Requires-Dist: aiosqlite>=0.20; extra == "dev"
50
+ Requires-Dist: redis>=5; extra == "dev"
51
+ Requires-Dist: sqlmodel>=0.0.22; extra == "dev"
52
+ Requires-Dist: greenlet; extra == "dev"
53
+ Dynamic: license-file
54
+
55
+ # fastapi-auth-saml-federated
56
+
57
+ Federated SAML2 Service Provider for FastAPI — Shibboleth / eduGAIN / NREN AAIs
58
+ (DFN-AAI, SWITCHaai, SURFconext, SWAMID). Part of the `fastapi_auth` package family.
59
+
60
+ ## Install
61
+
62
+ The SP shells out to the `xmlsec1` command-line tool for XML signing/verification
63
+ (via `pysaml2`) — install it via your system package manager first:
64
+
65
+ ```bash
66
+ sudo apt-get install --no-install-recommends xmlsec1 # Debian/Ubuntu
67
+ ```
68
+
69
+ Then the package:
70
+
71
+ ```bash
72
+ uv pip install fastapi-auth-saml-federated
73
+ ```
74
+
75
+ The session store is pluggable; the default in-memory store needs nothing extra,
76
+ Redis- or Postgres-backed stores need their extra (see [Backends](#backends)):
77
+
78
+ ```bash
79
+ uv pip install "fastapi-auth-saml-federated[redis]"
80
+ uv pip install "fastapi-auth-saml-federated[postgres]"
81
+ ```
82
+
83
+ ## Quickstart
84
+
85
+ ```python
86
+ from fastapi import Depends, FastAPI
87
+
88
+ from fastapi_auth import saml
89
+
90
+ app = FastAPI()
91
+
92
+ sp = saml.SamlSP(
93
+ saml.SamlSettings(
94
+ entity_id="https://sp.example.org/saml/metadata",
95
+ base_url="https://sp.example.org",
96
+ key_file="sp-key.pem",
97
+ cert_file="sp-cert.pem",
98
+ idp_metadata_file="idp-metadata.xml",
99
+ fixed_idp_entity_id="https://idp.example.org/idp/shibboleth",
100
+ session_secret="change-me-to-a-long-random-value",
101
+ )
102
+ )
103
+ sp.mount(app)
104
+ # equivalent to: app.include_router(sp.router, prefix=sp.settings.mount_path)
105
+ # -- only use include_router() directly if prefix matches settings.mount_path exactly.
106
+
107
+ current_user = sp.current_user()
108
+
109
+
110
+ @app.get("/whoami")
111
+ async def whoami(identity: saml.FederatedIdentity = Depends(current_user)):
112
+ return {"subject": sp.identifier(identity)}
113
+ ```
114
+
115
+ `sp.current_user()` is a dependency raising `401` without an active session;
116
+ `sp.optional_user()` returns the identity or `None` instead.
117
+
118
+ ## Development
119
+
120
+ ```bash
121
+ uv venv && source .venv/bin/activate
122
+ make install # uv pip install -U -e ".[dev]"
123
+ make test-local
124
+ ```
125
+
126
+ ## Docker
127
+
128
+ A multi-stage `Dockerfile` (slim runtime image, `xmlsec1` baked in) and a
129
+ `compose.yml` (Redis + Postgres, for exercising the store backends against the real
130
+ thing) are provided:
131
+
132
+ ```bash
133
+ docker build -t fastapi-auth-saml-federated .
134
+ make test-integration # docker compose up -d --wait, run integration tests, teardown
135
+ ```
136
+
137
+ See `docs/howto/docker.md` for details, including local port overrides via
138
+ `compose.override.yml`.
139
+
140
+ ## Backends
141
+
142
+ Session **backend** (`cookie` default, or `jwt`) and session **store**
143
+ (`memory` default, or `redis`/`postgres`) are chosen independently via
144
+ `SamlSettings(backend=..., store=..., redis_url=..., db_url=...)`. The `jwt` backend
145
+ requires a signing secret of at least 32 bytes. See `docs/howto/stores.md` for the
146
+ full trade-offs and extras.
147
+
148
+ ## Federation
149
+
150
+ Metadata can come from a single bilateral IdP (`metadata_source="direct"`) or from a
151
+ federation (`"aggregate"` / `"mdq"`); the latter two require a `trust_anchor_cert` to
152
+ verify signatures on metadata fetched over the network. Discovery of the right IdP
153
+ is `"passthrough"` (single fixed IdP), `"external"` (redirect to a federation
154
+ Discovery Service via `ds_url`), or `"embedded"` (a WAYF page rendered by the SP
155
+ itself). See the how-tos for testing against a local SimpleSAMLphp IdP, the
156
+ LMU `lmuidp-container` (Shibboleth), and the DFN-AAI test federation.
157
+
158
+ ## Authentication context and logout
159
+
160
+ A login can request an authentication context such as REFEDS MFA and have the
161
+ asserted one checked -- per login via `SamlEngine`, or for the whole router via
162
+ `SamlSP(settings, requested_authn_context=...)`; see `docs/howto/authn-context.md`.
163
+ Logging out is a `POST` to `{mount_path}/slo` with a CSRF token;
164
+ `GET {mount_path}/slo` only renders a confirmation form (`docs/howto/logout.md`).
165
+
166
+ ## Docs
167
+
168
+ Full documentation (Sphinx + MyST) lives in `docs/`:
169
+
170
+ ```bash
171
+ uv pip install -U -e ".[docs]"
172
+ uv run sphinx-build -b html docs docs/_build
173
+ ```
174
+
175
+ Open `docs/_build/index.html`, or read the sources directly under `docs/index.md`
176
+ and `docs/howto/`.
177
+
178
+ ## License
179
+
180
+ Dual-licensed: **Apache-2.0 OR EUPL-1.2** — the recipient may choose either.
181
+ See `LICENSE-APACHE` and `LICENSE-EUPL`.