auth
auth/authd/server.go
Fix whitespace in Profile queries. The lack of whitespace around the ` = ?` expression would have bothered me, so I fixed it.
1 package main
3 import (
4 "html/template"
5 "log"
6 "net/http"
8 "code.secondbit.org/auth.hg"
9 "github.com/gorilla/mux"
10 )
12 func main() {
13 p, err := auth.NewPostgres("dbname=testdb sslmode=disable")
14 if err != nil {
15 panic(err)
16 }
17 store := auth.NewMemstore()
18 if err != nil {
19 panic(err)
20 }
21 config := auth.Config{
22 ClientStore: store,
23 AuthCodeStore: store,
24 ProfileStore: &p,
25 TokenStore: store,
26 SessionStore: store,
27 ScopeStore: store,
28 Template: template.Must(template.New("base").ParseGlob("./templates/*.gotmpl")),
29 LoginURI: "/login",
30 }
31 err = config.Init()
32 if err != nil {
33 log.Fatal(err)
34 }
35 context, err := auth.NewContext(config)
36 if err != nil {
37 panic(err)
38 }
39 err = context.CreateScopes([]auth.Scope{
40 {ID: "testscope", Name: "Test Scope"},
41 })
43 router := mux.NewRouter()
44 auth.RegisterOAuth2(router, context)
45 auth.RegisterSessionHandlers(router, context)
46 auth.RegisterProfileHandlers(router, context)
47 auth.RegisterClientHandlers(router, context)
48 http.Handle("/", router)
49 log.Fatal(http.ListenAndServe(":8080", nil))
50 }