CakeDC / oauth2-cognito

Amazon Cognito Provider for the OAuth 2.0 Client
Other
14 stars 7 forks source link

Could not have "Sign In with Cognito" link in the login page #1

Open marcoarruda opened 5 years ago

marcoarruda commented 5 years ago

Hello,

I tried to follow the tutorial found here: https://www.cakedc.com/ajibarra/2019/03/15/how-to-cakephp-cakedc-users-and-amazon-cognito

But at the end I could not find the link "Sign In with Cognito" at the login page.

Is there something missing? Maybe I need to create the link manually and don't get it throughout the instructions.

Thanks in advance

roshnimansuri commented 4 years ago

Hi @marcoarruda , I am looking for the same. If you get anything to integrate Cognito with cakephp then please let me know. Any help will be appreciated! Thanks

marcoarruda commented 4 years ago

Hi @marcoarruda , I am looking for the same. If you get anything to integrate Cognito with cakephp then please let me know. Any help will be appreciated! Thanks

Hi! So far nothing from here, thanks for the support on that issue

ajibarra commented 3 years ago

Hey guys @roshnimansuri @marcoarruda, I am sorry I have missed this. I have updated article because I noticed some configuration details were in a wrong section.

If you are using Users plugin templates as recommended you just need to enable social login using

'Users.Social.login' => true

What I usually do is copying the whole users.php file to my app/config folder and then I add any configuration I want to include like previous one. Remember you also need to include clientID, secret, etc using:

'OAuth.providers.cognito.options.clientId' => 'CLIENT_ID',
'OAuth.providers.cognito.options.clientSecret' => 'CLIENT_SECRET',
'OAuth.providers.cognito.options.cognitoDomain' => 'DOMAIN',
'OAuth.providers.cognito.options.region' => 'REGION',

Please let me know if you still have problems and include your custom users.php file, you should remove sensitive information before pasting content here.

mattjohnsaint commented 2 years ago

Hi,

I think I had the same issue with the docs but worked my way through it. The docs at https://www.cakedc.com/ajibarra/2019/03/15/how-to-cakephp-cakedc-users-and-amazon-cognito

are missing a line of code.

It says

Add the following code to your src/Application.php pluginBootstrap() method to ensure we override the plugin defaults

But there is no code snippet after.

Working my way through the main cakedc plugin docs I found the answer. edit src/Application.php

Find where it says $this->addPlugin('CakeDC/Users'); and add Configure::write('Users.config', ['users']);

Also don't forget that config/users.php must start with <?PHP and close with ?>

Matt

mattjohnsaint commented 2 years ago

Also on Cakephp 4.3 I also had to fix the routing syntax

Colon prefixed route placeholders like:fooare deprecated. Use braced placeholders like{foo}instead. - /var/www/html/vendor/cakephp/cakephp/src/Routing/Route/Route.php, line: 300 You can disable all deprecation warnings by settingError.errorLeveltoE_ALL & ~E_USER_DEPRECATED, or addvendor/cakephp/cakephp/src/Routing/Route/Route.phptoError.ignoredDeprecationPathsin yourconfig/app.phpto mute deprecations from only this file.

Same as this issue from teh main cakedc https://github.com/CakeDC/users/issues/972

changed /:provider to /{provider}

in both

vendor/cakedc/users/config/routes.php vendor/cakedc/auth/config/bootstrap.php

Lastly, After running bin/cake migrations migrate -p CakeDC/Users to create the tables, I also had to make some changes to the social_accounts table to allow for the token. I changed both token and token_secret to text as var char 500 was too small.