Skip to content
This repository has been archived by the owner on May 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #5 from advisory/feature/suport-db-metadata
Browse files Browse the repository at this point in the history
Feature/suport db metadata
  • Loading branch information
songb committed Apr 5, 2016
2 parents 0f4fb98 + 1aa6389 commit c0077d4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
8 changes: 7 additions & 1 deletion djangosaml2/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import djangosaml2
from djangosaml2.utils import get_custom_setting, get_endpoints

from .exceptions import MissingSAMLMetadataException


BASE_PATH = getattr(settings, 'SAML2_IDP_BASE_DIR', os.path.dirname(djangosaml2.__file__))

Expand Down Expand Up @@ -95,7 +97,11 @@ def config_settings_loader(request):
# But if we simply put the 'DB' placeholder value there instead of valid XML, ask tenant.Member to get the XML
# metadata from the DB for the requesting tenant/member/schema.
if settings.SAML_CONFIG['metadata'].get('inline') == 'DB':
tenant_config['metadata']['inline'] = [request.tenant.get_saml_metadata(), ]
metadata = request.tenant.get_saml_metadata()
if metadata:
tenant_config['metadata']['inline'] = [metadata, ]
else:
raise MissingSAMLMetadataException("SAML metadata is not specified")

tenant_config["service"]["sp"]["endpoints"] = get_endpoints(request)
conf.load(tenant_config)
Expand Down
9 changes: 9 additions & 0 deletions djangosaml2/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class MissingSAMLMetadataException(Exception):
"""
This exception is thrown when 'DB' is used but metadata is not set in DB
"""
def __init__(self, msg):
self.msg = msg

def __str__(self):
return self.msg

0 comments on commit c0077d4

Please sign in to comment.