Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
server
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
m-team
oidc
mytoken
server
Commits
dd2070a9
Commit
dd2070a9
authored
3 years ago
by
Gabriel Zachmann
Browse files
Options
Downloads
Patches
Plain Diff
add auth_time to mytoken
parent
e86db238
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
internal/oidc/authcode/authcode.go
+7
-6
7 additions, 6 deletions
internal/oidc/authcode/authcode.go
shared/mytoken/mytokenHandler.go
+2
-2
2 additions, 2 deletions
shared/mytoken/mytokenHandler.go
shared/mytoken/pkg/mytoken.go
+3
-0
3 additions, 0 deletions
shared/mytoken/pkg/mytoken.go
with
12 additions
and
8 deletions
internal/oidc/authcode/authcode.go
+
7
−
6
View file @
dd2070a9
...
...
@@ -274,10 +274,9 @@ func CodeExchange(
func
createMytokenEntry
(
rlog
log
.
Ext1FieldLogger
,
tx
*
sqlx
.
Tx
,
authFlowInfo
*
authcodeinforepo
.
AuthFlowInfoOut
,
token
*
oauth2
.
Token
,
oidcSub
string
,
networkData
api
.
ClientMetaData
,
oidcSub
string
,
networkData
api
.
ClientMetaData
,
)
(
*
mytokenrepo
.
MytokenEntry
,
error
)
{
s
te
:=
mytokenrepo
.
NewMytokenEntry
(
m
te
:=
mytokenrepo
.
NewMytokenEntry
(
mytoken
.
NewMytoken
(
oidcSub
,
authFlowInfo
.
Issuer
,
...
...
@@ -285,16 +284,18 @@ func createMytokenEntry(
authFlowInfo
.
Capabilities
,
authFlowInfo
.
SubtokenCapabilities
,
authFlowInfo
.
Rotation
,
unixtime
.
Now
(),
),
authFlowInfo
.
Name
,
networkData
,
)
if
err
:=
ste
.
InitRefreshToken
(
token
.
RefreshToken
);
err
!=
nil
{
mte
.
Token
.
AuthTime
=
unixtime
.
Now
()
if
err
:=
mte
.
InitRefreshToken
(
token
.
RefreshToken
);
err
!=
nil
{
return
nil
,
err
}
if
err
:=
s
te
.
Store
(
rlog
,
tx
,
"Used grant_type oidc_flow authorization_code"
);
err
!=
nil
{
if
err
:=
m
te
.
Store
(
rlog
,
tx
,
"Used grant_type oidc_flow authorization_code"
);
err
!=
nil
{
return
nil
,
err
}
return
s
te
,
nil
return
m
te
,
nil
}
func
getSubjectFromUserinfo
(
provider
*
oidc
.
Provider
,
token
*
oauth2
.
Token
)
(
string
,
error
)
{
...
...
This diff is collapsed.
Click to expand it.
shared/mytoken/mytokenHandler.go
+
2
−
2
View file @
dd2070a9
...
...
@@ -271,8 +271,8 @@ func createMytokenEntry(
sc
=
api
.
TightenCapabilities
(
capsFromParent
,
req
.
SubtokenCapabilities
)
}
ste
:=
mytokenrepo
.
NewMytokenEntry
(
mytoken
.
NewMytoken
(
parent
.
OIDCSubject
,
parent
.
OIDCIssuer
,
r
,
c
,
sc
,
req
.
Rotation
)
,
req
.
Name
,
networkData
,
mytoken
.
NewMytoken
(
parent
.
OIDCSubject
,
parent
.
OIDCIssuer
,
r
,
c
,
sc
,
req
.
Rotation
,
parent
.
AuthTime
),
req
.
Name
,
networkData
,
)
encryptionKey
,
_
,
err
:=
encryptionkeyrepo
.
GetEncryptionKey
(
rlog
,
nil
,
parent
.
ID
,
req
.
Mytoken
.
JWT
)
if
err
!=
nil
{
...
...
This diff is collapsed.
Click to expand it.
shared/mytoken/pkg/mytoken.go
+
3
−
0
View file @
dd2070a9
...
...
@@ -34,6 +34,7 @@ type Mytoken struct {
ExpiresAt
unixtime
.
UnixTime
`json:"exp,omitempty"`
NotBefore
unixtime
.
UnixTime
`json:"nbf"`
IssuedAt
unixtime
.
UnixTime
`json:"iat"`
AuthTime
unixtime
.
UnixTime
`json:"auth_time,omitempty"`
ID
mtid
.
MTID
`json:"jti"`
SeqNo
uint64
`json:"seq_no"`
Name
string
`json:"name,omitempty"`
...
...
@@ -90,6 +91,7 @@ func (mt *Mytoken) VerifyCapabilities(required ...api.Capability) bool {
// NewMytoken creates a new Mytoken
func
NewMytoken
(
oidcSub
,
oidcIss
string
,
r
restrictions
.
Restrictions
,
c
,
sc
api
.
Capabilities
,
rot
*
api
.
Rotation
,
authTime
unixtime
.
UnixTime
,
)
*
Mytoken
{
now
:=
unixtime
.
Now
()
mt
:=
&
Mytoken
{
...
...
@@ -99,6 +101,7 @@ func NewMytoken(
SeqNo
:
1
,
IssuedAt
:
now
,
NotBefore
:
now
,
AuthTime
:
authTime
,
Issuer
:
config
.
Get
()
.
IssuerURL
,
Subject
:
utils
.
CreateMytokenSubject
(
oidcSub
,
oidcIss
),
Audience
:
config
.
Get
()
.
IssuerURL
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment