Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
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
Paul Graydon
erp5
Commits
99a2815b
Commit
99a2815b
authored
Oct 20, 2022
by
Kazuhiko Shiozaki
Committed by
Arnaud Fontaine
Mar 09, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
py2/py3: the way to ensure ASCII is different.
parent
463b374e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
6 deletions
+14
-6
bt5/erp5_oauth2_authorisation/DocumentTemplateItem/portal_components/document.erp5.OAuth2AuthorisationServerConnector.py
...nents/document.erp5.OAuth2AuthorisationServerConnector.py
+14
-6
No files found.
bt5/erp5_oauth2_authorisation/DocumentTemplateItem/portal_components/document.erp5.OAuth2AuthorisationServerConnector.py
View file @
99a2815b
...
@@ -92,6 +92,14 @@ from Products.ERP5Security.ERP5OAuth2ResourceServerPlugin import (
...
@@ -92,6 +92,14 @@ from Products.ERP5Security.ERP5OAuth2ResourceServerPlugin import (
)
)
from
ZPublisher.HTTPResponse
import
HTTPResponse
from
ZPublisher.HTTPResponse
import
HTTPResponse
def
ensure_ascii
(
s
):
if
six
.
PY2
:
return
s
.
encode
(
'ascii'
)
else
:
if
isinstance
(
s
,
str
):
s
=
bytes
(
s
,
'ascii'
)
return
s
.
decode
(
'ascii'
)
_DEFAULT_BACKEND
=
default_backend
()
_DEFAULT_BACKEND
=
default_backend
()
_SIGNATURE_ALGORITHM_TO_KEY_BYTE_LENGTH_DICT
=
{
_SIGNATURE_ALGORITHM_TO_KEY_BYTE_LENGTH_DICT
=
{
'HS256'
:
32
,
'HS256'
:
32
,
...
@@ -311,7 +319,7 @@ class _ERP5AuthorisationEndpoint(AuthorizationEndpoint):
...
@@ -311,7 +319,7 @@ class _ERP5AuthorisationEndpoint(AuthorizationEndpoint):
# Note: query string generation should not have produce any duplicate
# Note: query string generation should not have produce any duplicate
# entries, so convert into a dict for code simplicity.
# entries, so convert into a dict for code simplicity.
query_dict
=
{
query_dict
=
{
x
.
encode
(
'ascii'
):
y
.
encode
(
'ascii'
)
ensure_ascii
(
x
):
ensure_ascii
(
y
)
for
x
,
y
in
query_list
for
x
,
y
in
query_list
}
}
inner_response
=
HTTPResponse
(
stdout
=
None
,
stderr
=
None
)
inner_response
=
HTTPResponse
(
stdout
=
None
,
stderr
=
None
)
...
@@ -1277,7 +1285,7 @@ class OAuth2AuthorisationServerConnector(XMLObject):
...
@@ -1277,7 +1285,7 @@ class OAuth2AuthorisationServerConnector(XMLObject):
else
:
else
:
self
.
_checkCustomTokenPolicy
(
token_dict
,
request
)
self
.
_checkCustomTokenPolicy
(
token_dict
,
request
)
token_dict
[
JWT_PAYLOAD_KEY
]
=
decodeAccessTokenPayload
(
token_dict
[
JWT_PAYLOAD_KEY
]
=
decodeAccessTokenPayload
(
token_dict
[
JWT_PAYLOAD_KEY
].
encode
(
'ascii'
),
ensure_ascii
(
token_dict
[
JWT_PAYLOAD_KEY
]
),
)
)
return
token_dict
return
token_dict
raise
raise
...
@@ -1681,15 +1689,15 @@ class OAuth2AuthorisationServerConnector(XMLObject):
...
@@ -1681,15 +1689,15 @@ class OAuth2AuthorisationServerConnector(XMLObject):
(
(
now
,
now
,
access_token_signature_algorithm
,
access_token_signature_algorithm
,
private_key
.
private_bytes
(
ensure_ascii
(
private_key
.
private_bytes
(
encoding
=
Encoding
.
PEM
,
encoding
=
Encoding
.
PEM
,
format
=
PrivateFormat
.
PKCS8
,
format
=
PrivateFormat
.
PKCS8
,
encryption_algorithm
=
NoEncryption
(),
encryption_algorithm
=
NoEncryption
(),
)
.
encode
(
'ascii'
),
)),
private_key
.
public_key
().
public_bytes
(
ensure_ascii
(
private_key
.
public_key
().
public_bytes
(
encoding
=
Encoding
.
PEM
,
encoding
=
Encoding
.
PEM
,
format
=
PublicFormat
.
SubjectPublicKeyInfo
,
format
=
PublicFormat
.
SubjectPublicKeyInfo
,
)
.
encode
(
'ascii'
),
)),
),
),
)
+
tuple
(
)
+
tuple
(
x
x
...
...
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