@@ -18,7 +18,7 @@ package oauth2
18
18
19
19
type inMemoryAuthKey struct {
20
20
Client * Client
21
- User * User
21
+ User User
22
22
}
23
23
24
24
// InMemoryPersistence is a simple backend implementation that keeps all data
@@ -33,7 +33,7 @@ type InMemoryPersistence struct {
33
33
34
34
// users holds the references to existing users in the system,
35
35
// indexed by their login
36
- users map [string ]* User
36
+ users map [string ]User
37
37
38
38
// authorizations holds the existing authorizations indexed by
39
39
// access token
@@ -47,7 +47,7 @@ func NewInMemoryPersistence(validPassword string) *InMemoryPersistence {
47
47
return & InMemoryPersistence {
48
48
validPassword : validPassword ,
49
49
clients : make (map [string ]* Client ),
50
- users : make (map [string ]* User ),
50
+ users : make (map [string ]User ),
51
51
authorizations : make (map [inMemoryAuthKey ]* Authorization ),
52
52
scopes : make (map [string ]* Scope ),
53
53
}
@@ -134,27 +134,17 @@ func (b *InMemoryPersistence) SaveScope(s *Scope) error {
134
134
}
135
135
136
136
// GetUserByUsername lookup the user that matches the login
137
- func (b * InMemoryPersistence ) GetUserByUsername (username string ) (* User , error ) {
137
+ func (b * InMemoryPersistence ) GetUserByUsername (username string ) (User , error ) {
138
138
u , exst := b .users [username ]
139
139
if ! exst {
140
140
return nil , ErrNotFound
141
141
}
142
142
return u , nil
143
143
}
144
144
145
- // GetUserByCredentials lookup the user that matches the username and password
146
- func (b * InMemoryPersistence ) GetUserByCredentials (username , password string ) (* User , error ) {
147
- u , exst := b .users [username ]
148
- if ! exst || password != "validpassword" {
149
- return nil , ErrAccessDenied
150
- }
151
-
152
- return u , nil
153
- }
154
-
155
145
// SaveUser persists the user in the backend, it's not part of the Backend interface
156
146
// but we need a way to add users to the Backend.
157
- func (b * InMemoryPersistence ) SaveUser (u * User ) error {
158
- b .users [u .Username ] = u
147
+ func (b * InMemoryPersistence ) SaveUser (u User ) error {
148
+ b .users [u .GetUsername () ] = u
159
149
return nil
160
150
}
0 commit comments