alice-example

command
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 21, 2022 License: MIT, MIT Imports: 6 Imported by: 0

README

Go OpenId - Alice Example

godoc license

This fully working example implements an HTTP server chaining openid Authentication middlewares with various other middlewares using Alice.

Alice allows easily chaining middlewares in the form:

func (http.Handler) http.Handler

However the Authentication middlewares exported by the package openid2go/openid have slightly different constructors:

func Authenticate(conf *Configuration, h http.Handler) http.Handler
func AuthenticateUser(conf *Configuration, h UserHandler) http.Handler

This example demonstrates that those middlewares can still be easily chained using Alice with little additional code.

Test

Download and build:

go get github.com/emanoelxavier/openid2go/alice-example
go build github.com/emanoelxavier/openid2go/alice-example

Run:

github.com\emanoelxavier\openid2go\alice-example\alice-example.exe

Once running you can send requests like the ones below:

GET http://localhost:5103
GET http://localhost:5103/me
Authorization: Bearer eyJhbGciOiJS...
GET http://localhost:5103/authn
Authorization: Bearer eyJhbGciOiJS...

The abbreviated token above must be replaced with the IDToken acquired from the Google OAuth PlayGround entering "openid" (without quotes) within the scope field.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL