Skip to content
This repository was archived by the owner on Jul 1, 2024. It is now read-only.

Customizable forms field names #31

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions awsprocesscreds/saml.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ class GenericFormsBasedAuthenticator(SAMLAuthenticator):
'Could not find login form from: %s'
)
_ERROR_MISSING_FORM_FIELD = (
'Error parsing HTML form, could not find the form field: "%s"'
'Error parsing HTML form, could not find the form field: "%s" '
'Available fields: %s.'
)
_ERROR_LOGIN_FAILED_NON_200 = (
'Login failed, received non 200 response: %s'
Expand Down Expand Up @@ -177,7 +178,7 @@ def _fill_in_form_values(self, config, form_data):
username = config['saml_username']
if self.USERNAME_FIELD not in form_data:
raise SAMLError(
self._ERROR_MISSING_FORM_FIELD % self.USERNAME_FIELD)
self._ERROR_MISSING_FORM_FIELD % (self.USERNAME_FIELD, ", ".join(form_data.keys())))
else:
form_data[self.USERNAME_FIELD] = username
if self.PASSWORD_FIELD in form_data:
Copy link

@ericdbarry ericdbarry Jul 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The password field needs a field validation check too.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Password field may not always be present in the form, for example, when user is remembered.
This is also taken into account in already-existing unit tests which explicitly check if missing password field will not break the program.

Copy link

@ericdbarry ericdbarry Jul 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, fair enough - I didn't see that test. I was merely relaying my experience of mistyping the password field and not getting an error that it was missing on the form.

Expand Down