Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caucase
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
caucase
Commits
026c5000
Commit
026c5000
authored
Oct 20, 2017
by
Vincent Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wsgi: Use Unauthorized with non-standard scheme when authentication fails
parent
ba4a750b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
8 deletions
+13
-8
caucase/test.py
caucase/test.py
+1
-1
caucase/wsgi.py
caucase/wsgi.py
+12
-7
No files found.
caucase/test.py
View file @
026c5000
...
@@ -1197,7 +1197,7 @@ class CaucaseTest(unittest.TestCase):
...
@@ -1197,7 +1197,7 @@ class CaucaseTest(unittest.TestCase):
# pylint: enable=unbalanced-tuple-unpacking
# pylint: enable=unbalanced-tuple-unpacking
status
,
reason
=
status
.
split
(
' '
,
1
)
status
,
reason
=
status
.
split
(
' '
,
1
)
return
int
(
status
),
reason
,
header_list
,
''
.
join
(
body
)
return
int
(
status
),
reason
,
header_list
,
''
.
join
(
body
)
UNAUTHORISED_STATUS
=
40
4
UNAUTHORISED_STATUS
=
40
1
self
.
assertEqual
(
request
({
self
.
assertEqual
(
request
({
'PATH_INFO'
:
'/'
,
'PATH_INFO'
:
'/'
,
...
...
caucase/wsgi.py
View file @
026c5000
...
@@ -48,6 +48,17 @@ class BadRequest(ApplicationError):
...
@@ -48,6 +48,17 @@ class BadRequest(ApplicationError):
"""
"""
status
=
_getStatus
(
httplib
.
BAD_REQUEST
)
status
=
_getStatus
(
httplib
.
BAD_REQUEST
)
class
Unauthorized
(
ApplicationError
):
"""
HTTP unauthorized error
"""
status
=
_getStatus
(
httplib
.
UNAUTHORIZED
)
_response_headers
=
[
# XXX: non standard scheme, suggested in
# https://www.ietf.org/mail-archive/web/httpbisa/current/msg03764.html
(
'WWW-Authenticate'
,
'transport'
),
]
class
NotFound
(
ApplicationError
):
class
NotFound
(
ApplicationError
):
"""
"""
HTTP not found error
HTTP not found error
...
@@ -198,12 +209,6 @@ class Application(object):
...
@@ -198,12 +209,6 @@ class Application(object):
Raises NotFound if authentication does not pass checks.
Raises NotFound if authentication does not pass checks.
On success, appends a "Cache-Control" header.
On success, appends a "Cache-Control" header.
"""
"""
# Note on NotFound usage here: HTTP specs do not describe how to request
# client to provide transport-level authentication mechanism (x509 cert)
# so 401 is not applicable. 403 is not applicable either as spec requests
# client to not retry the request. 404 is recommended when server does not
# wish to disclose the reason why it rejected the access, so let's use
# this.
try
:
try
:
ca_list
=
self
.
_cau
.
getCACertificateList
()
ca_list
=
self
.
_cau
.
getCACertificateList
()
utils
.
load_certificate
(
utils
.
load_certificate
(
...
@@ -215,7 +220,7 @@ class Application(object):
...
@@ -215,7 +220,7 @@ class Application(object):
),
),
)
)
except
(
exceptions
.
CertificateVerificationError
,
ValueError
):
except
(
exceptions
.
CertificateVerificationError
,
ValueError
):
raise
NotFoun
d
raise
Unauthorize
d
header_list
.
append
((
'Cache-Control'
,
'private'
))
header_list
.
append
((
'Cache-Control'
,
'private'
))
def
_readJSON
(
self
,
environ
):
def
_readJSON
(
self
,
environ
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment