Giter Club home page Giter Club logo

cs.auth.facebook's Introduction

Introduction

A PAS plugin to login into a Plone Site using Facebook.

  • Log in to a Plone site through Facebook: when a user requests to log in to the Plone site he will be redirected to Facebook so that he provides the credentials there, then he will be redirected back to the Plone site and will be identified there.
  • The user will be a standard Plone user, so Roles or Group membership can be set.
  • Minimal user information is kept in Plone such as full name, Facebook ID, photo and e-mail (if available) of the user. This is kept to avoid permanent requests to Facebook API. This information is refreshed each time the user logs in to the site.

Installation and getting started

  1. Buildout

    Add cs.auth.facebook to your buildout.cfg eggs list:

    [buildout]
    ...
    eggs =
        cs.auth.facebook

    Or as a required install dependency of your own addon setup.py:

    install_requires=[
        ...
        'cs.auth.facebook',
    ], 
  2. Create a new Facebook app at https://developers.facebook.com/apps and fill in the required data in the plugin's control panel form. Make sure to enter the URL of the Website that is using the Facebook Login in App -> Facebook-Login -> Settings -> Valid OAuth Redirect URLs. If you want to run it from your local machine, you have to provide http://localhost:8080 and disable SSL-Enforcement.
  3. Install the product in the Plone Control Panel and provide the app_id and app_secret in the configuration panel.

    In Plone 4 you now see the "Facebook Login" button viewlet. To customize the placement of this viewlet please check out the Plone Viewlet Documentation

  4. Alternatively you can enable an action in portal_actions with the following configuration (see profiles/default/actions.xml within this package):

    <object name="portal_actions" meta_type="Plone Actions Tool"
       xmlns:i18n="http://xml.zope.org/namespaces/i18n">
        <object name="user" meta_type="CMF Action Category">
            <object name="login_facebook" meta_type="CMF Action" i18n:domain="cs.auth.facebook">
                <property name="title" i18n:translate="">Log in with Facebook</property>
                <property name="description" i18n:translate=""></property>
                <property name="url_expr">string:${globals_view/navigationRootUrl}/@@facebook-login</property>
                <property name="icon_expr"></property>
                <property name="available_expr">python:member is None</property>
                <property name="permissions">
                    <element value="View"/>
                </property>
                <property name="visible">False</property>
            </object>
        </object>
    </object>
  5. A second alternative is to link to the view ${globals_view/navigationRootUrl}/@@facebook-login where ever you want to start the facebook login.

Behind the scenes

The Facebook Login Viewlet uses the new Facebook JavaScript SDK v4.0 to ensure the proper popup for every target device. You don't have to care about this.

For more information on FB JSDK checkout the Facebook Developers Login Documentation

Credit

This product re-distributes a lot of code written by Martin Aspeli (aka @optilude) in his book "Professional Plone 4 Development" and available under GPL license in his personal GitHub account with the name 'optilux.facebookauth':

https://github.com/optilude/optilux/tree/chapter-16/src/optilux.facebookauth

Compatibility

Plone 4.x

Plone 5.x

cs.auth.facebook's People

Contributors

erral avatar petschki avatar nruiz avatar sarn0ld avatar

Stargazers

Tiberiu Ichim avatar Héctor Velarde avatar Jean Jordaan avatar Christian Ledermann avatar Dellaquila Pier Danilo avatar David Jonas avatar

Watchers

 avatar James Cloos avatar  avatar

cs.auth.facebook's Issues

You can't search for members authenticated by Facebook

That's because the UserEnumeration plugin implementation.

The method returns the users just when the current user is the Facebook logged one. Something should be implemented to test if the user is a valid facebook user (easy through the API) and if it's registered on the site (perhaps looking at portal_memnbership registry...

UnicodeDecodeError in plone.session

Hi, I've a problem after successful Facbook login. The session raises an UnicodeDecodeError:

Traceback (innermost last):
  Module ZPublisher.Publish, line 138, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module ZPublisher.Publish, line 48, in call_object
  Module Products.CMFFormController.FSControllerPythonScript, line 105, in __call__
  Module Products.CMFFormController.Script, line 145, in __call__
  Module Products.CMFCore.FSPythonScript, line 127, in __call__
  Module Shared.DC.Scripts.Bindings, line 322, in __call__
  Module Shared.DC.Scripts.Bindings, line 359, in _bindAndExec
  Module Products.PythonScripts.PythonScript, line 344, in _exec
  Module script, line 39, in logged_in
   - <FSControllerPythonScript at /Plone/logged_in>
   - Line 39
  Module Products.PlonePAS.tools.membership, line 632, in loginUser
  Module Products.PlonePAS.plugins.cookie_handler, line 93, in login
  Module Products.PluggableAuthService.PluggableAuthService, line 1234, in updateCredentials
  Module plone.session.plugins.session, line 220, in updateCredentials
  Module plone.session.plugins.session, line 140, in _setupSession
  Module plone.session.tktauth, line 180, in createTicket
UnicodeDecodeError: 'ascii' codec can't decode byte 0xae in position 4: ordinal not in range(128)

This is on a fresh CMFPlone 4.3.3 Site with no addons (except yours ;)
Do you have any idea, what's going wrong here?

OAuthException 191

Plone 4.3.10
cs.auth.facebook 1.1
collective.z3cform.norobots==1.4.2.2
collective.emailconfirmationregistration==1.2.0b5
Facebook API v2.12

I have created and configured the (web) app and activated and configured cs.auth.facebook, but always get this error if try login using Facebook:

{
"error": {
"message": "No se puede cargar la URL: El dominio de esta URL no está incluido en los dominios de la aplicación. Para poder cargar esta URL, añade todos los dominios y subdominios de tu aplicación al campo de dominios de la aplicación en la configuración de tu aplicación.",
"type": "OAuthException",
"code": 191,
"fbtrace_id": "Hajfak5PTJn"
}
}

Any idea?

Thanks

PS: I tried with https://www.google.com/search?q=OAuthException+191 tips, but no success.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.