RazorFlow SocialAuth

Authenticating using Google

You can use SocialAuth to restrict your Dashboard to specific Google Accounts. These can be GMail accounts, or accounts with Google Apps.

Set up

To prepare your dashboard for using Google Authentication, configure SocialAuth with your client_id and client_secret. If you do not have these tokens, then you can find out how to create them at Creating Google client id and client secret.

Use this code to set up the Google authentication:

SocialAuth::setupGoogle (array(
        'client_id' => 'your client ID goes here',
        'client_secret' => 'your client Secret goes here'
));

Allow specific Google Accounts

You can allow specific Google Accounts by providing an array of the email addresses associated with the accounts. Pass an array of email addresses to SocialAuth::allowGoogleAccounts

SocialAuth::allowGoogleAccounts(array(
        'foobar@gmail.com',
        'noname@gmail.com'
));

Allow specific Google Apps Domains

You can allow accounts belonging to specific Google Apps Domains by providing an array of domain names associated with the accounts. Pass an array of domain names to SocialAuth::allowGoogleDomains

SocialAuth::allowGoogleDomains(array(
        'yourcompany.org',
        'foobar.co.in'
));

Note

If you use both functions allowGoogleAccounts and allowGoogleDomains then the dashboard will be shown to a user who satisfies either criteria. For example ::

SocialAuth::allowGoogleAccounts(array('foo@partnercompany.com'));
SocialAuth::allowGoogleDomains(array('yourcompany.com'));

Now, people with email addresses foo@partnercompany.com and ceo@yourcompany.com can access the dashboard.

Authentication using Twitter

You can use SocialAuth to restrict your Dashboard to specific Twitter Accounts.

Set up

To prepare your dashboard for using Twitter Authentication, configure SocialAuth with your consumer_key and consumer_secret. If you do not have these tokens, then you can find out how to create them at Creating Twitter consumer key and consumer secret.

Use this code to set up the twitter authentication:

SocialAuth::setupTwitter (array(
        'consumer_key' => 'your consumer key goes here',
        'consumer_secret' => 'your consumer secret goes here'
));

Allow specific Twitter Accounts

You can allow specific Twitter Accounts by providing an array of the twitter usernames (do not start the username with @) associated with the accounts. Pass an array of usernames to SocialAuth::allowTwitterAccounts

SocialAuth::allowTwitterAccounts(array(
        'foobar123',
        'noname32'
));

Authenticating using LinkedIn

You can use SocialAuth to restrict your Dashboard to specific LinkedIn Accounts.

Set up

To prepafre your dashboard for using LinkedIn Authentication, configure SocialAuth with your api_key and secret_key. If you do not have these tokens, then you can find out how to create them at Creating Linkedin API key and secret key.

Use this code to set up the LinkedIn authentication:

SocialAuth::setupLinkedIn(array(
        'api_key' => 'your api key goes here',
        'secret_key' => 'your secret key goes here'
));

Allow specific LinkedIn Accounts

You can allow specific LinkedIn Accounts by providing an array of the email addresses associated with the accounts. Pass an array of email addresses to SocialAuth::allowLinkedInAccounts

SocialAuth::allowLinkedInAccounts(array(
        'foobar@gmail.com',
        'noname@gmail.com'
));

Allow specific LinkedIn Domains

You can allow accounts belonging to specific domains by providing an array of domain names associated with the LinkedIn accounts. Pass an array of domain names to SocialAuth::allowLinkedInDomains

SocialAuth::allowLinkedInDomains(array(
        'yourcompany.org',
        'gmail.com'
));

Note

If you use both functions allowLinkedInAccounts and allowLinkedInDomains then the dashboard will be shown to a user who satisfies either criteria. For example ::

SocialAuth::allowLinkedInAccounts(array('foo@partnercompany.com'));
SocialAuth::allowLinkedInDomains(array('yourcompany.com'));

Now, people with email addresses foo@partnercompany.com and ceo@yourcompany.com can access the dashboard.

Creating provider specific keys

Creating Google client id and client secret

Follow these steps to create Client ID and Client secret for your application.

  1. Create a new projet at Google APIs Console
  2. In the left navigation bar, click on API Access and click on the create an OAtuh client ID button
../_images/Google-APIs-Console-1.png
  1. Fill out thr branding information and click on next
../_images/create-google.png
  1. Select Web application type and click on more options beside your site or hostname

  2. Set Authorized redirect URIs to - http://your-server-hostname/path/to/rf/core/auth/?hauth.done=Google

    ../_images/client-settings.png
  3. Make a note of the Client ID and Client Secret

    ../_images/summary-google.png

Creating Twitter consumer key and consumer secret

Follow these steps to create Consumer Key and Consumer Secret for your application.

  1. Create a new application at Twitter Developer Site

  2. Click on create a new application

  3. Fillout the application details

  4. Set Callback URL to - http://your-server-hostname/path/to/rf/core/auth/?hauth.done=Twitter

    ../_images/create.png
  5. Make a note of the Consumer Key and Consumer Secret

    ../_images/summary.png
  6. Click on the settings tab and select ‘Allow this application to be used to Sign in with Twitter’ checkbox to ask the user to authorize only for the first time. If it is not checked, the user will have to authorize your app every single time he/she signs in.

../_images/checkbox.png

Note

If you are running your application on localhost, use 127.0.0.1 instead of localhost when filling out the application details.

Creating Linkedin API key and secret key

Follow these steps to create API key and Secret key

  1. Create a new application at LinkedIn Developer Network

  2. Click on Add New Application

    ../_images/add.png
  3. Fillout the application registration form

  4. In the OAuth User Agreement section set OAuth 1.0 Accept Redirect URL to - http://your-server-hostname/path/to/rf/core/auth/?hauth.done=LinkedIn

    ../_images/oauth.png
  5. Make a note of the API Key and Secret Key

    ../_images/summary1.png

Custom login templates

RazorFlow lets you customize the following sections in the Login page.

  • Page title
  • Heading text
  • Login message
  • Text on the login button

You can set these custom sections using the SocialAuth::setLoginPageMessages method. It takes a key-value pair array as an argument and has the following keys.

  • loginTitle - To set the loging page title and heading
  • loginBody - To set the login page message
  • loginButtonText - To set the text on the button

An example dashboard with custom login page sections would look like this

SocialAuth::setupTwitter(array(
        'consumer_key' => 'your key',
        'consumer_secret' => 'your secret'
));

SocialAuth::setLoginPageMessage(array(
                'loginTitle' => 'Custom Login Title',
                'loginBody' => 'This is a custom body text set from the dashboard file.'
                'loginButtonText' => 'Custom Button text',
));

Alternatively, you can create your own login page and pass it as an additional option called template_path when you are setting up a provider. template_path is the path to your login page file

SocialAuth::setupLinkedIn(array(
        'api_key' => 'apikey',
        'secret_key' => 'secret',
        'template_path' => '/examples/login_template.php'
));

and example login page would look like this

<html>
        <head>
                <title>Custom Login Page</title>
        </head>
        <body>
                <h2> Login </h2>
                <p>Please login over <a href="<?php echo $loginurl;?>">here</a></p>
        </body>
</html>

Note

You need to set the login link to $loginurl

Start building interactive, mobile-friendly Dashboards in PHP. See DemosDownload