auth

Paddy 2014-12-14 Child:d442523df640

100:d03786cbf3ae Go to Latest

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.

History
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/authd/server.go	Sun Dec 14 12:10:57 2014 -0500
     1.3 @@ -0,0 +1,34 @@
     1.4 +package main
     1.5 +
     1.6 +import (
     1.7 +	"html/template"
     1.8 +	"log"
     1.9 +	"net/http"
    1.10 +
    1.11 +	"code.secondbit.org/auth"
    1.12 +
    1.13 +	"github.com/gorilla/mux"
    1.14 +)
    1.15 +
    1.16 +func main() {
    1.17 +	store := auth.NewMemstore()
    1.18 +	config := auth.Config{
    1.19 +		ClientStore:   store,
    1.20 +		AuthCodeStore: store,
    1.21 +		ProfileStore:  store,
    1.22 +		TokenStore:    store,
    1.23 +		SessionStore:  store,
    1.24 +		Template:      template.Must(template.New("base").ParseGlob("./templates/*.gotmpl")),
    1.25 +		LoginURI:      "/login",
    1.26 +	}
    1.27 +	context, err := auth.NewContext(config)
    1.28 +	if err != nil {
    1.29 +		panic(err)
    1.30 +	}
    1.31 +
    1.32 +	router := mux.NewRouter()
    1.33 +	auth.RegisterOAuth2(router, context)
    1.34 +	auth.RegisterSessionHandlers(router, context)
    1.35 +	http.Handle("/", router)
    1.36 +	log.Fatal(http.ListenAndServe(":8080", nil))
    1.37 +}