auth

Paddy 2014-09-01 Parent:7a6f64db7246

27:043906283c65 Go to Latest

auth/README.md

Rough out profiles. Create a Profile type that stores information about user profiles. Create a Login type that stores information about a login strategy for user profiles. This is necessary so that a user can login with their username or email address, with usernames not being required if an email address is supplied and email addresses not being required if a username is supplied.

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