auth

Paddy 2014-12-14 Parent:d03786cbf3ae Child:d442523df640

103:0b45e6b9cb94 Go to Latest

auth/authd/server.go

Store salts and passphrases as hex-encoded strings. Update our passphraseScheme.create function signature to return strings. Hex encode our passphrases and salts when encrypthing them so they're easier to store safely. Decode our salt before using it to check candidate passphrases.

History
1 package main
3 import (
4 "html/template"
5 "log"
6 "net/http"
8 "code.secondbit.org/auth"
10 "github.com/gorilla/mux"
11 )
13 func main() {
14 store := auth.NewMemstore()
15 config := auth.Config{
16 ClientStore: store,
17 AuthCodeStore: store,
18 ProfileStore: store,
19 TokenStore: store,
20 SessionStore: store,
21 Template: template.Must(template.New("base").ParseGlob("./templates/*.gotmpl")),
22 LoginURI: "/login",
23 }
24 context, err := auth.NewContext(config)
25 if err != nil {
26 panic(err)
27 }
29 router := mux.NewRouter()
30 auth.RegisterOAuth2(router, context)
31 auth.RegisterSessionHandlers(router, context)
32 http.Handle("/", router)
33 log.Fatal(http.ListenAndServe(":8080", nil))
34 }