Commit b85faf0
Sem-Ver: api-break Rework Django and Flask support
Previously, contributors introduced Django and Flask support via
differing implementations into the contrib/ package. The implementations
were similar (sometimes almost copied and pasted from one another) but
also diverged in terms of their functionality and feature sets.
This change's primary goal is to take the contrib/{django,flask} and
refactor them into a shared implementation with framework-specific
backends to abstract away the differences between the two. To
demonstrate this formalization of support for these frameworks, they
have also been moved from contrib into frameworks/{django,flask}.
In addition the following changes were made in this commit:
- Django and Flask decorators no longer require an issuer to be present
in BOTH the global setting and the decorator argument to be valid.
Decorator arguments now override the global setting.
- The proxied middleware seems like a one-off special case and remains
in contrib while a more general ASAP middleware which applies the
decorator logic to all views is included in the supported package.
- The @require_asap decorator has been renamed to @with_asap since you
can technically pass the required=False argument to make ASAP not
enforced.
- The @validate_asap decorator has been renamed to a more descriptive
@restrict_asap to symbolize that it applies additional restrictions onto
an already processed ASAP authenticated request.
- The 'subjects' arg to the @validate_asap decorator has been removed
since it appears to be unused and is inconsistent with the existing
@with_asap decorator.
Sem-Ver: api-break
frameworks: Rework how settings overrides work
Instead of passing in an argument for each overrideable setting all the
way down the functional call chain when using the decorators, this
change duplicates the settings object and then overrides the applicable
properties and passes that settings object in to the validation code.
The following changes are also included in this commit:
- SettingsDict attributes are now immutable
- ASAP_VALID_ISSUERS is now converted into a set
Fixed a typo in comment
Remove an unused import
Refactored some of the common logic into something simpler
pep8 fix up.
Signed-off-by: David Black <dblack@atlassian.com>
_validate_claims does not need to perform the subject and issuer check as that has already been done by the verifier.
Signed-off-by: David Black <dblack@atlassian.com>
s/_validate_claims/_verify_issuers/
Signed-off-by: David Black <dblack@atlassian.com>
delete the server helpers module as it is no longer used.
Signed-off-by: David Black <dblack@atlassian.com>
Slightly less churn in the the flask tests.
Signed-off-by: David Black <dblack@atlassian.com>
style fix up.
Signed-off-by: David Black <dblack@atlassian.com>
Sem-Ver: feature Restore the previous requires_asap decorators to make migration easier.
Signed-off-by: David Black <dblack@atlassian.com>
set required to True by default.
Signed-off-by: David Black <dblack@atlassian.com>
make func the last argument.
Signed-off-by: David Black <dblack@atlassian.com>
default ASAP_SUBJECT_SHOULD_MATCH_ISSUER to None.
Signed-off-by: David Black <dblack@atlassian.com>
also default to required=True in _update_settings_from_kwargs.
Signed-off-by: David Black <dblack@atlassian.com>
restore the restricted_subject_view test.
Signed-off-by: David Black <dblack@atlassian.com>
frameworks: Rework how settings overrides work
Instead of passing in an argument for each overrideable setting all the
way down the functional call chain when using the decorators, this
change duplicates the settings object and then overrides the applicable
properties and passes that settings object in to the validation code.
The following changes are also included in this commit:
- SettingsDict attributes are now immutable
- ASAP_VALID_ISSUERS is now converted into a set
Fixed a typo in comment
Remove an unused import
Refactored some of the common logic into something simpler
Add usage of django.utils.deprecation.MiddlewareMixin to ProxiedAsapMiddleware
Move NoTokenProvidedError to the top exceptions module.
Signed-off-by: David Black <dblack@atlassian.com>
(cherry picked from commit 36bab18)
Move the contrib deprecation warnings to the respective deprecated __init__.py files.
Signed-off-by: David Black <dblack@atlassian.com>
Move NoTokenProvidedError to the top exceptions module.
Signed-off-by: David Black <dblack@atlassian.com>1 parent 93879d4 commit b85faf0
29 files changed
Lines changed: 559 additions & 304 deletions
File tree
- atlassian_jwt_auth
- contrib
- django
- flask_app
- server
- frameworks
- common
- django
- tests
- flask
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | 3 | | |
5 | 4 | | |
6 | | - | |
7 | | - | |
8 | | - | |
| 5 | + | |
9 | 6 | | |
10 | 7 | | |
11 | 8 | | |
| |||
46 | 43 | | |
47 | 44 | | |
48 | 45 | | |
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 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
| 13 | + | |
17 | 14 | | |
18 | 15 | | |
| 16 | + | |
19 | 17 | | |
20 | 18 | | |
21 | 19 | | |
| |||
27 | 25 | | |
28 | 26 | | |
29 | 27 | | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
37 | 36 | | |
38 | 37 | | |
39 | 38 | | |
| |||
62 | 61 | | |
63 | 62 | | |
64 | 63 | | |
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 | | - | |
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | | - | |
4 | 3 | | |
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 | | - | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
File renamed without changes.
0 commit comments