auth

Paddy 2014-08-16 Parent:7a6f64db7246

17:1f04b1146cad Go to Latest

auth/README.md

Implement CSRF prevention and pass info to confirmation. Implement CSRF prevention using the nosurf package. Note that the handler still needs to be wrapped before this will work. Pass info on the authorization being requested (namely the client and the scope) to the RenderConfirmation page so that the user can make an educated decision.

History
1 OSIN
2 ====
4 Golang OAuth2 server library
5 ----------------------------
7 OSIN is an OAuth2 server library for the Go language, as specified at
8 http://tools.ietf.org/html/rfc6749 and http://tools.ietf.org/html/draft-ietf-oauth-v2-10.
10 Using it, you can build your own OAuth2 authentication service.
12 The library implements the majority of the specification, like authorization and token endpoints, and authorization code, implicit, resource owner and client credentials grant types.
14 ### Dependencies
16 * go-uuid (http://code.google.com/p/go-uuid)
18 ### Example Server
20 ````go
21 import "github.com/RangelReale/osin"
23 // TestStorage implements the "osin.Storage" interface
24 server := osin.NewServer(osin.NewServerConfig(), &TestStorage{})
26 // Authorization code endpoint
27 http.HandleFunc("/authorize", func(w http.ResponseWriter, r *http.Request) {
28 resp := server.NewResponse()
29 if ar := server.HandleAuthorizeRequest(resp, r); ar != nil {
31 // HANDLE LOGIN PAGE HERE
33 ar.Authorized = true
34 server.FinishAuthorizeRequest(resp, r, ar)
35 }
36 osin.OutputJSON(resp, w, r)
37 })
39 // Access token endpoint
40 http.HandleFunc("/token", func(w http.ResponseWriter, r *http.Request) {
41 resp := server.NewResponse()
42 if ar := server.HandleAccessRequest(resp, r); ar != nil {
43 ar.Authorized = true
44 server.FinishAccessRequest(resp, r, ar)
45 }
46 osin.OutputJSON(resp, w, r)
47 })
49 http.ListenAndServe(":14000", nil)
50 ````
52 ### Example Access
54 Open in your web browser:
56 ````
57 http://localhost:14000/authorize?response_type=code&client_id=1234&redirect_url=http%3A%2F%2Flocalhost%3A14000%2Fappauth%2Fcode
58 ````
60 ### License
62 The code is licensed using "New BSD" license.
64 ### Author
66 Rangel Reale