Skip to content

Commit e409228

Browse files
evanpurkhiserNisanthan Nanthakumar
authored and
Nisanthan Nanthakumar
committed
fix(saml2): Improve error message on attribute mapping (#16347)
1 parent dadb76a commit e409228

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

src/sentry/auth/helper.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from uuid import uuid4
66

7+
import six
78
from django.conf import settings
89
from django.contrib import messages
910
from django.core.urlresolvers import reverse
@@ -637,8 +638,8 @@ def finish_pipeline(self):
637638

638639
try:
639640
identity = self.provider.build_identity(data)
640-
except IdentityNotValid:
641-
return self.error(ERR_INVALID_IDENTITY)
641+
except IdentityNotValid as error:
642+
return self.error(six.text_type(error) or ERR_INVALID_IDENTITY)
642643

643644
if self.state.flow == self.FLOW_LOGIN:
644645
# create identity and authenticate the user

src/sentry/auth/providers/saml2/provider.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,12 @@ def build_identity(self, state):
299299

300300
# Email and identifier MUST be correctly mapped
301301
if not attributes[Attributes.IDENTIFIER] or not attributes[Attributes.USER_EMAIL]:
302-
raise IdentityNotValid
302+
raise IdentityNotValid(
303+
_(
304+
"Failed to map SAML attributes. Assertion returned the following attribute keys: %(keys)s"
305+
)
306+
% {"keys": raw_attributes.keys()}
307+
)
303308

304309
name = (attributes[k] for k in (Attributes.FIRST_NAME, Attributes.LAST_NAME))
305310
name = " ".join(filter(None, name))

src/sentry/static/sentry/app/views/app.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ class App extends React.Component {
114114
AlertActions.addAlert({
115115
message: msg.message,
116116
type: msg.level,
117+
neverExpire: true,
117118
});
118119
});
119120

0 commit comments

Comments
 (0)