Skip to content

Commit e0b39f2

Browse files
committed
change the open source licenses for MIT
1 parent 5559ef4 commit e0b39f2

File tree

5 files changed

+64
-54
lines changed

5 files changed

+64
-54
lines changed

LICENSE

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
1-
Copyright (c) 2016, OAuth 2.0
2-
All rights reserved.
1+
MIT License
32

4-
Redistribution and use in source and binary forms, with or without
5-
modification, are permitted provided that the following conditions are met:
3+
Copyright (c) 2016 Lyric
64

7-
* Redistributions of source code must retain the above copyright notice, this
8-
list of conditions and the following disclaimer.
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
911

10-
* Redistributions in binary form must reproduce the above copyright notice,
11-
this list of conditions and the following disclaimer in the documentation
12-
and/or other materials provided with the distribution.
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
1314

14-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15-
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
18-
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19-
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20-
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21-
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22-
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
MongoDB Storage for OAuth2
2-
==========================
1+
# MongoDB Storage for OAuth 2.0
32

4-
[![GoDoc](https://godoc.org/github.com/go-oauth2/mongo?status.svg)](https://godoc.org/github.com/go-oauth2/mongo)
5-
[![Go Report Card](https://goreportcard.com/badge/github.com/go-oauth2/mongo)](https://goreportcard.com/report/github.com/go-oauth2/mongo)
3+
> Based on the redis token storage
64
7-
Install
8-
-------
5+
[![License][License-Image]][License-Url]
6+
[![ReportCard][ReportCard-Image]][ReportCard-Url]
7+
[![GoDoc][GoDoc-Image]][GoDoc-Url]
8+
9+
## Install
910

1011
``` bash
11-
$ go get -u -v github.com/go-oauth2/mongo
12+
$ go get -u github.com/go-oauth2/mongo
1213
```
1314

14-
Usage
15-
-----
15+
## Usage
1616

1717
``` go
1818
package main
@@ -25,17 +25,25 @@ import (
2525
func main() {
2626
manager := manage.NewDefaultManager()
2727
// use mongodb token store
28-
mcfg := mongo.NewConfig("mongodb://admin:[email protected]:27017", "oauth2")
29-
manager.MustTokenStorage(mongo.NewTokenStore(mcfg))
30-
28+
manager.MustTokenStorage(
29+
mongo.NewTokenStore(mongo.NewConfig(
30+
"mongodb://127.0.0.1:27017",
31+
"oauth2",
32+
)),
33+
)
3134
// ...
3235
}
3336
```
3437

35-
License
36-
-------
38+
## MIT License
3739

3840
```
39-
Copyright (c) 2016, OAuth 2.0
40-
All rights reserved.
41-
```
41+
Copyright (c) 2016 Lyric
42+
```
43+
44+
[License-Url]: http://opensource.org/licenses/MIT
45+
[License-Image]: https://img.shields.io/npm/l/express.svg
46+
[ReportCard-Url]: https://goreportcard.com/report/github.com/go-oauth2/mongo
47+
[ReportCard-Image]: https://goreportcard.com/badge/github.com/go-oauth2/mongo
48+
[GoDoc-Url]: https://godoc.org/github.com/go-oauth2/mongo
49+
[GoDoc-Image]: https://godoc.org/github.com/go-oauth2/mongo?status.svg

config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package mongo
22

3-
// Config MongoDB Config
3+
// Config mongodb configuration parameters
44
type Config struct {
55
URL string
66
DB string
77
}
88

9-
// NewConfig Create MongoDB Config
9+
// NewConfig create mongodb configuration
1010
func NewConfig(url, db string) *Config {
1111
return &Config{
1212
URL: url,

token.go

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,19 @@ import (
1111
"gopkg.in/oauth2.v3/models"
1212
)
1313

14-
// TokenConfig Token Config
14+
// TokenConfig token configuration parameters
1515
type TokenConfig struct {
16-
TxnCName string // Store txn collection name(The default is oauth2)
17-
BasicCName string // Store token based data collection name(The default is oauth2_basic)
18-
AccessCName string // Store access token data collection name(The default is oauth2_access)
19-
RefreshCName string // Store refresh token data collection name(The default is oauth2_refresh)
16+
// store txn collection name(The default is oauth2)
17+
TxnCName string
18+
// store token based data collection name(The default is oauth2_basic)
19+
BasicCName string
20+
// store access token data collection name(The default is oauth2_access)
21+
AccessCName string
22+
// store refresh token data collection name(The default is oauth2_refresh)
23+
RefreshCName string
2024
}
2125

22-
// NewDefaultTokenConfig Create default token config
26+
// NewDefaultTokenConfig create a default token configuration
2327
func NewDefaultTokenConfig() *TokenConfig {
2428
return &TokenConfig{
2529
TxnCName: "oauth2_txn",
@@ -29,7 +33,7 @@ func NewDefaultTokenConfig() *TokenConfig {
2933
}
3034
}
3135

32-
// NewTokenStore Create a token store instance based on mongodb
36+
// NewTokenStore create a token store instance based on mongodb
3337
func NewTokenStore(cfg *Config, tcfgs ...*TokenConfig) (store oauth2.TokenStore, err error) {
3438
ts := &TokenStore{
3539
mcfg: cfg,
@@ -68,7 +72,7 @@ func NewTokenStore(cfg *Config, tcfgs ...*TokenConfig) (store oauth2.TokenStore,
6872
return
6973
}
7074

71-
// TokenStore MongoDB token store
75+
// TokenStore MongoDB storage for OAuth 2.0
7276
type TokenStore struct {
7377
tcfg *TokenConfig
7478
mcfg *Config
@@ -86,7 +90,7 @@ func (ts *TokenStore) cHandler(name string, handler func(c *mgo.Collection)) {
8690
return
8791
}
8892

89-
// Create Create and store the new token information
93+
// Create create and store the new token information
9094
func (ts *TokenStore) Create(info oauth2.TokenInfo) (err error) {
9195
jv, err := json.Marshal(info)
9296
if err != nil {
@@ -148,7 +152,7 @@ func (ts *TokenStore) Create(info oauth2.TokenInfo) (err error) {
148152
return
149153
}
150154

151-
// RemoveByCode Use the authorization code to delete the token information
155+
// RemoveByCode use the authorization code to delete the token information
152156
func (ts *TokenStore) RemoveByCode(code string) (err error) {
153157
ts.cHandler(ts.tcfg.BasicCName, func(c *mgo.Collection) {
154158
verr := c.RemoveId(code)
@@ -162,7 +166,7 @@ func (ts *TokenStore) RemoveByCode(code string) (err error) {
162166
return
163167
}
164168

165-
// RemoveByAccess Use the access token to delete the token information
169+
// RemoveByAccess use the access token to delete the token information
166170
func (ts *TokenStore) RemoveByAccess(access string) (err error) {
167171
ts.cHandler(ts.tcfg.AccessCName, func(c *mgo.Collection) {
168172
verr := c.RemoveId(access)
@@ -176,7 +180,7 @@ func (ts *TokenStore) RemoveByAccess(access string) (err error) {
176180
return
177181
}
178182

179-
// RemoveByRefresh Use the refresh token to delete the token information
183+
// RemoveByRefresh use the refresh token to delete the token information
180184
func (ts *TokenStore) RemoveByRefresh(refresh string) (err error) {
181185
ts.cHandler(ts.tcfg.RefreshCName, func(c *mgo.Collection) {
182186
verr := c.RemoveId(refresh)
@@ -227,13 +231,13 @@ func (ts *TokenStore) getBasicID(cname, token string) (basicID string, err error
227231
return
228232
}
229233

230-
// GetByCode Use the authorization code for token information data
234+
// GetByCode use the authorization code for token information data
231235
func (ts *TokenStore) GetByCode(code string) (ti oauth2.TokenInfo, err error) {
232236
ti, err = ts.getData(code)
233237
return
234238
}
235239

236-
// GetByAccess Use the access token for token information data
240+
// GetByAccess use the access token for token information data
237241
func (ts *TokenStore) GetByAccess(access string) (ti oauth2.TokenInfo, err error) {
238242
basicID, err := ts.getBasicID(ts.tcfg.AccessCName, access)
239243
if err != nil && basicID == "" {
@@ -243,7 +247,7 @@ func (ts *TokenStore) GetByAccess(access string) (ti oauth2.TokenInfo, err error
243247
return
244248
}
245249

246-
// GetByRefresh Use the refresh token for token information data
250+
// GetByRefresh use the refresh token for token information data
247251
func (ts *TokenStore) GetByRefresh(refresh string) (ti oauth2.TokenInfo, err error) {
248252
basicID, err := ts.getBasicID(ts.tcfg.RefreshCName, refresh)
249253
if err != nil && basicID == "" {

token_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212

1313
func TestTokenStore(t *testing.T) {
1414
Convey("Test mongodb token store", t, func() {
15-
mcfg := mongo.NewConfig("mongodb://admin:[email protected]:27017", "oauth2")
15+
mcfg := mongo.NewConfig("mongodb://127.0.0.1:27017", "oauth2")
1616
store, err := mongo.NewTokenStore(mcfg)
1717
So(err, ShouldBeNil)
1818

0 commit comments

Comments
 (0)