Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom login forms #1471

Closed
angrybrad opened this issue Mar 8, 2017 · 11 comments
Closed

Custom login forms #1471

angrybrad opened this issue Mar 8, 2017 · 11 comments
Labels
enhancement improvements to existing features extensibility 🔌 features related to plugin/module dev

Comments

@angrybrad
Copy link
Member

Description

A plugin should be able to register login forms that an admin would enable/disable for a site.

Craft would be aware of those and display them on the CP login page instead of the default login form and it would provide a way for plugins to easily add things like 2FA authentication, SSO, LADP, etc. to the Craft login page.

@brandonkelly brandonkelly changed the title Provide a way for plugins to register login forms that would display on the CP login page if enabled allowing external authentication Custom login forms Mar 13, 2017
@roelvanhintum
Copy link
Contributor

For craft 2 i just created a plugin for this. I did have to use a nasty workaround to get things working. Right now all CP pages are blocked until the 2FA is verified (this all happens after login).
https://github.com/born05/craft-twofactorauthentication

@angrybrad
Copy link
Member Author

Thanks for sharing, @roelvanhintum. Curious what the hack was you had to use.

@roelvanhintum
Copy link
Contributor

roelvanhintum commented May 8, 2017

@takobell The ugliest part is logging the user in and logging out when the tries to bypass the 2FA page. This means verifying every page: https://github.com/born05/craft-twofactorauthentication/blob/master/TwoFactorAuthenticationPlugin.php#L56

The second part is the copied method to give the same result as a normal login.
https://github.com/born05/craft-twofactorauthentication/blob/master/controllers/TwoFactorAuthentication_VerifyController.php#L75
(If there is any problem with the copied part, or you know a nicer way, please let me know.)

@qrazi
Copy link
Contributor

qrazi commented Jul 18, 2017

Any idea whether this will be part of Craft CMS 3? I am very much interested in having a different authentication flow for the admin-side of Craft CMS, in my case to have SSO-type of login

@brandonkelly
Copy link
Member

@qrazi Not going to make it into 3.0 but maybe a 3.x release.

@bertoost
Copy link
Contributor

bertoost commented Jan 15, 2018

Maybe good to know, in the next update a userSession.onBeforeAuthenticate event is available.
I used this to manage LDAP authentication with the normal Craft CP Login screen.
PR: #2296

@brandonkelly brandonkelly added the extensibility 🔌 features related to plugin/module dev label Feb 26, 2018
@roelvanhintum
Copy link
Contributor

With the current setup i'm able to add my own login step, except for adding a special case request.

@brandonkelly Is it possible to add an option to add paths to _isSpecialCaseActionRequest?
https://github.com/craftcms/cms/blob/develop/src/web/Application.php#L546

@roelvanhintum
Copy link
Contributor

The AuthManager.js should also allow a follow up or replacement, when customizing the login form or adding an extra step.

@brandonkelly
Copy link
Member

@roelvanhintum Yep, thanks for the reminder :)

@dsmrt
Copy link
Contributor

dsmrt commented Aug 13, 2018

I have this working in Craft 3 for my SAML SP Plugin by overwriting the route. But, it's not pretty. Really, all I need for the SAML plugin is the ability to add some buttons.

Here's a screenshot of what's on my dev branch:
screen shot 2018-08-13 at 8 48 11 am

@blasvicco
Copy link
Contributor

I would like to mention our experience customizing the login form.
Seems that CraftCMS is appropriating the url where the query string contain p=/login matching the native UserController::actionLogin().
That could derivate in errors like this one:
#3458
Or some funny unexpected behaviors when you want the form to hit your particularly login system instead.

@brandonkelly brandonkelly added enhancement improvements to existing features and removed feature labels Mar 5, 2019
@craftcms craftcms locked and limited conversation to collaborators Jun 22, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
enhancement improvements to existing features extensibility 🔌 features related to plugin/module dev
Projects
None yet
Development

No branches or pull requests

7 participants