I want to add a button to Special:UserLogin so that users can choose between:
- using the regular MediaWiki login with a username and a password
- logging in via an external Single-Sign On system (which should just takes a click of a button)
So I tried implementing a PrimaryAuthenticationProvider:
class MyAuthProvider extends AbstractPrimaryAuthenticationProvider {
public function getAuthenticationRequests ( $action, array $options) {
return [
new ButtonAuthenticationRequest('some name', wfMessage('some label'), wfMessage('some help'), true),
];
}
// ... other methods
}to my surprise this results in the following user interface:
As it turns out that is this is because LoginSignupSpecialPage calls the function AuthenticationRequest::mergeFieldInfo to merge the fields from all authentication providers into one form.
While the form elements can be easily rearranged using the AuthChangeFormFields hook by assigning weights to the fields, using one form for separate providers has several disadvantages:
- fields that are required for one provider but not another cannot have the required HTML attribute (which is important for both UX as well as accessibility)
- the meaning of the form is not clear from the markup which is bad for e.g. screen readers
So for both UX as well as accessibility it would be much better to generate one form for every authentication provider, so users can simply choose which form to use and fields that are required for one authentication provider can actually be marked as required.
