Skip to content

Commit 61a8522

Browse files
committed
Removed oauth_users.meta_user_id column (not needed/used) and fixed introspect endpoint.
1 parent 293d6f2 commit 61a8522

File tree

8 files changed

+15
-19
lines changed

8 files changed

+15
-19
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: update-deps install-deps fmt lint golint test test-with-coverage
1+
.PHONY: fmt lint golint test test-with-coverage
22
# TODO: When Go 1.9 is released vendor folder should be ignored automatically
33
PACKAGES=`go list ./... | grep -v vendor | grep -v mocks`
44

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ The authorization server authenticates the client, validates the authorization c
123123

124124
```json
125125
{
126-
"user_id": 1,
126+
"user_id": "1",
127127
"access_token": "00ccd40e-72ca-4e79-a4b6-67c95e2e3f1c",
128128
"expires_in": 3600,
129129
"token_type": "Bearer",
@@ -252,7 +252,7 @@ The client requests an access token from the authorization server's token endpoi
252252
curl --compressed -v localhost:8080/v1/oauth/tokens \
253253
-u test_client_1:test_secret \
254254
-d "grant_type=password" \
255-
-d "username=test@username" \
255+
-d "username=test@user" \
256256
-d "password=test_password" \
257257
-d "scope=read_write"
258258
```
@@ -261,7 +261,7 @@ The authorization server authenticates the client and validates the resource own
261261

262262
```json
263263
{
264-
"user_id": 1,
264+
"user_id": "1",
265265
"access_token": "00ccd40e-72ca-4e79-a4b6-67c95e2e3f1c",
266266
"expires_in": 3600,
267267
"token_type": "Bearer",
@@ -334,7 +334,7 @@ If valid and authorized, the authorization server issues an access token.
334334

335335
```json
336336
{
337-
"user_id": 1,
337+
"user_id": "1",
338338
"access_token": "1f962bd5-7890-435d-b619-584b6aa32e6c",
339339
"expires_in": 3600,
340340
"token_type": "Bearer",

models/oauth.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,10 @@ func (r *OauthRole) TableName() string {
5050
// OauthUser ...
5151
type OauthUser struct {
5252
MyGormModel
53-
RoleID sql.NullString `sql:"type:varchar(20);index;not null"`
54-
Role *OauthRole
55-
Username string `sql:"type:varchar(254);unique;not null"`
56-
Password sql.NullString `sql:"type:varchar(60)"`
57-
MetaUserID string `sql:"index"`
53+
RoleID sql.NullString `sql:"type:varchar(20);index;not null"`
54+
Role *OauthRole
55+
Username string `sql:"type:varchar(254);unique;not null"`
56+
Password sql.NullString `sql:"type:varchar(60)"`
5857
}
5958

6059
// TableName specifies table name

oauth/fixtures/test_users.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
role_id: 'superuser'
1212
username: 'test@superuser'
1313
password: '$2a$10$4J4t9xuWhOKhfjN0bOKNReS9sL3BVSN9zxIr2.VaWWQfRBWh1dQIS'
14-
meta_user_id: "1"
1514
created_at: 'ON_INSERT_NOW()'
1615
updated_at: 'ON_UPDATE_NOW()'
1716

@@ -22,7 +21,6 @@
2221
role_id: 'user'
2322
username: 'test@user'
2423
password: '$2a$10$4J4t9xuWhOKhfjN0bOKNReS9sL3BVSN9zxIr2.VaWWQfRBWh1dQIS'
25-
meta_user_id: "2"
2624
created_at: 'ON_INSERT_NOW()'
2725
updated_at: 'ON_UPDATE_NOW()'
2826

@@ -33,6 +31,5 @@
3331
role_id: 'user'
3432
username: 'test@user2'
3533
password: '$2a$10$4J4t9xuWhOKhfjN0bOKNReS9sL3BVSN9zxIr2.VaWWQfRBWh1dQIS'
36-
meta_user_id: "3"
3734
created_at: 'ON_INSERT_NOW()'
3835
updated_at: 'ON_UPDATE_NOW()'

oauth/grant_type_authorization_code_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ func (suite *OauthTestSuite) TestAuthorizationCodeGrant() {
178178

179179
// Check the response
180180
expected := &oauth.AccessTokenResponse{
181-
UserID: accessToken.User.MetaUserID,
181+
UserID: accessToken.UserID.String,
182182
AccessToken: accessToken.Token,
183183
ExpiresIn: 3600,
184184
TokenType: tokentypes.Bearer,

oauth/grant_type_password_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func (suite *OauthTestSuite) TestPasswordGrant() {
3838

3939
// Check the response
4040
expected := &oauth.AccessTokenResponse{
41-
UserID: accessToken.User.MetaUserID,
41+
UserID: accessToken.UserID.String,
4242
AccessToken: accessToken.Token,
4343
ExpiresIn: 3600,
4444
TokenType: tokentypes.Bearer,

oauth/grant_type_refresh_token_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ func (suite *OauthTestSuite) TestRefreshTokenGrantDefaultsToOriginalScope() {
171171

172172
// Check the response body
173173
expected := &oauth.AccessTokenResponse{
174-
UserID: accessToken.User.MetaUserID,
174+
UserID: accessToken.UserID.String,
175175
AccessToken: accessToken.Token,
176176
ExpiresIn: 3600,
177177
TokenType: tokentypes.Bearer,
@@ -217,7 +217,7 @@ func (suite *OauthTestSuite) TestRefreshTokenGrant() {
217217

218218
// Check the response
219219
expected := &oauth.AccessTokenResponse{
220-
UserID: accessToken.User.MetaUserID,
220+
UserID: accessToken.UserID.String,
221221
AccessToken: accessToken.Token,
222222
ExpiresIn: 3600,
223223
TokenType: tokentypes.Bearer,

oauth/response.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ func NewAccessTokenResponse(accessToken *models.OauthAccessToken, refreshToken *
3232
TokenType: theTokenType,
3333
Scope: accessToken.Scope,
3434
}
35-
if accessToken.User != nil {
36-
response.UserID = accessToken.User.MetaUserID
35+
if accessToken.UserID.Valid {
36+
response.UserID = accessToken.UserID.String
3737
}
3838
if refreshToken != nil {
3939
response.RefreshToken = refreshToken.Token

0 commit comments

Comments
 (0)