update docs
This commit is contained in:
parent
109f77841b
commit
a0d19dd83c
|
@ -0,0 +1,37 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Package keyserve provides middleware to serve Public Keys
|
||||||
|
via OIDC-style (https://example.com/.well-known/openid-configuration)
|
||||||
|
and Auth0-style (https://example.com/.well-known/jwks.json)
|
||||||
|
URLs. It uses the keypairs package to encode to JWK format.
|
||||||
|
|
||||||
|
Basic usage:
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/ecdsa"
|
||||||
|
"crypto/rand"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/big-squid/go-keypairs/keyserve"
|
||||||
|
)
|
||||||
|
|
||||||
|
key, _ := ecdsa.GenerateKey(elliptic.P256, rand.Reader)
|
||||||
|
pub := key.Public()
|
||||||
|
|
||||||
|
handlers := &keyserve.Middleware{
|
||||||
|
// the self-reference used for building the openid-configuration url
|
||||||
|
BaseURL: "https://example.com/",
|
||||||
|
// public keys used to verify token signatures
|
||||||
|
Keys: []keypairs.PublicKey{ keypairs.NewPublicKey(pub) }
|
||||||
|
// how long clients should cache your public key
|
||||||
|
ExpiresIn: 72 * time.Hour
|
||||||
|
}
|
||||||
|
|
||||||
|
You can then use the handlers anywhere http.HandleFunc is allowed:
|
||||||
|
|
||||||
|
http.HandleFunc(keyserve.PEMPath, handlers.Auth0PEM)
|
||||||
|
http.HandleFunc(keyserve.JWKsPath, handlers.WellKnownJWKs)
|
||||||
|
http.HandleFunc(keyserve.OIDCPath, handlers.WellKnownOIDC)
|
||||||
|
|
||||||
|
*/
|
||||||
|
package keyserve
|
|
@ -1,7 +1,3 @@
|
||||||
// Package keyserve provides middleware to serve Public Keys
|
|
||||||
// via OIDC-style (https://example.com/.well-known/openid-configuration)
|
|
||||||
// and Auth0-style (https://example.com/.well-known/jwks.json)
|
|
||||||
// URLs. It uses the keypairs package to encode to JWK format.
|
|
||||||
package keyserve
|
package keyserve
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -31,8 +27,8 @@ const OIDCPath = "/.well-known/openid-configuration"
|
||||||
|
|
||||||
var oidcURL, _ = url.Parse(".well-known/openid-configuration")
|
var oidcURL, _ = url.Parse(".well-known/openid-configuration")
|
||||||
|
|
||||||
// Auth0PEMPath is "/pem" (Auth0 convention)
|
// PEMPath is "/pem" (Auth0 convention)
|
||||||
const Auth0PEMPath = "/pem"
|
const PEMPath = "/pem"
|
||||||
|
|
||||||
var auth0PEMURL, _ = url.Parse("pem")
|
var auth0PEMURL, _ = url.Parse("pem")
|
||||||
|
|
||||||
|
@ -66,7 +62,7 @@ func (m *Middleware) Handler(w http.ResponseWriter, r *http.Request) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasSuffix(r.URL.Path, Auth0PEMPath) {
|
if strings.HasSuffix(r.URL.Path, PEMPath) {
|
||||||
m.Auth0PEM(w, r)
|
m.Auth0PEM(w, r)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue