Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dex
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
dex
Commits
c70b29f8
Commit
c70b29f8
authored
Sep 30, 2015
by
Joe Bowers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db: log schema errors, distinguish them from nil results where needed
parent
a4269430
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
0 deletions
+29
-0
client.go
db/client.go
+5
-0
password.go
db/password.go
+3
-0
refresh.go
db/refresh.go
+3
-0
session.go
db/session.go
+6
-0
session_key.go
db/session_key.go
+6
-0
user.go
db/user.go
+6
-0
No files found.
db/client.go
View file @
c70b29f8
...
...
@@ -7,6 +7,7 @@ import (
"errors"
"fmt"
"net/url"
"reflect"
"github.com/coreos/go-oidc/oidc"
"github.com/go-gorp/gorp"
...
...
@@ -163,6 +164,7 @@ func (r *clientIdentityRepo) Metadata(clientID string) (*oidc.ClientMetadata, er
cim
,
ok
:=
m
.
(
*
clientIdentityModel
)
if
!
ok
{
log
.
Errorf
(
"expected clientIdentityModel but found %v"
,
reflect
.
TypeOf
(
m
))
return
nil
,
errors
.
New
(
"unrecognized model"
)
}
...
...
@@ -182,6 +184,7 @@ func (r *clientIdentityRepo) IsDexAdmin(clientID string) (bool, error) {
cim
,
ok
:=
m
.
(
*
clientIdentityModel
)
if
!
ok
{
log
.
Errorf
(
"expected clientIdentityModel but found %v"
,
reflect
.
TypeOf
(
m
))
return
false
,
errors
.
New
(
"unrecognized model"
)
}
...
...
@@ -203,6 +206,7 @@ func (r *clientIdentityRepo) SetDexAdmin(clientID string, isAdmin bool) error {
cim
,
ok
:=
m
.
(
*
clientIdentityModel
)
if
!
ok
{
rollback
(
tx
)
log
.
Errorf
(
"expected clientIdentityModel but found %v"
,
reflect
.
TypeOf
(
m
))
return
errors
.
New
(
"unrecognized model"
)
}
...
...
@@ -230,6 +234,7 @@ func (r *clientIdentityRepo) Authenticate(creds oidc.ClientCredentials) (bool, e
cim
,
ok
:=
m
.
(
*
clientIdentityModel
)
if
!
ok
{
log
.
Errorf
(
"expected clientIdentityModel but found %v"
,
reflect
.
TypeOf
(
m
))
return
false
,
errors
.
New
(
"unrecognized model"
)
}
...
...
db/password.go
View file @
c70b29f8
...
...
@@ -2,8 +2,10 @@ package db
import
(
"errors"
"reflect"
"time"
"github.com/coreos/dex/pkg/log"
"github.com/coreos/dex/repo"
"github.com/coreos/dex/user"
"github.com/go-gorp/gorp"
...
...
@@ -113,6 +115,7 @@ func (r *passwordInfoRepo) get(tx repo.Transaction, id string) (user.PasswordInf
pwm
,
ok
:=
m
.
(
*
passwordInfoModel
)
if
!
ok
{
log
.
Errorf
(
"expected passwordInfoModel but found %v"
,
reflect
.
TypeOf
(
m
))
return
user
.
PasswordInfo
{},
errors
.
New
(
"unrecognized model"
)
}
...
...
db/refresh.go
View file @
c70b29f8
...
...
@@ -4,9 +4,11 @@ import (
"encoding/base64"
"errors"
"fmt"
"reflect"
"strconv"
"strings"
"github.com/coreos/dex/pkg/log"
"github.com/coreos/dex/refresh"
"github.com/go-gorp/gorp"
"golang.org/x/crypto/bcrypt"
...
...
@@ -185,6 +187,7 @@ func (r *refreshTokenRepo) get(tx *gorp.Transaction, tokenID int64) (*refreshTok
record
,
ok
:=
result
.
(
*
refreshTokenModel
)
if
!
ok
{
log
.
Errorf
(
"expected refreshTokenModel but found %v"
,
reflect
.
TypeOf
(
result
))
return
nil
,
errors
.
New
(
"unrecognized model"
)
}
return
record
,
nil
...
...
db/session.go
View file @
c70b29f8
...
...
@@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"net/url"
"reflect"
"strings"
"time"
...
...
@@ -137,8 +138,13 @@ func (r *SessionRepo) Get(sessionID string) (*session.Session, error) {
return
nil
,
err
}
if
m
==
nil
{
return
nil
,
errors
.
New
(
"session does not exist"
)
}
sm
,
ok
:=
m
.
(
*
sessionModel
)
if
!
ok
{
log
.
Errorf
(
"expected sessionModel but found %v"
,
reflect
.
TypeOf
(
m
))
return
nil
,
errors
.
New
(
"unrecognized model"
)
}
...
...
db/session_key.go
View file @
c70b29f8
...
...
@@ -3,6 +3,7 @@ package db
import
(
"errors"
"fmt"
"reflect"
"time"
"github.com/go-gorp/gorp"
...
...
@@ -62,8 +63,13 @@ func (r *SessionKeyRepo) Pop(key string) (string, error) {
return
""
,
err
}
if
m
==
nil
{
return
""
,
errors
.
New
(
"session key does not exist"
)
}
skm
,
ok
:=
m
.
(
*
sessionKeyModel
)
if
!
ok
{
log
.
Errorf
(
"expected sessionKeyModel but found %v"
,
reflect
.
TypeOf
(
m
))
return
""
,
errors
.
New
(
"unrecognized model"
)
}
...
...
db/user.go
View file @
c70b29f8
...
...
@@ -4,11 +4,13 @@ import (
"database/sql"
"errors"
"fmt"
"reflect"
"time"
"github.com/go-gorp/gorp"
"github.com/lib/pq"
"github.com/coreos/dex/pkg/log"
"github.com/coreos/dex/repo"
"github.com/coreos/dex/user"
)
...
...
@@ -257,6 +259,7 @@ func (r *userRepo) GetRemoteIdentities(tx repo.Transaction, userID string) ([]us
for
_
,
m
:=
range
rims
{
rim
,
ok
:=
m
.
(
*
remoteIdentityMappingModel
)
if
!
ok
{
log
.
Errorf
(
"expected remoteIdentityMappingModel but found %v"
,
reflect
.
TypeOf
(
m
))
return
nil
,
errors
.
New
(
"unrecognized model"
)
}
...
...
@@ -313,6 +316,7 @@ func (r *userRepo) List(tx repo.Transaction, filter user.UserFilter, maxResults
for
i
:=
0
;
i
<
numUsers
;
i
++
{
um
,
ok
:=
ums
[
i
]
.
(
*
userModel
)
if
!
ok
{
log
.
Errorf
(
"expected userModel but found %v"
,
reflect
.
TypeOf
(
ums
[
i
]))
return
nil
,
""
,
errors
.
New
(
"unrecognized model"
)
}
usr
,
err
:=
um
.
user
()
...
...
@@ -379,6 +383,7 @@ func (r *userRepo) get(tx repo.Transaction, userID string) (user.User, error) {
um
,
ok
:=
m
.
(
*
userModel
)
if
!
ok
{
log
.
Errorf
(
"expected userModel but found %v"
,
reflect
.
TypeOf
(
m
))
return
user
.
User
{},
errors
.
New
(
"unrecognized model"
)
}
...
...
@@ -399,6 +404,7 @@ func (r *userRepo) getUserIDForRemoteIdentity(tx repo.Transaction, ri user.Remot
rim
,
ok
:=
m
.
(
*
remoteIdentityMappingModel
)
if
!
ok
{
log
.
Errorf
(
"expected remoteIdentityMappingModel but found %v"
,
reflect
.
TypeOf
(
m
))
return
""
,
errors
.
New
(
"unrecognized model"
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment