auth
106:d442523df640 Browse Files
Init Config, add profile handlers, and add grant template. Call config.Init() before attempting to use it. Register our profile handlers with the router. Define a simple get_grant template for the authorization grant endpoint.
authd/server.go authd/templates/simple.gotmpl
1.1 --- a/authd/server.go Sun Dec 14 17:02:23 2014 -0500 1.2 +++ b/authd/server.go Sun Dec 14 17:03:33 2014 -0500 1.3 @@ -21,6 +21,10 @@ 1.4 Template: template.Must(template.New("base").ParseGlob("./templates/*.gotmpl")), 1.5 LoginURI: "/login", 1.6 } 1.7 + err := config.Init() 1.8 + if err != nil { 1.9 + log.Fatal(err) 1.10 + } 1.11 context, err := auth.NewContext(config) 1.12 if err != nil { 1.13 panic(err) 1.14 @@ -29,6 +33,7 @@ 1.15 router := mux.NewRouter() 1.16 auth.RegisterOAuth2(router, context) 1.17 auth.RegisterSessionHandlers(router, context) 1.18 + auth.RegisterProfileHandlers(router, context) 1.19 http.Handle("/", router) 1.20 log.Fatal(http.ListenAndServe(":8080", nil)) 1.21 }
2.1 --- a/authd/templates/simple.gotmpl Sun Dec 14 17:02:23 2014 -0500 2.2 +++ b/authd/templates/simple.gotmpl Sun Dec 14 17:03:33 2014 -0500 2.3 @@ -15,3 +15,16 @@ 2.4 </form> 2.5 </body> 2.6 </html>{{ end }} 2.7 + 2.8 +{{ define "get_grant" }}<html> 2.9 + <head> 2.10 + <title>Grant access</title> 2.11 + </head> 2.12 + <body>{{ if .error }} 2.13 + <h1>Error</h1> 2.14 + <p>{{ .error }}</p>{{ end }}{{ if .internal_error }} 2.15 + <h1>Error</h1> 2.16 + <p>{{ .internal_error }}</p>{{ end }}{{ if not .error }}{{ if not .internal_error }}<h1>Grant access</h1> 2.17 + <p>{{ .client }} is requesting access to your account. if you grant it, you'll be redirected to {{ .redirectURL }}. Their access will be limited to {{ .scope }}. You are granting access for {{ .profile }}.</p>{{ end }}{{ end }} 2.18 + </body> 2.19 +</html>{{ end }}