~mna/webparts-auth0

20543622084ca7a8c8871753584fa51437c0961b — Martin Angers 1 year, 6 months ago 2af8880
example: make auth work
2 files changed, 18 insertions(+), 1 deletions(-)

A example/home.html
M example/main.go
A example/home.html => example/home.html +7 -0
@@ 0,0 1,7 @@
<div>
    <h1>Auth0 Example</h1>
    <p>Zero friction identity infrastructure, built for developers</p>
    <a href="/login">SignIn</a>
    <br>
    <a href="/logout">Logout</a>
</div>

M example/main.go => example/main.go +11 -1
@@ 2,6 2,7 @@ package main

import (
	"context"
	"html/template"
	"log"
	"net/http"
	"os"


@@ 27,8 28,10 @@ func main() {
	}

	mux := http.NewServeMux()
	//mux.Handle("/", renderTpl("home.html"))
	mux.Handle("/", renderTpl("home.html"))
	mux.Handle("/login", http.HandlerFunc(endpoints.Login))
	mux.Handle("/callback", http.HandlerFunc(endpoints.LoginCallback))
	mux.Handle("/logout", http.HandlerFunc(endpoints.Logout))

	srv := http.Server{
		Addr:    localAddr,


@@ 46,6 49,13 @@ func main() {
	srv.Close()
}

func renderTpl(page string) http.HandlerFunc {
	tpl := template.Must(template.ParseFiles(page))
	return func(w http.ResponseWriter, r *http.Request) {
		tpl.Execute(w, nil)
	}
}

func sessionStore() httpssn.Store {
	pairs, err := sessions.KeyPairsFromFile(".env_keypairs")
	if err != nil {