forum.coppermine-gallery.net

Support => cpg1.5 plugins => cpg1.5.x Support => cpg1.5 plugin contributions => Topic started by: omnitool on July 11, 2010, 08:34:04 pm

Title: Facebook Login Plugin
Post by: omnitool on July 11, 2010, 08:34:04 pm
This plugin throws a "connect with Facebook" button underneath the login button in the sidebar. You can still login the normal way, but if you choose to login via facebook, it will automatically:
1) Register the user (if he hasn't logged in before) using his firstname.lastname.DOB as his username, Facebook Id as his password, and email as his email (if the user has opted out of making his email public, facebook will use a proxy email in stead).
2) Log that user in (guaranteed working email addy from FB means no need for verification)
3)put your FBpicture up beneath the logout button.

Here's a good tutorial on setting up a FB application which you will need to do to use this plugin. Its meant for a wordpress plugin, so instead of throwing the keys in a WP page, just you'll want to put that in the plugin in the appropriate fields. (I just made an array in codebase.php, maybe theres a better coppermine way to do things, but I'm a coppernewb;) )
http://www.youtube.com/watch?v=nFCIlfnwZQg (http://www.youtube.com/watch?v=nFCIlfnwZQg)

Here's some Facebook Documentation: http://developers.facebook.com/docs/authentication/ (http://developers.facebook.com/docs/authentication/)
Here's what helped me wrap my head around the FB login process: http://github.com/facebook/php-sdk (http://github.com/facebook/php-sdk)


Things I'd like to do:
1) Change login to fancy-pants javacript login.
2) Once you FBlogin, all the checking the FBsession stuff happens after Coppermine Authentication, so I had to make it refresh. later on, there was a change to the site that made this endlessly loop. That needs to be done cleaner.
3) I couldn't figure out how to find the 'logout button' in the $menu array, o I just used $menu[11]. If you rearranged your menu, be sure and change this or better yet make it so its automatic.

A note about the quality: This is my first coppermine plugin. If its a little hacked, its because I'd never heard about coppermine until a few days before I created this, and my boss gave me a very short deadline. I ended up getting it to "just work" for what we needed with not too much thought of scalability for other users.

Title: Re: Facebook Login Plugin
Post by: Joachim Müller on July 12, 2010, 08:00:25 am
It's a pity that you haven't based your second generation plugin on the version that I originally had attached to your first draft version that you had to withdraw for personal reasons: the plugin that I had attached already used to contain several fixes and (most important of all) i18n. Some editing and work had already gone into the version I attached. Your second attempt is a step back. I had to perform a diff to get the delta between your initail version and the one I attached and apply the changes to your new version. Please be carefull as well with your version numbering scheme: your old copy had the version number 0.9, the one I attached in reply had 1.0. The new version you initially posted in this thread would have been v1.1, that's why my the version I have attached to my posting here is v1.2
As I consider the idea of the plugin promising I will add an actual config section to it, as it is my firm believe that actual, true plugins should not require the end user to modify any of the files.
With this being said, thanks again for your contribution.
I can see an issue though for end users: why are there two login buttons? In an ideal world, this wouldn't be a plugin, but a bridge file contribution.

Joachim

P.S. You might as well want to take a look at http://documentation.coppermine-gallery.net/en/dev_plugins.htm#plugin_writing_naming_conventions_archives
Title: Re: Facebook Login Plugin
Post by: omnitool on July 13, 2010, 12:14:51 am
It's a pity that you haven't based your second generation plugin on the version that I originally had attached to your first draft version that you had to withdraw for personal reasons: the plugin that I had attached already used to contain several fixes and (most important of all) i18n. Some editing and work had already gone into the version I attached. Your second attempt is a step back. I had to perform a diff to get the delta between your initail version and the one I attached and apply the changes to your new version.

By the time I had read your post, I tried to download your version. but it had moved to something called the CB board, which I didn't have permission to view. For some reason in this forum, you cant edit your own posts, you can't remove your own uploads, and for some reason you can't send messages to people, even if they message you. because of that I was unable to tell anybody what was going on.

Quote
Please be carefull as well with your version numbering scheme: your old copy had the version number 0.9, the one I attached in reply had 1.0. The new version you initially posted in this thread would have been v1.1, that's why my the version I have attached to my posting here is v1.2

The old post was deleted. I was told to not reference the old post and go on as if it never existed. that's what I did. personally, I don't think this plugin is quite ready to be >=1.0 which is why I versioned it 0.9.  I assumed anybody who was going to update my plugin would follow standard versioning conventions and update it to 0.9.1, 0.9.2, etc... until it was finally stable. You might want to look at http://en.wikipedia.org/wiki/Software_versioning#Version_1.0_as_a_milestone (http://en.wikipedia.org/wiki/Software_versioning#Version_1.0_as_a_milestone)


Quote
As I consider the idea of the plugin promising I will add an actual config section to it, as it is my firm believe that actual, true plugins should not require the end user to modify any of the files.
agreed. Thats what I said in my post. I just don't know how to use this because I've never worked with coppermine.
Quote
With this being said, thanks again for your contribution.
I can see an issue though for end users: why are there two login buttons?

the top login button is to login the old way. The new 'Connect with facebook' button is to connect through facebook. If it were possible to do what ,say, youtube does and have a single username/password login box, I'd say go for it, but I'm pretty sure FB wants you to use their proprietary login box thats on their page. I say that because I've never seen a static facebook login box. but maybe I'm wrong.

Quote
In an ideal world, this wouldn't be a plugin, but a bridge file contribution.


I don't know what that is. I've learned symfony, drupal, joomla, and wordpress, and never come accross a bridge file. Of course I'm self taught, so theres a lot I dont know that exists.

I'm not going to be maintaining this 'plugin' because we found a better solution and moved away from coppermine. I'm just offering it here if somebody else with coppermine experience wants to turn it into a plugin the coppermine way.
Title: Re: Facebook Login Plugin
Post by: omnitool on July 13, 2010, 12:15:32 am
and, of course, I can't edit my own post. :-\
Title: Re: Facebook Login Plugin
Post by: Αndré on July 13, 2010, 08:30:44 am
The ability for regular users to edit their postings has deliberately been removed because of frequent abuse in the past.
As contributor you should be moved to the appropriate board group and get the permission to edit your posts.
Title: Re: Facebook Login Plugin
Post by: Joachim Müller on July 13, 2010, 05:29:56 pm
and, of course, I can't edit my own post. :-\
You're not meant to, that's why. Postings remain unchanged preferably.

By the time I had read your post, I tried to download your version. but it had moved to something called the CB board, which I didn't have permission to view.
My version used to be attached to the posting in which I told you about the remnant private data inside your first public release, so this sound a bit implausible. Anyway, as I said, I have re-added the changes. Please base future contributions on the file I have attached.

For some reason in this forum, you cant edit your own posts, you can't remove your own uploads, and for some reason you can't send messages to people, even if they message you. because of that I was unable to tell anybody what was going on.
As André suggested, that's on purpose. We organize this forum differently: we believe in posting publicly, that's why there are no PMs allowed for regular users.

personally, I don't think this plugin is quite ready to be >=1.0 which is why I versioned it 0.9.
I understand that version numbering scheme and I have seen it before of course. End users never care about such things, they never ask themselves what a version number zero dot something means. That's why I consider this numbering scheme overkill.
I assumed anybody who was going to update my plugin would follow standard versioning conventions and update it to 0.9.1, 0.9.2, etc... until it was finally stable. You might want to look at http://en.wikipedia.org/wiki/Software_versioning#Version_1.0_as_a_milestone (http://en.wikipedia.org/wiki/Software_versioning#Version_1.0_as_a_milestone)
I'm aware that there are various version numbering schemes. For Coppermine plugins we agreed to start counting at 1.0. If you think that your plugin isn't mature enough, you're welcome to illustrate that by saying so in the description or install text, that's our prefered method to make end users aware of the fact that we consider versions as not-stable-yet.

I just don't know how to use this because I've never worked with coppermine.
Only recently I have finished coming up with additional documentation on adding config options, see http://forum.coppermine-gallery.net/index.php/topic,65526.msg327967.html#msg327967

and never come accross a bridge file. Of course I'm self taught, so theres a lot I dont know that exists.
Try http://documentation.coppermine-gallery.net/en/bridging.htm#integrating_bridge_file_creating_start as a start

I'm not going to be maintaining this 'plugin' because we found a better solution and moved away from coppermine. I'm just offering it here if somebody else with coppermine experience wants to turn it into a plugin the coppermine way.
OK, thanks again for your contrib. What license does your plugin come with? Is it GNU GPLed? Are we allowed to add it to the subversion repository?

As contributor you should be moved to the appropriate board group and get the permission to edit your posts.
You have been promoted to contributor status.
Title: Re: Facebook Login Plugin
Post by: taucher_0815 on August 11, 2010, 11:38:23 am
I am getting an Error during installation of the plugin...

Quote
Parse error: syntax error, unexpected '{' in /var/www/*some more text here*/coppermine/plugins/fb_oauth/codebase.php on line 69

Any idea on how to get around?
Title: Re: Facebook Login Plugin
Post by: Αndré on August 11, 2010, 11:47:57 am
Which version do you use?
Title: Re: Facebook Login Plugin
Post by: taucher_0815 on August 11, 2010, 11:51:37 am
Jochen's version: cpg1.5.x_plugin_fb-oauth_v1.2.zip.zip
Title: Re: Facebook Login Plugin
Post by: Αndré on August 11, 2010, 12:05:52 pm
Works for me as expected. Check if none of your files are corrupted/incomplete.
Title: Re: Facebook Login Plugin
Post by: taucher_0815 on August 11, 2010, 12:09:01 pm
uploaded several times. also the initial file from the Thread-Opener. Same Error.

May it be the PHP-Version? running on "PHP Version 4.4.9-0.dotdeb.1"
Title: Re: Facebook Login Plugin
Post by: Αndré on August 11, 2010, 12:17:11 pm
May it be the PHP-Version? running on "PHP Version 4.4.9-0.dotdeb.1"
Exceptions don't exist in PHP4:
Parse error: syntax error, unexpected '{' in /var/www/*some more text here*/coppermine/plugins/fb_oauth/codebase.php on line 69
Code: [Select]
$me = null;
// Session based API call.
if (!empty($session)) {
  try {
    $uid = $facebook->getUser();
    $me = $facebook->api('/me');
  } catch (FacebookApiException $e) {
    error_log($e);
  }
}
Title: Re: Facebook Login Plugin
Post by: taucher_0815 on August 11, 2010, 12:22:52 pm
after switching to PHP Version 5.2.13-0.dotdeb.1

Parse error: syntax error, unexpected '}' in /var/www/*some more text here*/coppermine/plugins/fb_oauth/codebase.php on line 99
Title: Re: Facebook Login Plugin
Post by: Αndré on August 11, 2010, 12:27:56 pm
Parse error: syntax error, unexpected '}' in /var/www/*some more text here*/coppermine/plugins/fb_oauth/codebase.php on line 99

I cannot find a '}' on line 99:
Code: (codebase.php, line 99) [Select]
$JS['includes'][] = 'plugins/fb_oauth/include/fbconnect.js';
I don't know what you're doing, sorry.
Title: Re: Facebook Login Plugin
Post by: taucher_0815 on August 12, 2010, 05:48:36 pm
strange... re-re-re-downloaded the zip, copied to the server inserted the requiered data and installed the plugin.

But now I do not see the FB-Connect-Button.

Using the unmodified "curve"-theme. Also copied the language file to german.php.

even a call to http://www.sk-foto.info/?lang=english does not bring this up

Title: Re: Facebook Login Plugin
Post by: Αndré on August 12, 2010, 06:15:52 pm
Works with e.g. the water_drop theme: http://www.sk-foto.info/?theme=water_drop
Title: Re: Facebook Login Plugin
Post by: taucher_0815 on August 12, 2010, 06:21:09 pm
any idea on how to bring this to curve?
Title: Re: Facebook Login Plugin
Post by: Αndré on August 12, 2010, 06:33:42 pm
You have to adjust the way how the button is added to the menu:
Code: [Select]
$new_button = array();
$new_button[0][0] = $buttonTtl;
$new_button[0][1] = $lang_plugin_fb_oauth['login_title'];
$new_button[0][2] = $buttonLnk;
$new_button[0][3] = 'fb_oauth';
$new_button[0][4] = $template_sys_menu_spacer;
$new_button[0][5] = 'rel="nofollow"';

array_splice($menu, count($menu)-1, 0, $new_button);

I cannot give you a working code snipped as I decided it's finishing time for today :P
Title: Re: Facebook Login Plugin
Post by: purplefreak3 on August 14, 2010, 09:03:42 am
Hello I am trying to use this plugin but I use the Curve theme, looked around on how to add it but havn't had much luck. Possible any more details on how to bring this plugin to Curve them?

Gallery
http://www.beautifuljodelle.com/gallery-user-created
Title: Re: Facebook Login Plugin
Post by: Αndré on August 14, 2010, 10:23:04 am
Please read one post above... ::)
Title: Re: Facebook Login Plugin
Post by: purplefreak3 on August 14, 2010, 05:46:16 pm
Sorry in advance for being clueless but where would I add/edit this information (code above) on adjusting the way a button is added to the menu?
Title: Re: Facebook Login Plugin
Post by: Αndré on August 14, 2010, 08:25:08 pm
In codebase.php
Title: Re: Facebook Login Plugin
Post by: DigitalMind on December 06, 2010, 09:23:12 pm
I can't seem to get this working on demotivationalpics.com ..

I created a facebook application page, I have the secret and app Id, I filled in all the details in codebase.php .. installing the plugin does in fact add the connect with facebook button, but when I click it and enter my facebook password, it simply brings me to my facebook account. 

The youtube video about setting up the facebook application seems out of date since some of the facebook settings are changed.

Any idea's ??  I get the feeling it has something to do with the facebook app end, and not the plugin since it's fairly straight forward.

For the moment I will leave the plugin active on demotivationalpics.com in case anyone wants to try it. 

Thanks guy !
Jason
Title: Re: Facebook Login Plugin
Post by: 1aB on January 11, 2011, 08:14:32 pm
@DigitalMind: I got the same problem, looked at the plugin code and played with it a bit...
I run Coppermine in an Apache with the prefork MPM (on Debian Lenny) ...but as far as my fair Apache knowledge and my dim PHP knowledge goes, I think this plugin could only work under Windows (mpm_winnt) or certain mpm_worker configurations, due to the use of the $facebook global variable.
Is that true? Does that match observations? Anyone working actively on this at the moment?
Anyway, I would like to modify this plugin, hoping that I'll have some changes that it would work for me, and then share it here. Give me a week for a start... ;-)
Title: Re: Facebook Login Plugin
Post by: Quinn on January 12, 2011, 10:31:08 pm
I have CPG 1.5.12 bridged with SMF 1.1.12.
SMF has Facebook Connect installed via SA FBConnect

Would / could this be extended to integrate with Coppermine and add a LIKE Button to the template?
Title: Re: Facebook Login Plugin
Post by: 1aB on January 13, 2011, 02:21:51 am
I came as far as this for now:

Some Todos that I would still see:

Hope that this might work for others, too, and also that the functionality is not only what I need but that others might also want/need it like this...
Title: Re: Facebook Login Plugin
Post by: Ziptrax on January 13, 2011, 02:35:24 pm
Invalid API key specified

The app you are trying to access does not exist or has been disabled.



Just tried this latest version and thats what i get

When i try and use it to log into my site at www.share-snaps.com
I will leave it on there so you can have a look at it if you want.
Title: Re: Facebook Login Plugin
Post by: 1aB on January 13, 2011, 04:47:29 pm
Hi,

saw your post, tried to go to your site but did not find it there.

Well -- the app key/app id and secret that you need to put into fb_init.php is something that you need to get from facebook by registering your gallery/site as an application with them at http://developers.facebook.com/setup/ -- there were some original instructions in this thread's initial post.

One thing I had initially done wrong was to mix up the app key and app id. But I am not sure whether Facebook's own wording of them is actually consistent. :-)

Hope this helps :-)
Roland
Title: Re: Facebook Login Plugin
Post by: 1aB on January 18, 2011, 01:19:24 pm
I managed to add a few more things:


Some proactive support attempts :-) Because I know that this beast is indeed very complicated and not easy to manage/troubleshoot.

If you should have a problem with the login process, try to find out where exactly it stops from working. Tools like LiveHttpHeaders (http://livehttpheaders.mozdev.org/) or IEhttpHeaders (http://www.blunck.se/iehttpheaders.html) might help with that.

There can be actually three... well... four ways how it can go wrong:

If you should have a problem with the new v1.4 autologin feature

BTW, has anyone else than me managed to get this working yet?
It would be great if someone could offer his working Facebook-login-able gallery for others to double-check on the login process (i.e. what a correct login process looks like in liveHttpHeaders).
Unfortunately I cannot share mine (at this time) because it has too little bandwith, sorry.


Some background about why I am doing this:
I have a small Coppermine gallery with lots of photos of people, friends and events where I have been asked to be a photographer. Definitely not the type of photos that one would want to share publically, so I have them secured via several different Coppermine groups. This approach works quite well, but there are some problems of the type of "password forgetting" and "group accounts".
So what I am trying to achieve is to keep my strict fine-grained Coppermine security model, and just map Facebook users to it, so that I can give the Facebook users persmissions to see those pictures that I want them to see, and ideally I would want to give those permissions in advance. I could then avoid "group accounts", and password remembering should then not be an issue with the users anymore, either...

I suppose that this approach is probably quite different from what others would like to achieve with Facebook integration. But maybe this is useful for you, too, though.


Future plans (beyond what I wrote previously):
Oh, I have just yesterday discovered that VZ (studiVZ/meinVZ) seems to have a similar login API (http://developer.studivz.net/wiki/index.php/VZ-ID) as Facebook. And wondering whether to use it would make sense in the scope of this plugin (then probably better renaming to "social_login" plugin  ;)) -- or better to create a separate vz-login-plugin, but then in a way that both could be used at the same time.
Not making any promises!
Title: Re: Facebook Login Plugin
Post by: spider666 on January 18, 2011, 04:35:14 pm
Hello. First thanks for your fantastic job !

I use the "curve" and "curve_black" theme and I can not see the "login via facebook" in the menu :-(. I see it on the "water_drop" theme. Little help is verry welcome.

Thanks in advance
Title: Re: Facebook Login Plugin
Post by: 1aB on January 19, 2011, 03:12:13 am
Okay, a special one for the "curve" users  ;)
Try this one and enable the "brute force" option -- whether it manages to change the sysmenu then.

Experts, please compare the source code for the "brute force" approach and the normal one -- which one is cleaner? (I would think the normal one is cleaner.)
Title: Re: Facebook Login Plugin
Post by: spider666 on January 19, 2011, 08:34:37 am
Many thanks, it's running with brute force :-)
Title: Re: Facebook Login Plugin
Post by: juwy on February 21, 2011, 06:32:48 pm
Hi,
I just installed coppermine and also instantly got cpg1.5.x_plugin_fb-oauth_v1.2 to work... great :-)
.. but ...
I uncommented

Code: [Select]

$login_params = array(
'req_perms' => 'email'
);


in fb_init.php but neither does facebook ask if the user wants to share his email with the app nor does the email appear in coppermines user management. Even if I am trying to require extended permissions by the req_perms parameter there is no change in facebooks behaviour.
Any help?
Title: Re: Facebook Login Plugin
Post by: 1aB on February 22, 2011, 03:56:54 pm
Need to look into that but since I have been trying with some other Facebook API calls as well and they seemed to work in an entirely different way (not via the $facebook object), it's possible that this part with the extended permissions may need reworking, too...
Title: Re: Facebook Login Plugin
Post by: 1aB on March 09, 2011, 05:11:53 pm
Hi,

as far as I could see that $login_params array works ok for the customized menu entry. The one that used to not show up with the curves theme ;-)

But not for the "big ugly" Javascript button. For that one it takes <fb:login-button perms="email"> instead of <fb:login-button> to make Facebook request the permission.

Maybe to copy the email from the Facebook profile to the Coppermine profile does not work properly at this time... I do not know... feel free to experiment with it ;-)

CU
Roland
Title: Re: Facebook Login Plugin
Post by: 1aB on March 09, 2011, 11:43:12 pm
Just to share what I managed to add so far. Sorry I did not deal with the Facebook perms issues yet. Hardly getting round to do anything these days  :-\

But if you should have nonpublic albums, v1.5 can now show on the thumbnails page who of one's Facebook friends are also allowed to see them. It might help Facebook-coming users better orientation to judge what they can see vs. what their friends can see in the gallery.

For those of you who want to play with the Facebook-interfacing code, note the use of the $facebook object in the old code versus the json_decode(file_get_contents('https://graph.facebook.com/...')) style code for this new feature. Despite the first one seems more object-oriented, I think I like the latter approach better... seems to be more kinda-direct...
Title: Re: Facebook Login Plugin
Post by: payam on April 25, 2011, 01:35:18 pm
Hi, do you have any updates to the plugin? Chrome doesn't seem to like it and I'm having trouble logging in normally (without facebook) once I have checked marked the automatically detected if they are signed in facebook.
Title: Re: Facebook Login Plugin
Post by: spider666 on May 19, 2011, 08:59:59 am
I receive this from Facebook about the Auth and I don't know what I have to do with this. This is directely in relation with your plugin I think.

My question are, can I update ? and if yes where exactely. Is your code "compatible" ?

Sorry, I'm not a coder, so all this is a bit confused

Thanks for your help

-----------------------------------------------


Dear Developer of XXXXX

Our automated systems have detected that you may be inadvertently allowing authentication data to be passed to 3rd parties. Allowing user ids and access tokens to be passed to 3rd parties, even inadvertently, could allow these 3rd parties to access the data the user made available to your site. This violates our policies and undermines user trust in your site and Facebook Platform.

In every case that we have examined, this information is passed via the HTTP Referer Header by the user's browser. This can happen when using our legacy authentication system and including <iframe>, <img> or <script> content from 3rd parties in the page that receives authentication data from Facebook. Our legacy mechanism passes authentication information in the URL query string which, if handled incorrectly, can be passed to 3rd parties by the browser. Our current OAuth 2.0 authentication system, released over a year ago, passes this information in the URL fragment, which is not passed to 3rd parties by the browser.

Please ensure that you are not allowing this data to be passed immediately. Accessing your site as a test user while running a HTTP proxy/monitor like Charles or Fiddler is the best way to determine if you are allowing this information to be passed. If you discover the issue, you can do one of two things:

1. Migrate your site to use our OAuth 2.0 authentication system. We are requiring all apps and sites to update to this mechanism by Sept. 1, 2011. Migrating now will address this issue and ensure that you are one of the first to meet the deadline. For more details, please see our Authentication Guide.

2. Create and use an interstitial page to remove the authentication data before redirecting to your page with 3rd party content. This approach is used by many of our largest developers today (although they are all migrating to OAuth 2.0 shortly). This is a simple and straightforwardchange that should have minimal impact on your site. For more details on this approach, see our Legacy Connect Auth doc.

Because of the importance of ensuring user trust and privacy, we are asking you to complete one of the above steps in the next 48 hours. If you fail to do so, your site may be subject to one of the enforcement actions outlined in our policies.

If you have any questions or believe you have received this message in error, please contact us.

Facebook Developer Relations
Title: Re: Facebook Login Plugin
Post by: rickmick on November 28, 2014, 06:25:35 pm
I can't believe that a plugin like this is dead in the water. With all the people using facebook login, Coppermine is so far behind.
Title: Re: Facebook Login Plugin
Post by: rickmick on November 29, 2014, 08:20:04 pm
I have it working for me. In the file fbconnect.php, on line 429, I changed

Code: [Select]
'login.php',
To

Code: [Select]
'dialog/oauth',
If you login using your facebook at least one time and you want to logout, and login to your admin username, you must delete your cookie that starts with fsb_ and ends with your AppId number. Always remember to backup your database and have an extra admin user before loading a plugin.