PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, November 1, 2022

[FIXED] How to make redirection work properly for google login on CakeDC's user plugin?

 November 01, 2022     cakedc, cakephp-3.0, google-authentication     No comments   

Issue

I'm using cakeDC's users plugin (8.5.1) to restrict my CakePHP (3.89) site to only members of my organization and have followed these directions:

https://www.cakedc.com/jorge_gonzalez/2016/10/11/create_google_app_for_web_oauth2_login_step_by_step

https://www.cakedc.com/jorge_gonzalez/2016/10/11/login-with-google-oauth2-in-cakephp-using-cakedc-users-plugin

I added these two lines to my bootstrap.php file, which was slightly different from what the directions said:

Configure::write('Users.config', ['users']); //add this line before Plugin::load('CakeDC/Users...
$this->addPlugin('CakeDC/Users', ['routes' => true, 'bootstrap' => true]);

my site is https://internal.domain.com

if not logged in, it redirects to:

https://internal.domain.com/login

after login, google redirects to

https://internal.domain.com/auth/google?state=XXXXXXX&code=4/XXXXXXX&scope=XXXXXX&authuser=XXXX&hd=XXXXXX&prompt=XXXX&session_state=XXXXXX

which doesn't work as a page, that is there's no route set up for it in cake:

Database Error PDOException Error: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'avatar' at row 1

From logs I can see that the user isn't being logged in, so it's makes me believe I've done something wrong in the install.

Is it just redirecting to the wrong page here or is the plugin installed incorrectly? Google won't let me change the redirect_uri to anything else, that is to say if I put a different address there, it will say there's a uri_redirect mismatch on login and give me the link to the console to fix it.


Solution

Specific routes are added to match all your social login enabled providers here https://github.com/CakeDC/users/blob/8.5.1/config/bootstrap.php#L37

Please check the route was correctly created via bin/cake routes and the google provider configuration is correctly set, see https://github.com/CakeDC/users/blob/8.5.1/Docs/Documentation/SocialAuthenticate.md#setup



Answered By - steinkel
Answer Checked By - Marie Seifert (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing