Mozilla Persona Integration

Persona is an identity platform developed by Mozilla as a secure, easy to implement login solution for websites. It's great because it's safe and convinient for consumers. Enabling login with Persona is dead simple with Dailycred, and allows you to get much more information than just using Persona.

1. Add persona.js to your website by adding the following html:
  <script src="https://login.persona.org/include.js"></script>
2. Setup your audience setting in your Dailycred identity provider settings.
3. Get the most up to date javascript tag with your new persona settings and add it to your website.
4. Simply call personaLogin() at any time to log in the user with Persona.

This can be done inline like so:

  <a onclick="personaLogin()" href="#">Log in with Persona</a>

Or you can do it in regular javascript:

  $('#login').click(function(){
    personaLogin();
  });

That's it! Upon signing up, the user will be redirected to your usual OAuth callback URL, so that you don't have to do any extra work to login your user.



Enabling Persona login on our login page


In order to enable logging in with Persona on your gateway login page, you must first establish a custom cname and visit http://{your-cname}/oauth/gateway?client_id={your_client_id}.



Advanced callbacks

Configure any of the following methods callbacks that will be fired during the persona login process.

dc_opts.onPersonaLogin(assertion)

This is called as soon as the user comes back to your site after logging in with Persona. assertion is a string that is used to get information (like the user's email address) from Persona. Dailycred automatically retrieves the user's information for you, so you don't have to do anything.

dc_opts.onPersonaResponse(error, response)

This is fired after Dailycred retrieves the user's information from Persona. The error object has an attribute and message property.

Example:

{
  "message": "no certificates provided",
  "attribute": "persona_error"
}

The response object has contains a redirect url to continue through your OAuth callback as well as the user object for your convenience. Example:

{
  "worked": true,
  "redirect": "http://localhost:9000/signup/callback/dc?code=VgwvPy32rVYgzWoWMzI469t_DtKJvMaO2Ei-LMbDqPUOdtZ_EiJdjGCtqmgXyNT6lo8OuO7ab5cj2MFGb-Ugetbua1t0Ua0Y2tqUM-k&expires_in=2592000",
  "user": {
    // this will be a contain information identical from what you would retrieve through the user information api.

}, "access_token": "c3681ad2-250a-4985-a8ea-faad48a12235" }

Important: if you define dc_opts.onPersonaResponse(), your user will not be automatically redirected to your callback URL. It is up to you to decide how to continue logging in the user.