auth

Paddy 2014-09-01 Parent:7a6f64db7246

28:75cf37088852 Go to Latest

auth/README.md

Rough out tokens and begin the memstore. Rough out the Token type for working with OAuth2 access and refresh tokens. Rough out the TokenStore interface that dictates how Tokens will be stored and retrieved. Write tests for the successful (in the working-as-intended sense) calls to TokenStore. Begin a Memstore type that stores data in memory. Implement the TokenStore interface for Memstore.

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