auth
2014-07-18
auth/README.md
Start rewriting the repo. This code originally was a carbon copy of https://github.com/RangelReale/osin, but I am methodically stripping out the extensible nature of it for a simpler interface, while simultaneously bringing the style into line with the Ducky style.
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/README.md Fri Jul 18 07:13:22 2014 -0400 1.3 @@ -0,0 +1,66 @@ 1.4 +OSIN 1.5 +==== 1.6 + 1.7 +Golang OAuth2 server library 1.8 +---------------------------- 1.9 + 1.10 +OSIN is an OAuth2 server library for the Go language, as specified at 1.11 +http://tools.ietf.org/html/rfc6749 and http://tools.ietf.org/html/draft-ietf-oauth-v2-10. 1.12 + 1.13 +Using it, you can build your own OAuth2 authentication service. 1.14 + 1.15 +The library implements the majority of the specification, like authorization and token endpoints, and authorization code, implicit, resource owner and client credentials grant types. 1.16 + 1.17 +### Dependencies 1.18 + 1.19 +* go-uuid (http://code.google.com/p/go-uuid) 1.20 + 1.21 +### Example Server 1.22 + 1.23 +````go 1.24 +import "github.com/RangelReale/osin" 1.25 + 1.26 +// TestStorage implements the "osin.Storage" interface 1.27 +server := osin.NewServer(osin.NewServerConfig(), &TestStorage{}) 1.28 + 1.29 +// Authorization code endpoint 1.30 +http.HandleFunc("/authorize", func(w http.ResponseWriter, r *http.Request) { 1.31 + resp := server.NewResponse() 1.32 + if ar := server.HandleAuthorizeRequest(resp, r); ar != nil { 1.33 + 1.34 + // HANDLE LOGIN PAGE HERE 1.35 + 1.36 + ar.Authorized = true 1.37 + server.FinishAuthorizeRequest(resp, r, ar) 1.38 + } 1.39 + osin.OutputJSON(resp, w, r) 1.40 +}) 1.41 + 1.42 +// Access token endpoint 1.43 +http.HandleFunc("/token", func(w http.ResponseWriter, r *http.Request) { 1.44 + resp := server.NewResponse() 1.45 + if ar := server.HandleAccessRequest(resp, r); ar != nil { 1.46 + ar.Authorized = true 1.47 + server.FinishAccessRequest(resp, r, ar) 1.48 + } 1.49 + osin.OutputJSON(resp, w, r) 1.50 +}) 1.51 + 1.52 +http.ListenAndServe(":14000", nil) 1.53 +```` 1.54 + 1.55 +### Example Access 1.56 + 1.57 +Open in your web browser: 1.58 + 1.59 +```` 1.60 +http://localhost:14000/authorize?response_type=code&client_id=1234&redirect_url=http%3A%2F%2Flocalhost%3A14000%2Fappauth%2Fcode 1.61 +```` 1.62 + 1.63 +### License 1.64 + 1.65 +The code is licensed using "New BSD" license. 1.66 + 1.67 +### Author 1.68 + 1.69 +Rangel Reale