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
5e67f473
Commit
5e67f473
authored
Mar 13, 2018
by
zhengjiajin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify authenticator configuration initialization
parent
a0844c17
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
13 deletions
+9
-13
config.go
pkg/kubeapiserver/authenticator/config.go
+9
-13
No files found.
pkg/kubeapiserver/authenticator/config.go
View file @
5e67f473
...
@@ -82,7 +82,6 @@ func (config AuthenticatorConfig) New() (authenticator.Request, *spec.SecurityDe
...
@@ -82,7 +82,6 @@ func (config AuthenticatorConfig) New() (authenticator.Request, *spec.SecurityDe
var
authenticators
[]
authenticator
.
Request
var
authenticators
[]
authenticator
.
Request
var
tokenAuthenticators
[]
authenticator
.
Token
var
tokenAuthenticators
[]
authenticator
.
Token
securityDefinitions
:=
spec
.
SecurityDefinitions
{}
securityDefinitions
:=
spec
.
SecurityDefinitions
{}
hasBasicAuth
:=
false
// front-proxy, BasicAuth methods, local first, then remote
// front-proxy, BasicAuth methods, local first, then remote
// Add the front proxy authenticator if requested
// Add the front proxy authenticator if requested
...
@@ -100,13 +99,20 @@ func (config AuthenticatorConfig) New() (authenticator.Request, *spec.SecurityDe
...
@@ -100,13 +99,20 @@ func (config AuthenticatorConfig) New() (authenticator.Request, *spec.SecurityDe
authenticators
=
append
(
authenticators
,
requestHeaderAuthenticator
)
authenticators
=
append
(
authenticators
,
requestHeaderAuthenticator
)
}
}
// basic auth
if
len
(
config
.
BasicAuthFile
)
>
0
{
if
len
(
config
.
BasicAuthFile
)
>
0
{
basicAuth
,
err
:=
newAuthenticatorFromBasicAuthFile
(
config
.
BasicAuthFile
)
basicAuth
,
err
:=
newAuthenticatorFromBasicAuthFile
(
config
.
BasicAuthFile
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
nil
,
err
return
nil
,
nil
,
err
}
}
authenticators
=
append
(
authenticators
,
basicAuth
)
authenticators
=
append
(
authenticators
,
basicAuth
)
hasBasicAuth
=
true
securityDefinitions
[
"HTTPBasic"
]
=
&
spec
.
SecurityScheme
{
SecuritySchemeProps
:
spec
.
SecuritySchemeProps
{
Type
:
"basic"
,
Description
:
"HTTP Basic authentication"
,
},
}
}
}
// X509 methods
// X509 methods
...
@@ -167,15 +173,6 @@ func (config AuthenticatorConfig) New() (authenticator.Request, *spec.SecurityDe
...
@@ -167,15 +173,6 @@ func (config AuthenticatorConfig) New() (authenticator.Request, *spec.SecurityDe
tokenAuthenticators
=
append
(
tokenAuthenticators
,
webhookTokenAuth
)
tokenAuthenticators
=
append
(
tokenAuthenticators
,
webhookTokenAuth
)
}
}
if
hasBasicAuth
{
securityDefinitions
[
"HTTPBasic"
]
=
&
spec
.
SecurityScheme
{
SecuritySchemeProps
:
spec
.
SecuritySchemeProps
{
Type
:
"basic"
,
Description
:
"HTTP Basic authentication"
,
},
}
}
if
len
(
tokenAuthenticators
)
>
0
{
if
len
(
tokenAuthenticators
)
>
0
{
// Union the token authenticators
// Union the token authenticators
tokenAuth
:=
tokenunion
.
New
(
tokenAuthenticators
...
)
tokenAuth
:=
tokenunion
.
New
(
tokenAuthenticators
...
)
...
@@ -200,8 +197,7 @@ func (config AuthenticatorConfig) New() (authenticator.Request, *spec.SecurityDe
...
@@ -200,8 +197,7 @@ func (config AuthenticatorConfig) New() (authenticator.Request, *spec.SecurityDe
}
}
}
}
switch
len
(
authenticators
)
{
if
len
(
authenticators
)
==
0
{
case
0
:
return
nil
,
&
securityDefinitions
,
nil
return
nil
,
&
securityDefinitions
,
nil
}
}
...
...
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