Okta SWA and Moodle

Okta SWA and Moodle

by Stephen Teichgraeber -
Number of replies: 4

Our organization uses Okta for SSO.  When a user signs in to Okta, they click a link for our Moodle site and are automatically signed in with their credentials.  This is done through Okta's SWA protocol.  Okta's SWA works by storing user credentials with encryption and a private key.  When a user logs into the Okta web portal and clicks the link to our Moodle site, Okta posts those stored credentials to the Moodle login page over SSL and the user is signed in.  Our Moodle 3.6 site authenticates off LDAP and fills in Moodle profile info with fields from the LDAP record.

In our classrooms, thin clients connect users to a VMware desktop pool with Windows 10 LTSC VMs.  Using Chrome, a user can successfully login through Okta via the method outlined above.  If a user closes all Chrome windows, opens Chrome again, signs into Okta, and and follows the Moodle link, they are directred to a Moodle error page that reads, "You are already logged in as <user name of person trying to sign in>.  You must logout before logging in as a different user."  A user can either click "Logout" to be redirected to a login prompt or click "Cancel".  When choosing Cancel, a user is taken to our Moodle home page and they are signed in with the correct account.

Does anyone have experience using Okta SWA for SSO with Moodle?  I'm confused by the error message, "before logging in as a different user."  What's the different user if the person is signed in through Okta with the same credentials they used the first time?

I am going to open a ticket with Okta support as well but I was curious if anyone encountered this issue with Moodle and Okta or if they've seen this same error message under other circumstances in Moodle. 

Average of ratings: -
In reply to Stephen Teichgraeber

Re: Okta SWA and Moodle

by Jon Bolton -
Picture of Particularly helpful Moodlers Picture of Testers
Just a stab in the dark, but what’s the exact URL they are clicking on before they see the error message. You can redact the domain name if need be, but the rest of it is important.

That message appears when you’re trying to login in but are already logged in and it therefore presumes you’re NOT the person who is logged in and asks you to log out as the original person and log back in as the new person.
In reply to Jon Bolton

Re: Okta SWA and Moodle

by Stephen Teichgraeber -
I was able to resolve this late yesterday. We had the wrong URL in the Okta SWA config.

For the login page, we were using the home page that won't display the login field if a user is already logged in. So Okta SWA couldn't locate the login fields, and as you indicated, Moodle freaked out about there already being a session. Changing the Okta SWA URL to /login/index.php resolved the problem.
In reply to Stephen Teichgraeber

Re: Okta SWA and Moodle

by Herson Cruz -
Hello Stephen,
I'm trying to integrate OKTA with Moodle, in a similar way you just did, can you please share which auth plugin did you use? I'm looking to find out one that allows me to setup user client Id and secret in order to allow user to login.
Thanks,
In reply to Herson Cruz

Re: Okta SWA and Moodle

by Stephen Teichgraeber -
Currently, we're not using a SAML auth plugin in our Moodle, though I am looking into the possibility. So far, this one looks promising to me and I'll be testing it soon: https://github.com/catalyst/moodle-auth_saml2

Instead, our Moodle is using what Okta calls "Secure Web Authentication". https://www.okta.com/resources/whitepaper/how-okta-integrates-applications-architectural-overview/

"Okta can leverage its Secure Web Authentication protocol to automatically log users into these internal web applications. When an internal web application is configured to delegate authentication to AD (the same source to which Okta delegates authentication), Okta captures the user’s AD password at login and automatically sets that password for that user in any applications that also delegate to AD. This allows users to simply click a link to access these applications, and then be logged in automatically."