On our platform, we're using only external credentials and no on-site credentials, so it would be beneficial if we could initiate log-in via links instead of having to display the provider form in a block. This would allow, for example, the display of "log-in now" / "sign-up now" images/ads/etc shown to anonymous users to initiate log-in through an external IdP with no pause in flow (e.g. having to take the user to the log-in page just so they click on a button to log-in through a third party).

#3011413: Autologin when one client enabled makes a similar request, but handles it differently -- in that scenario, the goal is for a single-provider configuration to automatically initiate log-in through that provider. This request is different in that it does not preclude the possibility that there are several providers configured, allowing the providers to be triggered via URLs tailored for each specific provider. In this way, it's similar to the kc_idp_hint parameter Keycloak supports for identity brokering, as I mentioned in comment #7 on the other issue.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

GuyPaddock created an issue. See original summary.

guypaddock’s picture

I know that policy tends to be that new features have to start on 8.x and be back-ported to 7.x. Unfortunately, we aren't developing here on 7.x yet and we needed this feature for 7.x. So, attached, please find a patch for 7.x.

I'm not marking the issue as "Needs review" since I don't have an 8.x patch.

guypaddock’s picture

Realized that the previous patch broke account linking (i.e. linking an existing account to an external account).

The revised patch is attached, along with an interdiff.

leeomara’s picture

Do you think that this feature should follow (or support) the Initiating Login from a Third Party spec from OpenID Connect Core? From my reading, it looks like the Relying Party (Drupal) would need to accept an iss URL parameter (the full URL of the OpenID Provider) at the login initiation endpoint.

pfrilling’s picture

Status: Active » Needs review
StatusFileSize
new16.25 KB

Attached is a patch that follows the specifications from OpenID Connect Core for the 8.x branch.

Let me know if you have any changes/questions/thoughts.

pfrilling’s picture

I made a few adjustments to the patch in #5 to allow for extending the controller class a little easier.

pfrilling’s picture

Re-rolled the patch and updated the session unit test.

jcnventura’s picture

Status: Needs review » Needs work

The use of Nullable parameters forces this to specify a minimum version of php to >=7.1 in the module's composer.json.

sorinb’s picture

@pfrilling was this tested by any chance with OKTA provider?

I get a redirect to: openid-connect/okta?iss=https%3A%2F%2Fdigital-phoenix.okta.com
And it results in you're not authorized to access this page.

Just curious if you're by any chance trying with same provider I do?

jedihe’s picture

Version: 8.x-1.x-dev » 2.x-dev
Assigned: Unassigned » jedihe
jedihe’s picture

Re-rolled #7 onto 2.x. Pushed to MR, and I'm also attaching the patch. No idea if it's possible to generate an interdiff, given how many little things changed from 1.x to 2.x.

#8 is already resolved in branch 2.x.

jedihe’s picture

Assigned: jedihe » Unassigned
Status: Needs work » Needs review

I was not able to test properly, as I don't yet know how to set the 'state' token. My attempts seemed to trigger a forbidden AccessResult.

Will now open the MR to trigger tests, including a new commit I pushed after #11.

jedihe’s picture

This is the important @todo:

+++ b/src/Controller/OpenIDConnectRedirectController.php
@@ -97,25 +128,64 @@ class OpenIDConnectRedirectController extends ControllerBase implements AccessIn
+    // @todo while re-rolling for #11, it was not clear how to properly resolve
+    // a divergence here:
+    // - #7 reads state from the request $query.
+    // - 2.x reads state from $request.
+    // Decided to favor 2.x for now.
jcnventura’s picture

Status: Needs review » Needs work

@jedihe, any chance I can ask for you to adapt this to the latest code? The merge request doesn't seem to be applicable anymore.

And I've been changing a lot of stuff that probably has an impact on this code. If you manage to get it to work again, I think this would be a nice feature to have.

Regarding the @todo.. Yes, 2.x is the one to favor. The 1.x version will not get any new features anymore.

jedihe’s picture

Hi @jcnventura! I'm quite busy right now, but if I manage to find some time for contribution, I'll be looking into this one :).

jedihe’s picture

Hi @jcnventura! I managed to update the MR branch with current 2.x and get the unit tests passing (including the new one). I also tried to update some code in OpenIDConnectRedirectController, but I didn't actually test if the various controller methods in it continue working fine.

So, the MR was updated with latest work in 2.x branch, but manual testing is now needed to verify it works and no regressions were introduced.

turneyj’s picture

Any updates on this MR?

pfrilling’s picture

Status: Needs work » Needs review
StatusFileSize
new16.83 KB

I was able to get this patch to apply against the 2.x branch and confirm that it is working with Okta as the IDP. I manually tested logging in from Drupal and also logging in from Okta and both directions seem to be working well. I re-worked the target_link_uri logic and confirm that is working too.

Let me know if you'd like me to force push these changes to the merge request branch that @jedihe created.

joelsteidl’s picture

#19 is doing the trick for me. It took me a moment to figure out I was putting the iss querystring param in the wrong place.

pfrilling’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for the review @joelsteidl. Marking this as RTBC.

  • pfrilling authored 546d5ec on 2.x
    Issue #3030651 by jedihe, pfrilling: Support URL-initiated Log-in...
pfrilling’s picture

Status: Reviewed & tested by the community » Fixed

Looks good. Merged.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

rroblik’s picture

Thanks for the work but lack of documentation ...
How to get the OID login url and/or the Response object to use it in a custom event subscriber ?