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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Official
AlekSIS-Core
Commits
1473db29
Verified
Commit
1473db29
authored
Nov 4, 2021
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
[OAuth] Add allowed_scopes to application model
parent
b4090959
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!759
Resolve "[OAuth] Allow limiting scopes per application"
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
aleksis/core/models.py
+5
-0
5 additions, 0 deletions
aleksis/core/models.py
aleksis/core/views.py
+7
-1
7 additions, 1 deletion
aleksis/core/views.py
with
12 additions
and
1 deletion
aleksis/core/models.py
+
5
−
0
View file @
1473db29
...
...
@@ -30,6 +30,7 @@ from django_celery_results.models import TaskResult
from
dynamic_preferences.models
import
PerInstancePreferenceModel
from
model_utils
import
FieldTracker
from
model_utils.models
import
TimeStampedModel
from
multiselectfield
import
MultiSelectField
from
oauth2_provider.models
import
(
AbstractAccessToken
,
AbstractApplication
,
...
...
@@ -58,6 +59,7 @@ from .mixins import (
SchoolTermRelatedExtensibleModel
,
)
from
.tasks
import
send_notification
from
.util.auth_helpers
import
AppScopes
from
.util.core_helpers
import
get_site_preferences
,
now_tomorrow
from
.util.model_helpers
import
ICONS
...
...
@@ -1112,6 +1114,9 @@ class OAuthApplication(AbstractApplication):
max_length
=
32
,
choices
=
AbstractApplication
.
GRANT_TYPES
,
blank
=
True
,
null
=
True
)
# Optional list of alloewd scopes
allowed_scopes
=
MultiSelectField
(
choices
=
list
(
AppScopes
().
get_all_scopes
().
items
()))
def
allows_grant_type
(
self
,
*
grant_types
:
set
[
str
])
->
bool
:
allowed_grants
=
get_site_preferences
()[
"
auth__oauth_allowed_grants
"
]
...
...
This diff is collapsed.
Click to expand it.
aleksis/core/views.py
+
7
−
1
View file @
1473db29
...
...
@@ -1080,7 +1080,13 @@ class OAuth2Update(PermissionRequiredMixin, UpdateView):
"""
Return the form class for the application model.
"""
return
modelform_factory
(
OAuthApplication
,
fields
=
(
"
name
"
,
"
client_id
"
,
"
client_secret
"
,
"
client_type
"
,
"
redirect_uris
"
,),
fields
=
(
"
name
"
,
"
client_id
"
,
"
client_secret
"
,
"
client_type
"
,
"
allowed_scopes
"
,
"
redirect_uris
"
,),
)
...
...
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