auth
2014-12-14
Child:d442523df640
auth/authd/server.go
Add authd. Start adding our server implementation. Right now, it's very proof-of-concept stage and will almost certainly be entirely rewritten, but it gets a server up and running.
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 }