Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Official
AlekSIS-Core
Commits
019d4a4c
Verified
Commit
019d4a4c
authored
3 years ago
by
Nik | Klampfradler
Committed by
Jonathan Weth
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Turn get_*_scopes methods into classmethods
(cherry picked from commit
6593c34b
)
parent
b4db5802
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!733
Prepare release 2.0rc6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
aleksis/core/apps.py
+16
-0
16 additions, 0 deletions
aleksis/core/apps.py
aleksis/core/util/apps.py
+27
-0
27 additions, 0 deletions
aleksis/core/util/apps.py
with
43 additions
and
0 deletions
aleksis/core/apps.py
+
16
−
0
View file @
019d4a4c
...
...
@@ -136,3 +136,19 @@ class CoreConfig(AppConfig):
if
has_person
(
user
):
# Save the associated person to pick up defaults
user
.
person
.
save
()
@classmethod
def
get_all_scopes
(
cls
)
->
dict
[
str
,
str
]:
scopes
=
{
"
read
"
:
"
Read anything the resource owner can read
"
,
"
write
"
:
"
Write anything the resource owner can write
"
,
}
if
settings
.
OAUTH2_PROVIDER
.
get
(
"
OIDC_ENABLED
"
,
False
):
scopes
|=
{
"
openid
"
:
_
(
"
OpenID Connect scope
"
),
"
profile
"
:
_
(
"
Given name, family name, link to profile and picture if existing.
"
),
"
address
"
:
_
(
"
Full home postal address
"
),
"
email
"
:
_
(
"
Email address
"
),
"
phone
"
:
_
(
"
Home and mobile phone
"
),
}
return
scopes
This diff is collapsed.
Click to expand it.
aleksis/core/util/apps.py
+
27
−
0
View file @
019d4a4c
...
...
@@ -214,6 +214,33 @@ class AppConfig(django.apps.AppConfig):
"""
pass
@classmethod
def
get_all_scopes
(
cls
)
->
dict
[
str
,
str
]:
"""
Return all OAuth scopes and their descriptions for this app.
"""
return
{}
@classmethod
def
get_available_scopes
(
cls
,
application
:
Optional
[
"
AbstractApplication
"
]
=
None
,
request
:
Optional
[
HttpRequest
]
=
None
,
*
args
,
**
kwargs
,
)
->
list
[
str
]:
"""
Return a list of all OAuth scopes available to the request and application.
"""
return
list
(
cls
.
get_all_scopes
().
keys
())
@classmethod
def
get_default_scopes
(
cls
,
application
:
Optional
[
"
AbstractApplication
"
]
=
None
,
request
:
Optional
[
HttpRequest
]
=
None
,
*
args
,
**
kwargs
,
)
->
list
[
str
]:
"""
Return a list of all OAuth scopes to always include for this request and application.
"""
return
[]
def
_maintain_default_data
(
self
):
from
django.contrib.auth.models
import
Permission
from
django.contrib.contenttypes.models
import
ContentType
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment