20 |
20 |
super(LogMixin, self).__init__(*args, **kwargs)
|
21 |
21 |
|
22 |
22 |
class LoginView(LogMixin, View):
|
23 |
|
def get_idp(self, request):
|
24 |
|
entity_id = request.REQUEST.get('entity_id')
|
|
23 |
def get_idp(self, request, entity_id=None):
|
|
24 |
if entity_id is None:
|
|
25 |
entity_id = request.REQUEST.get('entity_id')
|
25 |
26 |
if not entity_id:
|
26 |
27 |
return next(utils.get_idps())
|
27 |
28 |
else:
|
... | ... | |
139 |
140 |
return HttpResponseRedirect(next_url)
|
140 |
141 |
|
141 |
142 |
def continue_sso_artifact_get(self, request):
|
142 |
|
login = utils.create_login(request)
|
143 |
|
login.initRequest(request.META['QUERY_STRING'], lasso.HTTP_METHOD_ARTIFACT_GET)
|
144 |
|
login.buildRequestMsg()
|
145 |
|
|
146 |
143 |
idp_message = None
|
147 |
144 |
status_codes = []
|
148 |
145 |
|
|
146 |
login = utils.create_login(request)
|
|
147 |
try:
|
|
148 |
login.initRequest(request.META['QUERY_STRING'], lasso.HTTP_METHOD_ARTIFACT_GET)
|
|
149 |
except lasso.ServerProviderNotFoundError:
|
|
150 |
return HttpResponseBadRequest(
|
|
151 |
'no entity id found for this artifact %r' %
|
|
152 |
request.GET['SAMLart'])
|
|
153 |
idp = utils.get_idp(login.remoteProviderId)
|
|
154 |
if not idp:
|
|
155 |
return HttpResponseBadRequest(
|
|
156 |
'entity id %r is unknown' % login.remoteProviderId)
|
|
157 |
verify_ssl_certificate = utils.get_setting(
|
|
158 |
idp, 'VERIFY_SSL_CERTIFICATE')
|
|
159 |
login.buildRequestMsg()
|
149 |
160 |
result = requests.post(login.msgUrl, data=login.msgBody,
|
150 |
|
headers={'content-type': 'text/xml'})
|
|
161 |
headers={'content-type': 'text/xml'}, verify=verify_ssl_certificate)
|
151 |
162 |
if result.status_code != 200:
|
152 |
163 |
self.log.warning('SAML authentication failed: '\
|
153 |
164 |
'IdP returned %s when given artifact' % result.status_code)
|
154 |
|
-
|