persona

package module
v0.0.0-...-1daa6d7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 1, 2015 License: MIT Imports: 7 Imported by: 0

README

persona docs

Package for using persona in webapps.

store := persona.NewStore(cookieSecret)
persona := persona.New(store, "http://localhost:8080", []string{"john.doe@example.com"})

http.Handle("/", persona.Switch(SignInHandler, SignedOutHandler))
http.Handle("/secret", persona.Protect(SecretHandler))
http.Handle("/sign-in", persona.SignIn)
http.Handle("/sign-out", persona.SignOut)

then add this to your html,

<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="https://login.persona.org/include.js"></script>

<script>
  function gotAssertion(assertion) {
    // got an assertion, now send it up to the server for verification
    if (assertion !== null) {
      $.ajax({
        type: 'POST',
        url: '/sign-in',
        data: { assertion: assertion },
        success: function(res, status, xhr) {
          window.location.reload();
        },
        error: function(xhr, status, res) {
          alert("sign-in failure" + res);
        }
     });
    }
  };

  jQuery(function($) {
    $('#browserid').click(function() {
      navigator.id.get(gotAssertion);
    });
  });
</script>

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PersonaHandlers

type PersonaHandlers struct {
	SignIn  http.Handler
	SignOut http.Handler
	Protect Protect
	Switch  Switch
}

func New

func New(store Store, audience string, users []string) PersonaHandlers

type Protect

type Protect func(http.Handler) http.Handler

func Protector

func Protector(store Store, users []string) Protect

type Store

type Store interface {
	Set(email string, w http.ResponseWriter, r *http.Request)
	Get(r *http.Request) string
}

func NewStore

func NewStore(secret string) Store

type Switch

type Switch func(http.Handler, http.Handler) http.Handler

func Switcher

func Switcher(store Store, users []string) Switch

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL