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
b119ffdd
Commit
b119ffdd
authored
Feb 14, 2017
by
rithu leena john
Committed by
GitHub
Feb 14, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #801 from rithujohn191/token-revocation
api: adding a gRPC call for listing refresh tokens.
parents
53e38367
d201e492
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
229 additions
and
51 deletions
+229
-51
api.pb.go
api/api.pb.go
+132
-42
api.proto
api/api.proto
+23
-1
api.go
server/api.go
+30
-0
handlers.go
server/handlers.go
+3
-3
types.pb.go
server/internal/types.pb.go
+20
-3
types.proto
server/internal/types.proto
+7
-0
oauth2.go
server/oauth2.go
+14
-2
No files found.
api/api.pb.go
View file @
b119ffdd
...
...
@@ -25,6 +25,9 @@ It has these top-level messages:
ListPasswordResp
VersionReq
VersionResp
RefreshTokenRef
ListRefreshReq
ListRefreshResp
*/
package
api
...
...
@@ -213,7 +216,7 @@ func (m *ListPasswordReq) String() string { return proto.CompactTextS
func
(
*
ListPasswordReq
)
ProtoMessage
()
{}
func
(
*
ListPasswordReq
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
fileDescriptor0
,
[]
int
{
12
}
}
// ListPasswordResp returs a list of passwords.
// ListPasswordResp retur
n
s a list of passwords.
type
ListPasswordResp
struct
{
Passwords
[]
*
Password
`protobuf:"bytes,1,rep,name=passwords" json:"passwords,omitempty"`
}
...
...
@@ -253,6 +256,48 @@ func (m *VersionResp) String() string { return proto.CompactTextStrin
func
(
*
VersionResp
)
ProtoMessage
()
{}
func
(
*
VersionResp
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
fileDescriptor0
,
[]
int
{
15
}
}
// RefreshTokenRef contains the metadata for a refresh token that is managed by the storage.
type
RefreshTokenRef
struct
{
// ID of the refresh token.
Id
string
`protobuf:"bytes,1,opt,name=id" json:"id,omitempty"`
ClientId
string
`protobuf:"bytes,2,opt,name=client_id,json=clientId" json:"client_id,omitempty"`
CreatedAt
string
`protobuf:"bytes,3,opt,name=created_at,json=createdAt" json:"created_at,omitempty"`
LastUsed
string
`protobuf:"bytes,4,opt,name=last_used,json=lastUsed" json:"last_used,omitempty"`
}
func
(
m
*
RefreshTokenRef
)
Reset
()
{
*
m
=
RefreshTokenRef
{}
}
func
(
m
*
RefreshTokenRef
)
String
()
string
{
return
proto
.
CompactTextString
(
m
)
}
func
(
*
RefreshTokenRef
)
ProtoMessage
()
{}
func
(
*
RefreshTokenRef
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
fileDescriptor0
,
[]
int
{
16
}
}
// ListRefreshReq is a request to enumerate the refresh tokens of a user.
type
ListRefreshReq
struct
{
// The "sub" claim returned in the ID Token.
UserId
string
`protobuf:"bytes,1,opt,name=user_id,json=userId" json:"user_id,omitempty"`
}
func
(
m
*
ListRefreshReq
)
Reset
()
{
*
m
=
ListRefreshReq
{}
}
func
(
m
*
ListRefreshReq
)
String
()
string
{
return
proto
.
CompactTextString
(
m
)
}
func
(
*
ListRefreshReq
)
ProtoMessage
()
{}
func
(
*
ListRefreshReq
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
fileDescriptor0
,
[]
int
{
17
}
}
// ListRefreshResp returns a list of refresh tokens for a user.
type
ListRefreshResp
struct
{
RefreshTokens
[]
*
RefreshTokenRef
`protobuf:"bytes,1,rep,name=refresh_tokens,json=refreshTokens" json:"refresh_tokens,omitempty"`
}
func
(
m
*
ListRefreshResp
)
Reset
()
{
*
m
=
ListRefreshResp
{}
}
func
(
m
*
ListRefreshResp
)
String
()
string
{
return
proto
.
CompactTextString
(
m
)
}
func
(
*
ListRefreshResp
)
ProtoMessage
()
{}
func
(
*
ListRefreshResp
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
fileDescriptor0
,
[]
int
{
18
}
}
func
(
m
*
ListRefreshResp
)
GetRefreshTokens
()
[]
*
RefreshTokenRef
{
if
m
!=
nil
{
return
m
.
RefreshTokens
}
return
nil
}
func
init
()
{
proto
.
RegisterType
((
*
Client
)(
nil
),
"api.Client"
)
proto
.
RegisterType
((
*
CreateClientReq
)(
nil
),
"api.CreateClientReq"
)
...
...
@@ -270,6 +315,9 @@ func init() {
proto
.
RegisterType
((
*
ListPasswordResp
)(
nil
),
"api.ListPasswordResp"
)
proto
.
RegisterType
((
*
VersionReq
)(
nil
),
"api.VersionReq"
)
proto
.
RegisterType
((
*
VersionResp
)(
nil
),
"api.VersionResp"
)
proto
.
RegisterType
((
*
RefreshTokenRef
)(
nil
),
"api.RefreshTokenRef"
)
proto
.
RegisterType
((
*
ListRefreshReq
)(
nil
),
"api.ListRefreshReq"
)
proto
.
RegisterType
((
*
ListRefreshResp
)(
nil
),
"api.ListRefreshResp"
)
}
// Reference imports to suppress errors if they are not otherwise used.
...
...
@@ -297,6 +345,8 @@ type DexClient interface {
ListPasswords
(
ctx
context
.
Context
,
in
*
ListPasswordReq
,
opts
...
grpc
.
CallOption
)
(
*
ListPasswordResp
,
error
)
// GetVersion returns version information of the server.
GetVersion
(
ctx
context
.
Context
,
in
*
VersionReq
,
opts
...
grpc
.
CallOption
)
(
*
VersionResp
,
error
)
// ListRefresh lists all the refresh token entries for a particular user.
ListRefresh
(
ctx
context
.
Context
,
in
*
ListRefreshReq
,
opts
...
grpc
.
CallOption
)
(
*
ListRefreshResp
,
error
)
}
type
dexClient
struct
{
...
...
@@ -370,6 +420,15 @@ func (c *dexClient) GetVersion(ctx context.Context, in *VersionReq, opts ...grpc
return
out
,
nil
}
func
(
c
*
dexClient
)
ListRefresh
(
ctx
context
.
Context
,
in
*
ListRefreshReq
,
opts
...
grpc
.
CallOption
)
(
*
ListRefreshResp
,
error
)
{
out
:=
new
(
ListRefreshResp
)
err
:=
grpc
.
Invoke
(
ctx
,
"/api.Dex/ListRefresh"
,
in
,
out
,
c
.
cc
,
opts
...
)
if
err
!=
nil
{
return
nil
,
err
}
return
out
,
nil
}
// Server API for Dex service
type
DexServer
interface
{
...
...
@@ -387,6 +446,8 @@ type DexServer interface {
ListPasswords
(
context
.
Context
,
*
ListPasswordReq
)
(
*
ListPasswordResp
,
error
)
// GetVersion returns version information of the server.
GetVersion
(
context
.
Context
,
*
VersionReq
)
(
*
VersionResp
,
error
)
// ListRefresh lists all the refresh token entries for a particular user.
ListRefresh
(
context
.
Context
,
*
ListRefreshReq
)
(
*
ListRefreshResp
,
error
)
}
func
RegisterDexServer
(
s
*
grpc
.
Server
,
srv
DexServer
)
{
...
...
@@ -519,6 +580,24 @@ func _Dex_GetVersion_Handler(srv interface{}, ctx context.Context, dec func(inte
return
interceptor
(
ctx
,
in
,
info
,
handler
)
}
func
_Dex_ListRefresh_Handler
(
srv
interface
{},
ctx
context
.
Context
,
dec
func
(
interface
{})
error
,
interceptor
grpc
.
UnaryServerInterceptor
)
(
interface
{},
error
)
{
in
:=
new
(
ListRefreshReq
)
if
err
:=
dec
(
in
);
err
!=
nil
{
return
nil
,
err
}
if
interceptor
==
nil
{
return
srv
.
(
DexServer
)
.
ListRefresh
(
ctx
,
in
)
}
info
:=
&
grpc
.
UnaryServerInfo
{
Server
:
srv
,
FullMethod
:
"/api.Dex/ListRefresh"
,
}
handler
:=
func
(
ctx
context
.
Context
,
req
interface
{})
(
interface
{},
error
)
{
return
srv
.
(
DexServer
)
.
ListRefresh
(
ctx
,
req
.
(
*
ListRefreshReq
))
}
return
interceptor
(
ctx
,
in
,
info
,
handler
)
}
var
_Dex_serviceDesc
=
grpc
.
ServiceDesc
{
ServiceName
:
"api.Dex"
,
HandlerType
:
(
*
DexServer
)(
nil
),
...
...
@@ -551,6 +630,10 @@ var _Dex_serviceDesc = grpc.ServiceDesc{
MethodName
:
"GetVersion"
,
Handler
:
_Dex_GetVersion_Handler
,
},
{
MethodName
:
"ListRefresh"
,
Handler
:
_Dex_ListRefresh_Handler
,
},
},
Streams
:
[]
grpc
.
StreamDesc
{},
Metadata
:
fileDescriptor0
,
...
...
@@ -559,45 +642,52 @@ var _Dex_serviceDesc = grpc.ServiceDesc{
func
init
()
{
proto
.
RegisterFile
(
"api/api.proto"
,
fileDescriptor0
)
}
var
fileDescriptor0
=
[]
byte
{
// 625 bytes of a gzipped FileDescriptorProto
0x1f
,
0x8b
,
0x08
,
0x00
,
0x00
,
0x09
,
0x6e
,
0x88
,
0x02
,
0xff
,
0x8c
,
0x55
,
0x4f
,
0x4f
,
0xdb
,
0x4e
,
0x10
,
0x4d
,
0x62
,
0x48
,
0x9c
,
0x49
,
0x42
,
0x92
,
0x11
,
0x3f
,
0x30
,
0xf9
,
0x5d
,
0x60
,
0x51
,
0x25
,
0x50
,
0x25
,
0x10
,
0x54
,
0x6a
,
0x0f
,
0x55
,
0xe9
,
0x01
,
0xfa
,
0x4f
,
0xea
,
0x01
,
0x59
,
0x4a
,
0x8f
,
0xb5
,
0x4c
,
0x3c
,
0x85
,
0x95
,
0x8c
,
0xbd
,
0xdd
,
0xb5
,
0x1b
,
0xfa
,
0xf1
,
0x7a
,
0xe8
,
0xf7
,
0xaa
,
0x76
,
0xbd
,
0x09
,
0xb6
,
0x43
,
0x95
,
0xde
,
0xfc
,
0xde
,
0xce
,
0xbc
,
0xd9
,
0x79
,
0x33
,
0x9b
,
0xc0
,
0x20
,
0x14
,
0xfc
,
0x34
,
0x14
,
0xfc
,
0x44
,
0xc8
,
0x34
,
0x4b
,
0xd1
,
0x09
,
0x05
,
0x67
,
0xbf
,
0x9a
,
0xd0
,
0xbe
,
0x8c
,
0x39
,
0x25
,
0x19
,
0x6e
,
0x41
,
0x8b
,
0x47
,
0x5e
,
0x73
,
0xbf
,
0x79
,
0xd4
,
0xf5
,
0x5b
,
0x3c
,
0xc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
0x96
,
0xbe
,
0xf0
,
0x44
,
0x07
,
0x00
,
0x00
,
}
api/api.proto
View file @
b119ffdd
...
...
@@ -83,7 +83,7 @@ message DeletePasswordResp {
// ListPasswordReq is a request to enumerate passwords.
message
ListPasswordReq
{}
// ListPasswordResp returs a list of passwords.
// ListPasswordResp retur
n
s a list of passwords.
message
ListPasswordResp
{
repeated
Password
passwords
=
1
;
}
...
...
@@ -100,6 +100,26 @@ message VersionResp {
int32
api
=
2
;
}
// RefreshTokenRef contains the metadata for a refresh token that is managed by the storage.
message
RefreshTokenRef
{
// ID of the refresh token.
string
id
=
1
;
string
client_id
=
2
;
string
created_at
=
3
;
string
last_used
=
4
;
}
// ListRefreshReq is a request to enumerate the refresh tokens of a user.
message
ListRefreshReq
{
// The "sub" claim returned in the ID Token.
string
user_id
=
1
;
}
// ListRefreshResp returns a list of refresh tokens for a user.
message
ListRefreshResp
{
repeated
RefreshTokenRef
refresh_tokens
=
1
;
}
// Dex represents the dex gRPC service.
service
Dex
{
// CreateClient creates a client.
...
...
@@ -116,4 +136,6 @@ service Dex {
rpc
ListPasswords
(
ListPasswordReq
)
returns
(
ListPasswordResp
)
{};
// GetVersion returns version information of the server.
rpc
GetVersion
(
VersionReq
)
returns
(
VersionResp
)
{};
// ListRefresh lists all the refresh token entries for a particular user.
rpc
ListRefresh
(
ListRefreshReq
)
returns
(
ListRefreshResp
)
{};
}
server/api.go
View file @
b119ffdd
...
...
@@ -9,6 +9,7 @@ import (
"github.com/Sirupsen/logrus"
"github.com/coreos/dex/api"
"github.com/coreos/dex/server/internal"
"github.com/coreos/dex/storage"
"github.com/coreos/dex/version"
)
...
...
@@ -198,3 +199,32 @@ func (d dexAPI) ListPasswords(ctx context.Context, req *api.ListPasswordReq) (*a
},
nil
}
func
(
d
dexAPI
)
ListRefresh
(
ctx
context
.
Context
,
req
*
api
.
ListRefreshReq
)
(
*
api
.
ListRefreshResp
,
error
)
{
id
:=
new
(
internal
.
IDTokenSubject
)
if
err
:=
internal
.
Unmarshal
(
req
.
UserId
,
id
);
err
!=
nil
{
d
.
logger
.
Errorf
(
"api: failed to unmarshal ID Token subject: %v"
,
err
)
return
nil
,
fmt
.
Errorf
(
"unmarshal ID Token subject: %v"
,
err
)
}
offlineSessions
,
err
:=
d
.
s
.
GetOfflineSessions
(
id
.
UserId
,
id
.
ConnId
)
if
err
!=
nil
{
d
.
logger
.
Errorf
(
"api: failed to list refresh tokens: %v"
,
err
)
return
nil
,
fmt
.
Errorf
(
"list refresh tokens: %v"
,
err
)
}
var
refreshTokenRefs
[]
*
api
.
RefreshTokenRef
for
_
,
session
:=
range
offlineSessions
.
Refresh
{
r
:=
api
.
RefreshTokenRef
{
Id
:
session
.
ID
,
ClientId
:
session
.
ClientID
,
CreatedAt
:
session
.
CreatedAt
.
String
(),
LastUsed
:
session
.
LastUsed
.
String
(),
}
refreshTokenRefs
=
append
(
refreshTokenRefs
,
&
r
)
}
return
&
api
.
ListRefreshResp
{
RefreshTokens
:
refreshTokenRefs
,
},
nil
}
server/handlers.go
View file @
b119ffdd
...
...
@@ -510,7 +510,7 @@ func (s *Server) sendCodeResponse(w http.ResponseWriter, r *http.Request, authRe
case
responseTypeIDToken
:
implicitOrHybrid
=
true
var
err
error
idToken
,
idTokenExpiry
,
err
=
s
.
newIDToken
(
authReq
.
ClientID
,
authReq
.
Claims
,
authReq
.
Scopes
,
authReq
.
Nonce
,
accessToken
)
idToken
,
idTokenExpiry
,
err
=
s
.
newIDToken
(
authReq
.
ClientID
,
authReq
.
Claims
,
authReq
.
Scopes
,
authReq
.
Nonce
,
accessToken
,
authReq
.
ConnectorID
)
if
err
!=
nil
{
s
.
logger
.
Errorf
(
"failed to create ID token: %v"
,
err
)
s
.
tokenErrHelper
(
w
,
errServerError
,
""
,
http
.
StatusInternalServerError
)
...
...
@@ -632,7 +632,7 @@ func (s *Server) handleAuthCode(w http.ResponseWriter, r *http.Request, client s
}
accessToken
:=
storage
.
NewID
()
idToken
,
expiry
,
err
:=
s
.
newIDToken
(
client
.
ID
,
authCode
.
Claims
,
authCode
.
Scopes
,
authCode
.
Nonce
,
accessToken
)
idToken
,
expiry
,
err
:=
s
.
newIDToken
(
client
.
ID
,
authCode
.
Claims
,
authCode
.
Scopes
,
authCode
.
Nonce
,
accessToken
,
authCode
.
ConnectorID
)
if
err
!=
nil
{
s
.
logger
.
Errorf
(
"failed to create ID token: %v"
,
err
)
s
.
tokenErrHelper
(
w
,
errServerError
,
""
,
http
.
StatusInternalServerError
)
...
...
@@ -866,7 +866,7 @@ func (s *Server) handleRefreshToken(w http.ResponseWriter, r *http.Request, clie
}
accessToken
:=
storage
.
NewID
()
idToken
,
expiry
,
err
:=
s
.
newIDToken
(
client
.
ID
,
claims
,
scopes
,
refresh
.
Nonce
,
accessToken
)
idToken
,
expiry
,
err
:=
s
.
newIDToken
(
client
.
ID
,
claims
,
scopes
,
refresh
.
Nonce
,
accessToken
,
refresh
.
ConnectorID
)
if
err
!=
nil
{
s
.
logger
.
Errorf
(
"failed to create ID token: %v"
,
err
)
s
.
tokenErrHelper
(
w
,
errServerError
,
""
,
http
.
StatusInternalServerError
)
...
...
server/internal/types.pb.go
View file @
b119ffdd
...
...
@@ -12,6 +12,7 @@ It is generated from these files:
It has these top-level messages:
RefreshToken
IDTokenSubject
*/
package
internal
...
...
@@ -41,19 +42,35 @@ func (m *RefreshToken) String() string { return proto.CompactTextStri
func
(
*
RefreshToken
)
ProtoMessage
()
{}
func
(
*
RefreshToken
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
fileDescriptor0
,
[]
int
{
0
}
}
// IDTokenSubject represents both the userID and connID which is returned
// as the "sub" claim in the ID Token.
type
IDTokenSubject
struct
{
UserId
string
`protobuf:"bytes,1,opt,name=user_id,json=userId" json:"user_id,omitempty"`
ConnId
string
`protobuf:"bytes,2,opt,name=conn_id,json=connId" json:"conn_id,omitempty"`
}
func
(
m
*
IDTokenSubject
)
Reset
()
{
*
m
=
IDTokenSubject
{}
}
func
(
m
*
IDTokenSubject
)
String
()
string
{
return
proto
.
CompactTextString
(
m
)
}
func
(
*
IDTokenSubject
)
ProtoMessage
()
{}
func
(
*
IDTokenSubject
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
fileDescriptor0
,
[]
int
{
1
}
}
func
init
()
{
proto
.
RegisterType
((
*
RefreshToken
)(
nil
),
"internal.RefreshToken"
)
proto
.
RegisterType
((
*
IDTokenSubject
)(
nil
),
"internal.IDTokenSubject"
)
}
func
init
()
{
proto
.
RegisterFile
(
"server/internal/types.proto"
,
fileDescriptor0
)
}
var
fileDescriptor0
=
[]
byte
{
// 1
12
bytes of a gzipped FileDescriptorProto
// 1
57
bytes of a gzipped FileDescriptorProto
0x1f
,
0x8b
,
0x08
,
0x00
,
0x00
,
0x09
,
0x6e
,
0x88
,
0x02
,
0xff
,
0xe2
,
0x92
,
0x2e
,
0x4e
,
0x2d
,
0x2a
,
0x4b
,
0x2d
,
0xd2
,
0xcf
,
0xcc
,
0x2b
,
0x49
,
0x2d
,
0xca
,
0x4b
,
0xcc
,
0xd1
,
0x2f
,
0xa9
,
0x2c
,
0x48
,
0x2d
,
0xd6
,
0x2b
,
0x28
,
0xca
,
0x2f
,
0xc9
,
0x17
,
0xe2
,
0x80
,
0x89
,
0x2a
,
0x39
,
0x73
,
0xf1
,
0x04
,
0xa5
,
0xa6
,
0x15
,
0xa5
,
0x16
,
0x67
,
0x84
,
0xe4
,
0x67
,
0xa7
,
0xe6
,
0x09
,
0xc9
,
0x72
,
0x71
,
0x15
,
0x41
,
0xf8
,
0xf1
,
0x99
,
0x29
,
0x12
,
0x8c
,
0x0a
,
0x8c
,
0x1a
,
0x9c
,
0x41
,
0x9c
,
0x50
,
0x11
,
0xcf
,
0x14
,
0x21
,
0x11
,
0x2e
,
0xd6
,
0x12
,
0x90
,
0x3a
,
0x09
,
0x26
,
0xb0
,
0x0c
,
0x84
,
0x93
,
0xc4
,
0x06
,
0x36
,
0xd5
,
0x18
,
0x10
,
0x00
,
0x00
,
0xff
,
0xff
,
0x9b
,
0xd0
,
0x5a
,
0x1d
,
0x74
,
0x00
,
0x00
,
0x00
,
0x14
,
0x21
,
0x11
,
0x2e
,
0xd6
,
0x12
,
0x90
,
0x3a
,
0x09
,
0x26
,
0xb0
,
0x0c
,
0x84
,
0xa3
,
0xe4
,
0xc4
,
0xc5
,
0xe7
,
0xe9
,
0x02
,
0xd6
,
0x1f
,
0x5c
,
0x9a
,
0x94
,
0x95
,
0x9a
,
0x5c
,
0x22
,
0x24
,
0xce
,
0xc5
,
0x5e
,
0x5a
,
0x9c
,
0x5a
,
0x84
,
0x30
,
0x83
,
0x0d
,
0xc4
,
0xf5
,
0x4c
,
0x01
,
0x49
,
0x24
,
0xe7
,
0xe7
,
0xe5
,
0x81
,
0x24
,
0x20
,
0x46
,
0xb0
,
0x81
,
0xb8
,
0x9e
,
0x29
,
0x49
,
0x6c
,
0x60
,
0x97
,
0x19
,
0x03
,
0x02
,
0x00
,
0x00
,
0xff
,
0xff
,
0x13
,
0xfe
,
0x01
,
0x37
,
0xb8
,
0x00
,
0x00
,
0x00
,
}
server/internal/types.proto
View file @
b119ffdd
...
...
@@ -8,3 +8,10 @@ message RefreshToken {
string
refresh_id
=
1
;
string
token
=
2
;
}
// IDTokenSubject represents both the userID and connID which is returned
// as the "sub" claim in the ID Token.
message
IDTokenSubject
{
string
user_id
=
1
;
string
conn_id
=
2
;
}
server/oauth2.go
View file @
b119ffdd
...
...
@@ -21,6 +21,7 @@ import (
jose
"gopkg.in/square/go-jose.v2"
"github.com/coreos/dex/connector"
"github.com/coreos/dex/server/internal"
"github.com/coreos/dex/storage"
)
...
...
@@ -246,7 +247,7 @@ type idTokenClaims struct {
Name
string
`json:"name,omitempty"`
}
func
(
s
*
Server
)
newIDToken
(
clientID
string
,
claims
storage
.
Claims
,
scopes
[]
string
,
nonce
,
accessToken
string
)
(
idToken
string
,
expiry
time
.
Time
,
err
error
)
{
func
(
s
*
Server
)
newIDToken
(
clientID
string
,
claims
storage
.
Claims
,
scopes
[]
string
,
nonce
,
accessToken
,
connID
string
)
(
idToken
string
,
expiry
time
.
Time
,
err
error
)
{
keys
,
err
:=
s
.
storage
.
GetKeys
()
if
err
!=
nil
{
s
.
logger
.
Errorf
(
"Failed to get keys: %v"
,
err
)
...
...
@@ -265,9 +266,20 @@ func (s *Server) newIDToken(clientID string, claims storage.Claims, scopes []str
issuedAt
:=
s
.
now
()
expiry
=
issuedAt
.
Add
(
s
.
idTokensValidFor
)
sub
:=
&
internal
.
IDTokenSubject
{
UserId
:
claims
.
UserID
,
ConnId
:
connID
,
}
subjectString
,
err
:=
internal
.
Marshal
(
sub
)
if
err
!=
nil
{
s
.
logger
.
Errorf
(
"failed to marshal offline session ID: %v"
,
err
)
return
""
,
expiry
,
fmt
.
Errorf
(
"failed to marshal offline session ID: %v"
,
err
)
}
tok
:=
idTokenClaims
{
Issuer
:
s
.
issuerURL
.
String
(),
Subject
:
claims
.
UserID
,
Subject
:
subjectString
,
Nonce
:
nonce
,
Expiry
:
expiry
.
Unix
(),
IssuedAt
:
issuedAt
.
Unix
(),
...
...
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