I apoligise if this has been asked many times before, but I'm wondering if anyone has a link to a good tutorial on implementing a working remote authentication system in Drupal 7. I'm new to Drupal.
I've found various examples online, but the system for doing this seems to have changed substantially between Drupal 5 to 6 to 7.
I have a working system that will allow me to authenticate a user remotely and adds the user to my drupal installation. However now I cant log in any Drupal only accounts (eg the admin) as I get an error saying that the username is unknown since the code is looking for my admin username in the external system.
I get an unrecognised username error. The code is being executed for both an external and an internal user.
I know its something simple.
External site login
Case on same server and try from any store on same path
like /store
define('DRUPAL_ROOT','D:/wamp/www/drupal');
require_once '../includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
global $user;
//change this line and put your username and password instead of 'admin' and 'password'
$account = user_authenticate('krishana', 'hiddens');
$user = user_load($account, TRUE);
drupal_session_regenerate();
Related
I am using the ready package as a base, I have done all steps in the readme.md file and was able to login as "einstein" user. So all seems to be configured correctly.
Later I have changed the credentials for the ldap server, which is using Active Directory.
While runing command php artisan ldap:test i receive message that i was able to connect correctly. Laravel logs says the same, but I cannot log in to laravel app. While running the command php artisan ldap:import ldap get message that no users where find
In the log file i see something like this:
[2021-04-28 23:04:08] local.INFO: LDAP (ldap://domain.pl:389) - Operation: Search - Base DN: cn=username#domain.pl,ou=Users,dc=domain,dc=pl - Filter: (&(objectclass=top)(objectclass=person)(objectclass=organizationalperson)(objectclass=inetorgperson)(uid=username)) - Selected: (entryuuid,*) - Time Elapsed: 737.37
Have anyone had the same issue with the ldaprecord that he was able to connect to domain but wasn't able to authenticate to an app ? And was able to solve that ?
UPDATE: i've found that auth.php is using wrong User model, it was using OpenLdap not Active directory, changed that but result is still the same
Problem solved, to make it work with AD you need to:
in the auth.php file switch model to ActiveDirectory
in login controller change in the credentials function have to change 'uid' key to 'sameaccountname'
Hello I am having some issues moving a Laravel website from one server to another. Everything appears to be working correctly but when I try to login to the website it will not redirect to any other page than the login page.
I am not getting any errors.
I am using version 4.2.
I am new to Laravel and wondering if anyone could help me out?
Thanks,
First you need to provide more information, but my guess is that you actually do not did not create any users in your current server and this is why your old user credentials do not work. If you don't have access to the database ssh into your server and cd into your project, then run following:
php artisan tinker
Followed by
App\User::all();
And check if it actually returns any user, if no, you don't have any users, you can do following to quickly create one:
// Run this in your php artisan:tinker session
App\User::create([
'name' => 'Jon Doe',
'email' => 'jon#doe.com',
'password' => bcrypt('password')
]);
That will create a user, if you have done that successfully try to log in to your website using those credentials. If that whole process fails you need to check or provide us your logs.
Laravel logs are located here:
appname/storage/logs/laravel.log
When trying to login with a Facebook app, I'm getting the following error:
Can't Load URL: The domain of this URL isn't included in the app's domains. To be able to load this URL, add all domains and subdomains of your app to the App Domains field in your app settings.
As you can see on the following image:
URL: http://www.facebook-php-test.com
Below is the configuration I have set on my Facebook App.
(Notice: for privacy purposes I changed the values for App ID and App Secret on the image)
The code for this basic sample application is on this GitHub repository:
https://github.com/zeuscronos/facebook-php-test.com
I really don't know why it says that the domain of this URL isn't included in the app's domains when it is actually there.
On the field: App Domains I tried with both domains at the same time:
facebook-php-test.com
www.facebook-php-test.com
but no success.
The generated login URL is as follows:
https://www.facebook.com/v2.10/dialog/oauth?client_id=012345678901234&state=d3758e484d539bebd6505427aaf1fa3b&response_type=code&sdk=php-sdk-5.6.1&redirect_uri=http%3A%2F%2Fwww.facebook-php-test.com%2Ffb-callback.php&scope=email%2Cuser_friends%2Cuser_photos
I configured the domain: facebook-php-test.com as a virtual host on an Apache server.
I have to say that I have worked a lot with the Facebook PHP SDK and this is the first time I'm getting struggle with this. Actually, I got this problem with another big application I was working with then after couple of hours trying to solve the problem I created this dummy application to try to figure out what's the cause of the problem.
I have tried many things with no success.
Any idea on how to solve this?
Thanks.
EDIT 01
Following the suggestion of Mr.Geeker comment I did the following...
Added the product: Facebook Login and configured like below:
Then, finally I could go forward, and I was asked for permissions:
But unfortunately, after granting permissions, I got the following:
Any idea on how to continue from this point?
EDIT 02 - SOLUTION
I ended disabling the option: Use Strict Mode for Redirect URIs under Client OAuth Settings. They say it is strongly recommended has this feature On but I could not get this working with that On.
By the way I also disabled: Client OAuth Login since my app doesn't use it.
Finally, the only feature I have enable under: Client OAuth Settings is: Web OAuth Login.
Facebook now roles some features as plugins. In the left hand side select Products and add product. Then select Facbook Login. Pretty straight forward from there, you'll see all the Oauth options show up.
As originally answered here
On March 2018, facebook updated the API and forced all apps to keep strict mode On.
To make it work, you have to include the full callback url in the Valid OAuth Redirect URIs field. If you redirect to "https://www.example.com/facebook/callback", the full URI must be included (without parameters):
The domain must be set in the App domains and the Website Site URL fields on the basic settings page:
If none of these works and the "Can't Load URL: The domain of this URL isn't included in the app's domains." message keeps showing, check if you have the latest version of the SDK. I could make it work after updating de PHP SDK from version 5.5 to 5.6.2
I'm using PHP 5.5 and I found the bug.
The PHP Facebook API VERSION = '5.5.0', DEFAULT_GRAPH_VERSION = 'v2.9' was adding the URI ?code=XXX in my callback page like this:
mydomainExample.com/callbackFacebook.php ?code=XXXXXXX
and I changed the source code to remove the string after '?'. Now the callback url is only
mydomainExample.com/callbackFacebook.php
The fixed can be done in the file Facebook/Helpers/ FacebookRedirectLoginHelper.php inside the getAccessToken function. I added a 'if' as below in the line 226 and the issue gone:
$redirectUrl = $redirectUrl ?: $this->urlDetectionHandler->getCurrentUrl();
//the next 3 lines was added to avoid the bug (fixed)
if(strripos($redirectUrl, "?")){
$redirectUrl = substr($redirectUrl, 0, strripos($redirectUrl, "?"));
}
// At minimum we need to remove the state param
$redirectUrl = FacebookUrlManipulator::removeParamsFromUrl($redirectUrl, ['state']);
I working on third party social login facebook by using django-social-authpackage. But when try to login bellow error show .
I also use django-allauth package and for that i use answerme facebook app.But same problem shown there also.
Facebook server will never find your local server because your website is not live and if you are running localserver then that means that is available to you only and the other person or Machine will not be able to access your server which local. so, to provide your url as callback url you will have to host your local server somewhere globally so, that Facebook can go through that and give results in response to that.
In Settings -> basic set http://localhost:8000/
In Django settings set:
SOCIAL_AUTH_FACEBOOK_KEY = your key
SOCIAL_AUTH_FACEBOOK_SECRET = your secret key
Also in case of success or fail you can redirect the user using this settings.
For finish SOCIAL_AUTH_LOGIN_REDIRECT_URL
For fail SOCIAL_AUTH_LOGIN_URL
I've written a Facebook App for a client which works fine on my own server running PHP5.2
On installing on the clients server we discovered that it was running PHP5.1.6
So no json_de/encode lib.
Client is prevented from upgrading to PHP5.2 by their server vendor and given the hack and state of their website (ancient hacked to death Joomla v1.0) probably risky.
Looking around I found upgradephp (v1.7 I've used).
Which supplies both json_encode & decode
The problem I'm stuck with is that the code is in a perpetual loop trying to get the Facebook user id:
$options = array("scope" => "user_birthday",
"redirect_uri" => "https://apps.facebook.com/".$nameSpace."/");
$loginUrl = $facebook->getLoginUrl($options);
// Get User ID
$user = $facebook->getUser();
if (!$user) {
// Require user to authenticate the app
echo '<script>top.location.href = "' . $loginUrl . '"</script>';
}
This code works great on my own server, just not on the clients.
So I'm left wondering where to start debugging and how?
Any suggestions greatly appreciated!
The answer was simply a configuration issue within the Facebook App panel caused by the client I did the work for.
They had wrongly entered their own web site URL omitting the preceeding "www."
When the app ran it attempted to go to the domain name without the www and was re-directed to the www.domainname. Not only that but the https was dropped for http in the re-direct.
This caused the infinite loop of re-directs as facebook doesn't allow non-https requests.