Using AWS Cognito for authentication

Using AWS Cognito for authentication

by David M -
Number of replies: 6


Hi everybody smile

We have a brand new Moodle 3.9.1 installation hosted in AWS EC2 the installation works fine with the default values, currently we are trying to allow our current users stored in AWS Cognito to login into the site.

What we have done so far is enabling the OAuth2 authentication plugin and configured Cognito as a custom OAuth, these are the values that we are using in the server configuration:

On Service base URL we put: https://<cognito_app>.auth.us-east-1.amazoncognito.com

Also we put the mandatory endpoints following the OAuth plugin documentation (https://docs.moodle.org/39/en/OAuth_2_services#Issuer_Configuration)

And finally we mapped the cognito email field with the moodle email field:

After setting this values the OAuth provider appears in the login screen, when clicked it correctly fordwards the user to the cognito OAuth portal:

After login into that portal we are redirected back into moodle, but then the following message appears:

And the user is still not logged in into moodle.

But the weird thing is when you click in again in login and use the OAuth cognito provider, the authentication portal is skipped and the user is now logged in into moodle.

The account works fine after the login and can use moodle normally, but if you try to log out and want to login as a different user, the Cognito OAuth portal is also skipped and the same user logs in. (I think this is because moodle doesn't know how to tell cognito to log out the user)

Does anybody has sucessfully configured cognito as login provider using OAuth? Or should I try using SAML instead?

Thank you so much in advance, any help will be appreciated.


Average of ratings: -
In reply to David M

Re: Using AWS Cognito for authentication

by John Dougherty -

Hi, 

Did you manage to solve this at all? I'm encountering the same issue myself when using AWS Cognito.

Regards


In reply to John Dougherty

Re: Using AWS Cognito for authentication

by David M -
Hi John,
I haven't found a solution yet, the user from this post has a possible workaround for this issue but his answer is not elaborated:

https://moodle.org/mod/forum/discuss.php?d=400947
In reply to David M

Re: Using AWS Cognito for authentication

by John Dougherty -

Hi David,

Just an update

I ended up using the OpenID Connect plugin instead with Cognito and that seems to work fine for me.

Regards

John

Average of ratings: Useful (1)
In reply to John Dougherty

Re: Using AWS Cognito for authentication

by David M -
Thank you so much John!

With the OpenID connect plugin I can now login using cognito!
Now I need to fix the log out of the current user.

Does the log out work for you?, when a user logs in with cognito, and the signs out and signing in again the cognito hosted ui is skipped and the user is logged in again.
In reply to David M

Re: Using AWS Cognito for authentication

by John Dougherty -

Hi David,

Yes I initially had trouble logging out too but used the following plugin to redirect my logout:

https://moodle.org/plugins/auth_loginlogoutredir

I set my login redirect in my config.php to something like this:

https://YOUR_DOMAIN/logout?client_id=YOUR_CLIENTID&response_type=code&scope=aws.cognito.signin.user.admin+email+openid+profile&redirect_uri=https://YOUR_REDIRECT.

Just fill in the YOUR part of the redirect to your own required configuration.

Regards

John

In reply to John Dougherty

Re: Using AWS Cognito for authentication

by ayuryoga life -

Hi John,

What would be auth_oidc | oidcresource value while using Openid plugin for cognito.