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
3872c7e0
Commit
3872c7e0
authored
Dec 23, 2015
by
Marek Grabowski
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #18917 from yifan-gu/add_close_oidc_authn
auth: Add Close() for OIDC authenticator.
parents
8be79992
04db432f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
5 deletions
+16
-5
oidc.go
plugin/pkg/auth/authenticator/token/oidc/oidc.go
+15
-5
oidc_test.go
plugin/pkg/auth/authenticator/token/oidc/oidc_test.go
+1
-0
No files found.
plugin/pkg/auth/authenticator/token/oidc/oidc.go
View file @
3872c7e0
...
...
@@ -38,9 +38,10 @@ var (
)
type
OIDCAuthenticator
struct
{
clientConfig
oidc
.
ClientConfig
client
*
oidc
.
Client
usernameClaim
string
clientConfig
oidc
.
ClientConfig
client
*
oidc
.
Client
usernameClaim
string
stopSyncProvider
chan
struct
{}
}
// New creates a new OpenID Connect client with the given issuerURL and clientID.
...
...
@@ -113,9 +114,9 @@ func New(issuerURL, clientID, caFile, usernameClaim string) (*OIDCAuthenticator,
// SyncProviderConfig will start a goroutine to periodically synchronize the provider config.
// The synchronization interval is set by the expiration length of the config, and has a mininum
// and maximum threshold.
client
.
SyncProviderConfig
(
issuerURL
)
stop
:=
client
.
SyncProviderConfig
(
issuerURL
)
return
&
OIDCAuthenticator
{
ccfg
,
client
,
usernameClaim
},
nil
return
&
OIDCAuthenticator
{
ccfg
,
client
,
usernameClaim
,
stop
},
nil
}
// AuthenticateToken decodes and verifies a JWT using the OIDC client, if the verification succeeds,
...
...
@@ -156,3 +157,12 @@ func (a *OIDCAuthenticator) AuthenticateToken(value string) (user.Info, bool, er
// TODO(yifan): Add UID and Group, also populate the issuer to upper layer.
return
&
user
.
DefaultInfo
{
Name
:
username
},
true
,
nil
}
// Close closes the OIDC authenticator, this will close the provider sync goroutine.
func
(
a
*
OIDCAuthenticator
)
Close
()
{
// This assumes the s.stopSyncProvider is an unbuffered channel.
// So instead of closing the channel, we send am empty struct here.
// This guarantees that when this function returns, there is no flying requests,
// because a send to an unbuffered channel happens after the receive from the channel.
a
.
stopSyncProvider
<-
struct
{}{}
}
plugin/pkg/auth/authenticator/token/oidc/oidc_test.go
View file @
3872c7e0
...
...
@@ -391,5 +391,6 @@ func TestOIDCAuthentication(t *testing.T) {
if
!
reflect
.
DeepEqual
(
tt
.
userInfo
,
user
)
{
t
.
Errorf
(
"#%d: Expecting: %v, but got: %v"
,
i
,
tt
.
userInfo
,
user
)
}
client
.
Close
()
}
}
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