idp: always write files as binaries (#36515)
This commit is contained in:
parent
f4ad46acc6
commit
00fc3deef0
|
@ -24,7 +24,7 @@ import tempfile
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|
||||||
from django.utils import six
|
from django.utils import six
|
||||||
from django.utils.encoding import force_text
|
from django.utils.encoding import force_bytes, force_text
|
||||||
from django.utils.six.moves import configparser as ConfigParser
|
from django.utils.six.moves import configparser as ConfigParser
|
||||||
from django.utils.six.moves.urllib import parse as urlparse
|
from django.utils.six.moves.urllib import parse as urlparse
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ class CmdCheckHobos(Command):
|
||||||
|
|
||||||
self.update_profile(self.all_services.get('profile', {}), pub)
|
self.update_profile(self.all_services.get('profile', {}), pub)
|
||||||
# Store hobo.json
|
# Store hobo.json
|
||||||
atomic_write(os.path.join(pub.app_dir, 'hobo.json'), json.dumps(self.all_services))
|
atomic_write(os.path.join(pub.app_dir, 'hobo.json'), force_bytes(json.dumps(self.all_services)))
|
||||||
|
|
||||||
def update_configuration(self, service, pub):
|
def update_configuration(self, service, pub):
|
||||||
if not pub.cfg.get('misc'):
|
if not pub.cfg.get('misc'):
|
||||||
|
@ -331,7 +331,7 @@ class CmdCheckHobos(Command):
|
||||||
|
|
||||||
s = rfd.read()
|
s = rfd.read()
|
||||||
(bfd, metadata_pathname) = tempfile.mkstemp('.metadata')
|
(bfd, metadata_pathname) = tempfile.mkstemp('.metadata')
|
||||||
atomic_write(metadata_pathname, s)
|
atomic_write(metadata_pathname, force_bytes(s))
|
||||||
|
|
||||||
from ..qommon.ident.idp import AdminIDPDir
|
from ..qommon.ident.idp import AdminIDPDir
|
||||||
admin_dir = AdminIDPDir()
|
admin_dir = AdminIDPDir()
|
||||||
|
|
|
@ -344,19 +344,19 @@ class AdminIDPDir(Directory):
|
||||||
atomic_write(os.path.join(dir, metadata_fn), force_bytes(metadata))
|
atomic_write(os.path.join(dir, metadata_fn), force_bytes(metadata))
|
||||||
if publickey:
|
if publickey:
|
||||||
publickey_fn = 'idp-%s-publickey.pem' % key_provider_id
|
publickey_fn = 'idp-%s-publickey.pem' % key_provider_id
|
||||||
atomic_write(os.path.join(dir, publickey_fn), publickey)
|
atomic_write(os.path.join(dir, publickey_fn), force_bytes(publickey))
|
||||||
else:
|
else:
|
||||||
publickey_fn = None
|
publickey_fn = None
|
||||||
|
|
||||||
if cacertchain:
|
if cacertchain:
|
||||||
cacertchain_fn = 'idp-%s-cacertchain.pem' % key_provider_id
|
cacertchain_fn = 'idp-%s-cacertchain.pem' % key_provider_id
|
||||||
atomic_write(os.path.join(dir, cacertchain_fn), cacertchain)
|
atomic_write(os.path.join(dir, cacertchain_fn), force_bytes(cacertchain))
|
||||||
else:
|
else:
|
||||||
cacertchain_fn = None
|
cacertchain_fn = None
|
||||||
|
|
||||||
if clientcertificate:
|
if clientcertificate:
|
||||||
clientcertificate_fn = 'idp-%s-clientcertificate.pem' % key_provider_id
|
clientcertificate_fn = 'idp-%s-clientcertificate.pem' % key_provider_id
|
||||||
atomic_write(os.path.join(dir, clientcertificate_fn), clientcertificate)
|
atomic_write(os.path.join(dir, clientcertificate_fn), force_bytes(clientcertificate))
|
||||||
else:
|
else:
|
||||||
clientcertificate_fn = None
|
clientcertificate_fn = None
|
||||||
|
|
||||||
|
@ -414,7 +414,7 @@ class AdminIDPDir(Directory):
|
||||||
else:
|
else:
|
||||||
s = rfd.read()
|
s = rfd.read()
|
||||||
(bfd, metadata_pathname) = tempfile.mkstemp(str('.metadata'))
|
(bfd, metadata_pathname) = tempfile.mkstemp(str('.metadata'))
|
||||||
atomic_write(metadata_pathname, s)
|
atomic_write(metadata_pathname, force_bytes(s))
|
||||||
try:
|
try:
|
||||||
p = lasso.Provider(lasso.PROVIDER_ROLE_IDP, metadata_pathname, None, None)
|
p = lasso.Provider(lasso.PROVIDER_ROLE_IDP, metadata_pathname, None, None)
|
||||||
except lasso.Error:
|
except lasso.Error:
|
||||||
|
@ -439,7 +439,7 @@ class AdminIDPDir(Directory):
|
||||||
else:
|
else:
|
||||||
s = rfd.read()
|
s = rfd.read()
|
||||||
(bfd, publickey_pathname) = tempfile.mkstemp(str('.publickey'))
|
(bfd, publickey_pathname) = tempfile.mkstemp(str('.publickey'))
|
||||||
atomic_write(publickey_pathname, s)
|
atomic_write(publickey_pathname, force_bytes(s))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
p = lasso.Provider(lasso.PROVIDER_ROLE_IDP, metadata_pathname,
|
p = lasso.Provider(lasso.PROVIDER_ROLE_IDP, metadata_pathname,
|
||||||
|
@ -539,9 +539,9 @@ class AdminIDPDir(Directory):
|
||||||
cfg_idp[key_provider_id]['metadata_url'] = metadata_url
|
cfg_idp[key_provider_id]['metadata_url'] = metadata_url
|
||||||
cfg_idp[key_provider_id]['publickey_url'] = publickey_url
|
cfg_idp[key_provider_id]['publickey_url'] = publickey_url
|
||||||
|
|
||||||
atomic_write(misc.get_abs_path(metadata_fn), metadata)
|
atomic_write(misc.get_abs_path(metadata_fn), force_bytes(metadata))
|
||||||
if publickey:
|
if publickey:
|
||||||
atomic_write(misc.get_abs_path(publickey_fn), publickey)
|
atomic_write(misc.get_abs_path(publickey_fn), force_bytes(publickey))
|
||||||
|
|
||||||
get_publisher().write_cfg()
|
get_publisher().write_cfg()
|
||||||
|
|
||||||
|
@ -704,12 +704,12 @@ class AdminIDPUI(Directory):
|
||||||
cfg_idp[key_provider_id]['metadata'] = metadata_fn
|
cfg_idp[key_provider_id]['metadata'] = metadata_fn
|
||||||
|
|
||||||
if metadata:
|
if metadata:
|
||||||
atomic_write(misc.get_abs_path(metadata_fn), metadata)
|
atomic_write(misc.get_abs_path(metadata_fn), force_bytes(metadata))
|
||||||
if publickey:
|
if publickey:
|
||||||
atomic_write(misc.get_abs_path(publickey_fn), publickey)
|
atomic_write(misc.get_abs_path(publickey_fn), force_bytes(publickey))
|
||||||
cfg_idp[key_provider_id]['publickey'] = publickey_fn
|
cfg_idp[key_provider_id]['publickey'] = publickey_fn
|
||||||
if cacertchain:
|
if cacertchain:
|
||||||
atomic_write(misc.get_abs_path(cacertchain_fn), cacertchain)
|
atomic_write(misc.get_abs_path(cacertchain_fn), force_bytes(cacertchain))
|
||||||
cfg_idp[key_provider_id]['cacertchain'] = cacertchain_fn
|
cfg_idp[key_provider_id]['cacertchain'] = cacertchain_fn
|
||||||
|
|
||||||
lp = cfg_idp[key_provider_id]
|
lp = cfg_idp[key_provider_id]
|
||||||
|
@ -966,7 +966,7 @@ class MethodAdminDirectory(Directory):
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
fn = os.path.join(new_domain_dir, 'common_cookie')
|
fn = os.path.join(new_domain_dir, 'common_cookie')
|
||||||
atomic_write(fn, get_publisher().app_dir)
|
atomic_write(fn, force_bytes(get_publisher().app_dir))
|
||||||
return self.configure_sp_metadatas(cfg_sp, signing_pem_key, private_signing_pem_key, encryption_pem_key, private_encryption_pem_key)
|
return self.configure_sp_metadatas(cfg_sp, signing_pem_key, private_signing_pem_key, encryption_pem_key, private_encryption_pem_key)
|
||||||
|
|
||||||
def get_saml2_metadata(self, sp_config, signing_pem_key, encryption_pem_key):
|
def get_saml2_metadata(self, sp_config, signing_pem_key, encryption_pem_key):
|
||||||
|
|
Loading…
Reference in New Issue