Cakephp and opauth login problems - cakephp

currently i'm trying to implement the opauth plugin for cakephp found here using the facebook strategy at present. I've followed the instructions however when I attempt to login using my facebook account I am redirected to the login page. What I have noticed is that the authentication is occurring and successful using this->Auth->login($user) where $user is an array of the user's stored information, but on redirection, the login function of my UserController is called an I'm returned to the login page. Any ideas? Thanks in advance!

So I figured it out. Turns out its a config setting, I noticed it while staring at his commit comments on github. In the config of the plugin the default option for the callback transport was changed from session (losing the session was my issue) to post. The change can be seen here. After making that change to the config everything worked.

Related

Issue with razor pay OAuth connect flow

Currently i am adding feature to connect razorpay merchants on my site using https://razorpay.com/docs/oauth/authorize/#authorization-url
and generating url to redirect merchants for login and permission on below URL
https://auth.razorpay.com/authorize?client_id={client_id}&response_type=code&redirect_uri=http://localhost:3000/admin-home&scope=read_only&state=NOBYtv8r6c75ex6WZ
Note: client id is generated and downloaded from https://dashboard.razorpay.com/app/keys page
but when above URL is opening in new window it gives below error
can someone please help me to solve this problem?
Please check whether you have whitelisted the redirect_uri, as per the instructions.
It is highly possible that there are validation placed based on the whitelisting which is preventing you request from going through.
It is explained in Step 1 on the same documentation which you have gone through.

Keycloak : Angularjs app logout when ever i refresh the page?

I'm using Keycloack in my angularjs app for login and its working fine.
But after the login in the application when ever a user tries to do a page refresh (F5) the application will logout and it will show the login page to the user.
Can someone please let me know what can be cause of this issue?
I got where is the issue ,please find attached screen shot
So i checked the Keyclock documentation and they wrote
The next execution is a subflow called Forms. Since this subflow is
marked as alternative it will not be executed if the Cookie
authentication type passed. This subflow contains additional
authentication type that needs to be executed. The executions for this
subflow are loaded and the same processing logic occurs
So considering above documented statement i made changes in keyclock server as well and it worked

CakePHP and Opauth

I started implementing Opauth for CakePHP. It's awesome that it's easy to login via Facebook, Twitter...
Question is once Opauth returns login data what would be an efficient way to login the user to CakePHP?
Opauth doesn't login the user to CakePHP. I think I'm supposed to create a user and save the facebook or other auth info to the db. Is there a plugin that allows me to do this easily?
One thing I love about CakePHP 2.0 was the way the Auth Plugins work, you can really customize one ore more Authentication methods. At the same time this leaves it to the developer to 'hook in' custom Auth Plugins to integrate the solution.
The plugin page has your answer, almost
Goto https://github.com/uzyn/cakephp-opauth#how-to-use
check step #6 "After validation, user will be redirected to Router::url('/opauth-complete') with validated auth response data retrievable available at $this->data"
after this is complete and you have code like their example public function opauth_complete() {...
in this function you will use the $this->data to find your User that was authenticated
a method I use at times is to find the user by 2 pieces of information that is provided by Opauth example: username and email
you can use something like $loginUser = $this->User->find('first', array('fields'=>array('User.*'), 'conditions'=>array('User.username'=>$this->data['username'], 'User.email'=>$this->data['email']));
once you have the user in $loginUser you can just call the $this->Auth->login($loginUser) and you will now have an AuthSession with that user!
Let me know if you have any questions.

Cakephp After redirecting session is not working in Live server

I am using cakephp 2.0 in My Users controller i am setting a SESSION in login action using
$this->Session->write('Users',$value);
once session set it will redirect to next action named home. In login action its working I logged and checked the value, but after the redirect I read the session value by using the following in home action
$this->log($this->Session->read('Users'));
nothing displayed. But its working fine in local server.
Please check the following things on your server.
Check your php.ini file whether session is enabled or not.
session.cookie.domain is set to your server or not.
Check for your php files having any blank lines after ?> if any please remove.
And then try.
What I understood is:
You are writing the session value into a log file. The value will not display on the screen, instead of it you can find this value in app/tmp/logs/error.log file.
This link will help you to get understand the concept.
To display the session value use pr($this->Session->read('Users'));
Kindly ask if it not worked for you.
User cakephp debug toolkit to check the session values. By using this you'll be able to monitor many things like
Request History.
Session.
Sql Log.
Timer.
Log (Which you are using in your question).
Variable set to your view.
https://github.com/cakephp/debug_kit/ Different version of debug kit are available for different version of Cake.

Log out with Facebook Connect in a Cakephp app

I want to include Facebook Connect in a Cakephp app that I'm working on. Right now, I'm trying to implement auto-login with Facebook Connect. I'm able to start a new login session by writing stuff to $this->Session whenever a user's Facebook Connect status is "connected", so I've got the first half of the feature working. The problem comes when the user tries to log off. Like The Run Around demo app, I've got a linke like this:
<a onclick="FB.Connect.logout(redirect_to_logout_action)">log out</a>
The logout action clears the login session variable, but on the next page, the user is still logged in to my site, but not Facebook. The user can log out of my site if he hits the log out link again, so I'm thinking that when he first tries to do this, he gets a new login session on my site, because facebook_client()->get_loggedin_user() is still returning something. Am I doing something wrong here? I thought when my server got the logout request that the Facebook cookies would be cleared by FB.Connect.logout :?
Have your javascript first do:
FB.Connect.logout
Then
location.href="/logout.php";
And on logout.php have
session_destroy();
session_start();
As abales said, I would ensure that whatever logout action is being redirected to calls the following method against the CakePHP Session component:
$this->Session->destroy();
That should eliminate the Cake/PHP session. After that, redirect to whatever controller+action is appropriate for a user that isn't logged in.
allyourcode,
I had similar issues in an app I built several months ago. We were using the Facebook component (like the one found here: from http://savarino.net/facebook-cakephp).
If I recall correctly, we ended up building a logout method that looked something like this:
$logout_url = $this->Facebook->facebook->get_logout_url('http://' . $_SERVER['SERVER_NAME'] . $this->webroot);
try {
$this->Facebook->facebook->expire_session();
} catch (Exception $e) {
$this->Facebook->facebook->set_user(null, null);
$this->Facebook->facebook->clear_cookie_state();
}
$this->redirect($logout_url);
I'm sorry I cannot be more specific. It's been several months since I've been back inside that app (and several projects since then) but, hopefully this will point you in the right direction.
Seth

Resources