Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
eedf6380
Commit
eedf6380
authored
Jan 20, 2018
by
zouyee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sync code from copy destination
parent
f9bb978a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
8 deletions
+11
-8
bootstrap.go
plugin/pkg/auth/authenticator/token/bootstrap/bootstrap.go
+11
-8
No files found.
plugin/pkg/auth/authenticator/token/bootstrap/bootstrap.go
View file @
eedf6380
...
@@ -152,13 +152,12 @@ func (t *TokenAuthenticator) AuthenticateToken(token string) (user.Info, bool, e
...
@@ -152,13 +152,12 @@ func (t *TokenAuthenticator) AuthenticateToken(token string) (user.Info, bool, e
// Copied from k8s.io/client-go/tools/bootstrap/token/api
// Copied from k8s.io/client-go/tools/bootstrap/token/api
func
getSecretString
(
secret
*
api
.
Secret
,
key
string
)
string
{
func
getSecretString
(
secret
*
api
.
Secret
,
key
string
)
string
{
if
secret
.
Data
==
nil
{
data
,
ok
:=
secret
.
Data
[
key
]
if
!
ok
{
return
""
return
""
}
}
if
val
,
ok
:=
secret
.
Data
[
key
];
ok
{
return
string
(
val
)
return
string
(
data
)
}
return
""
}
}
// Copied from k8s.io/client-go/tools/bootstrap/token/api
// Copied from k8s.io/client-go/tools/bootstrap/token/api
...
@@ -167,11 +166,13 @@ func isSecretExpired(secret *api.Secret) bool {
...
@@ -167,11 +166,13 @@ func isSecretExpired(secret *api.Secret) bool {
if
len
(
expiration
)
>
0
{
if
len
(
expiration
)
>
0
{
expTime
,
err2
:=
time
.
Parse
(
time
.
RFC3339
,
expiration
)
expTime
,
err2
:=
time
.
Parse
(
time
.
RFC3339
,
expiration
)
if
err2
!=
nil
{
if
err2
!=
nil
{
tokenErrorf
(
secret
,
"has unparsable expiration time (%s). Treating as expired."
,
expiration
)
glog
.
V
(
3
)
.
Infof
(
"Unparseable expiration time (%s) in %s/%s Secret: %v. Treating as expired."
,
expiration
,
secret
.
Namespace
,
secret
.
Name
,
err2
)
return
true
return
true
}
}
if
time
.
Now
()
.
After
(
expTime
)
{
if
time
.
Now
()
.
After
(
expTime
)
{
tokenErrorf
(
secret
,
"has expired."
,
expiration
)
glog
.
V
(
3
)
.
Infof
(
"Expired bootstrap token in %s/%s Secret: %v"
,
secret
.
Namespace
,
secret
.
Name
,
expiration
)
return
true
return
true
}
}
}
}
...
@@ -181,8 +182,10 @@ func isSecretExpired(secret *api.Secret) bool {
...
@@ -181,8 +182,10 @@ func isSecretExpired(secret *api.Secret) bool {
// Copied from kubernetes/cmd/kubeadm/app/util/token
// Copied from kubernetes/cmd/kubeadm/app/util/token
var
(
var
(
// tokenRegexpString defines id.secret regular expression pattern
tokenRegexpString
=
"^([a-z0-9]{6})
\\
.([a-z0-9]{16})$"
tokenRegexpString
=
"^([a-z0-9]{6})
\\
.([a-z0-9]{16})$"
tokenRegexp
=
regexp
.
MustCompile
(
tokenRegexpString
)
// tokenRegexp is a compiled regular expression of TokenRegexpString
tokenRegexp
=
regexp
.
MustCompile
(
tokenRegexpString
)
)
)
// parseToken tries and parse a valid token from a string.
// parseToken tries and parse a valid token from a string.
...
...
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