Skip to content

Commit

Permalink
Merge pull request fangli#18 from DSpeichert/DSpeichert-patch-1
Browse files Browse the repository at this point in the history
Make use of tempfile compatible with Windows
  • Loading branch information
fangli authored Apr 1, 2017
2 parents afc9584 + 52e833b commit d775bff
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions django_saml2_auth/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,13 @@ def get_reverse(objs):

def _get_saml_client(domain):
acs_url = domain + get_reverse([acs, 'acs', 'django_saml2_auth:acs'])
import tempfile
tmp = tempfile.NamedTemporaryFile()
f = open(tmp.name, 'wb')
import tempfile, os
f = tempfile.NamedTemporaryFile(mode='wb', delete=False)
f.write(_urllib.urlopen(settings.SAML2_AUTH['METADATA_AUTO_CONF_URL']).read())
f.close()
saml_settings = {
'metadata': {
'local': [tmp.name],
'local': [f.name],
},
'service': {
'sp': {
Expand All @@ -88,7 +87,7 @@ def _get_saml_client(domain):
spConfig.load(saml_settings)
spConfig.allow_unknown_attributes = True
saml_client = Saml2Client(config=spConfig)
tmp.close()
os.unlink(f.name)
return saml_client


Expand Down

0 comments on commit d775bff

Please sign in to comment.