diff options
Diffstat (limited to 'auth_persona.go')
-rw-r--r-- | auth_persona.go | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/auth_persona.go b/auth_persona.go index 7895c2d..2b5942e 100644 --- a/auth_persona.go +++ b/auth_persona.go @@ -1,52 +1,52 @@ package main import ( - "encoding/json" - "io" - "io/ioutil" - "log" - "net/http" - "net/url" + "encoding/json" + "io" + "io/ioutil" + "log" + "net/http" + "net/url" ) type PersonaResponse struct { - Status, Email, Reason string + Status, Email, Reason string } func (b PersonaResponse) Okay() bool { - return b.Status == "okay" + return b.Status == "okay" } func VerifyPersonaAssertion(assertion, audience string) PersonaResponse { - resp, _ := http.PostForm( - "https://browserid.org/verify", - url.Values{ - "assertion": {assertion}, - "audience": {audience}, - }) - response := personaResponseFromJson(resp.Body) - resp.Body.Close() - - return response + resp, _ := http.PostForm( + "https://browserid.org/verify", + url.Values{ + "assertion": {assertion}, + "audience": {audience}, + }) + response := personaResponseFromJson(resp.Body) + resp.Body.Close() + + return response } func personaResponseFromJson(r io.Reader) (resp PersonaResponse) { - body, err := ioutil.ReadAll(r) + body, err := ioutil.ReadAll(r) - if err != nil { - log.Fatal(err) - } + if err != nil { + log.Fatal(err) + } - err = json.Unmarshal(body, &resp) + err = json.Unmarshal(body, &resp) - if err != nil { - log.Fatal(err) - } + if err != nil { + log.Fatal(err) + } - return resp + return resp } -type PersonaAuth bool +type PersonaAuth bool func (pa PersonaAuth) CheckLogin(name, pw string) error { return nil |