Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
swh-deposit
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
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Platform
Development
swh-deposit
Commits
245d1872
Unverified
Commit
245d1872
authored
Sep 19, 2017
by
Antoine R. Dumont
Browse files
Options
Downloads
Patches
Plain Diff
swh.deposit.api: Unify error messages
parent
65e73ea7
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
swh/deposit/auth.py
+4
-3
4 additions, 3 deletions
swh/deposit/auth.py
with
4 additions
and
3 deletions
swh/deposit/auth.py
+
4
−
3
View file @
245d1872
...
...
@@ -7,9 +7,10 @@ import base64
from
swh.core.config
import
SWHConfig
from
django.http
import
HttpResponse
from
django.contrib.auth
import
authenticate
,
login
from
.errors
import
UNAUTHORIZED
,
make_error
,
make_error_response
def
view_or_basicauth
(
view
,
request
,
test_func
,
realm
=
""
,
*
args
,
**
kwargs
):
"""
This determine if the request has already provided proper
...
...
@@ -42,8 +43,8 @@ def view_or_basicauth(view, request, test_func, realm="", *args, **kwargs):
# Either they did not provide an authorization header or
# something in the authorization attempt failed. Send a 401
# back to them to ask them to authenticate.
response
=
HttpResponse
(
)
response
.
status_code
=
401
err
=
make_error
(
UNAUTHORIZED
,
'
Access to this api needs authentication
'
)
response
=
make_error_response
(
request
,
err
[
'
error
'
])
response
[
'
WWW-Authenticate
'
]
=
'
Basic realm=
"
%s
"'
%
realm
return
response
...
...
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