Skip to content

Latest commit

 

History

History
 
 

alice-example

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

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.