Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mandatory2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
Jonas.Ostenstad
mandatory2
Commits
98547ad2
Commit
98547ad2
authored
2 years ago
by
Anya Helene Bagge
Browse files
Options
Downloads
Patches
Plain Diff
extra comments
parent
2a2279b7
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app.py
+7
-2
7 additions, 2 deletions
app.py
with
7 additions
and
2 deletions
app.py
+
7
−
2
View file @
98547ad2
...
...
@@ -63,6 +63,8 @@ def user_loader(user_id):
# than getting the user name the standard way (from the session cookie)
@login_manager.request_loader
def
request_loader
(
request
):
# Even though this HTTP header is primarily used for *authentication*
# rather than *authorization*, it's still called "Authorization".
auth
=
request
.
headers
.
get
(
'
Authorization
'
)
# If there is not Authorization header, do nothing, and the login
...
...
@@ -78,7 +80,7 @@ def request_loader(request):
u
=
users
.
get
(
uid
)
if
u
:
# and check_password(u.password, passwd):
return
user_loader
(
uid
)
elif
auth_scheme
==
'
bearer
'
:
# Bearer auth contains an access token
elif
auth_scheme
==
'
bearer
'
:
# Bearer auth contains an access token
;
# an 'access token' is a unique string that both identifies
# and authenticates a user, so no username is provided (unless
# you encode it in the token – see JWT (JSON Web Token), which
...
...
@@ -91,10 +93,13 @@ def request_loader(request):
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication
# If we failed to find a valid Authorized header or valid credentials, fail
# with 401 Unauthorized and a list of valid authentication schemes
# with
"
401 Unauthorized
"
and a list of valid authentication schemes
# (The presence of the Authorized header probably means we're talking to
# a program and not a user in a browser, so we should send a proper
# error message rather than redirect to the login page.)
# (If an authenticated user doesn't have authorization to view a page,
# Flask will send a "403 Forbidden" response, so think of
# "Unauthorized" as "Unauthenticated" and "Forbidden" as "Unauthorized")
abort
(
HTTPStatus
.
UNAUTHORIZED
,
www_authenticate
=
WWWAuthenticate
(
'
Basic realm=inf226, Bearer
'
))
def
pygmentize
(
text
):
...
...
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