Documentation
¶
Overview ¶
Example ¶
package main import ( "io" "log" "net/http" "github.com/heroku/x/dynoid/middleware" ) const Audience = "testing" func main() { authorized := middleware.AuthorizeSameSpace(Audience) secureHandler := authorized(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { if _, err := io.WriteString(w, "Hello from a secure endpoint!\n"); err != nil { log.Printf("error writing response (%v)", err) } })) http.Handle("/secure", secureHandler) log.Fatal(http.ListenAndServe(":8080", nil)) }
Output:
Index ¶
- Variables
- func Authorize(audience string, callback dynoid.IssuerCallback) func(http.Handler) http.Handler
- func AuthorizeSameSpace(audience string) func(http.Handler) http.Handler
- func AuthorizeSpaces(audience string, spaces ...string) func(http.Handler) http.Handler
- func AuthorizeSpacesWithIssuer(audience, issuer string, spaces ...string) func(http.Handler) http.Handler
- func Populate(audience string, callback dynoid.IssuerCallback) func(http.Handler) http.Handler
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // returned when the `Authorization` header does not contain a Bearer token ErrTokenMissing = errors.New("token not found") )
Functions ¶
func AuthorizeSameSpace ¶
AuthorizeSameSpace restricts access to tokens from the same space/issuer for the given audience.
func AuthorizeSpaces ¶
AuthorizeSpaces populates the dyno identity and blocks any requests that aren't from one of the given spaces.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.