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
c5dc0915
Unverified
Commit
c5dc0915
authored
Aug 26, 2020
by
Erik Wilson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move basic authentication to k3s
parent
57fc0c9c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
2 deletions
+36
-2
auth.go
pkg/daemons/control/auth.go
+30
-0
server.go
pkg/daemons/control/server.go
+6
-2
No files found.
pkg/daemons/control/auth.go
0 → 100644
View file @
c5dc0915
package
control
import
(
"github.com/rancher/k3s/pkg/authenticator/basicauth"
"github.com/rancher/k3s/pkg/authenticator/passwordfile"
"k8s.io/apiserver/pkg/authentication/authenticator"
"k8s.io/apiserver/pkg/authentication/group"
"k8s.io/apiserver/pkg/authentication/request/union"
)
func
basicAuthenticator
(
basicAuthFile
string
)
(
authenticator
.
Request
,
error
)
{
if
basicAuthFile
==
""
{
return
nil
,
nil
}
basicAuthenticator
,
err
:=
passwordfile
.
NewCSV
(
basicAuthFile
)
if
err
!=
nil
{
return
nil
,
err
}
return
basicauth
.
New
(
basicAuthenticator
),
nil
}
func
combineAuthenticators
(
auths
...
authenticator
.
Request
)
authenticator
.
Request
{
var
authenticators
[]
authenticator
.
Request
for
_
,
auth
:=
range
auths
{
if
auth
!=
nil
{
authenticators
=
append
(
authenticators
,
auth
)
}
}
return
group
.
NewAuthenticatedGroupAdder
(
union
.
New
(
authenticators
...
))
}
pkg/daemons/control/server.go
View file @
c5dc0915
...
...
@@ -102,8 +102,13 @@ func Server(ctx context.Context, cfg *config.Control) error {
return
err
}
basicAuth
,
err
:=
basicAuthenticator
(
runtime
.
PasswdFile
)
if
err
!=
nil
{
return
err
}
runtime
.
Authenticator
=
combineAuthenticators
(
basicAuth
,
auth
)
runtime
.
Handler
=
handler
runtime
.
Authenticator
=
auth
if
!
cfg
.
NoScheduler
{
if
err
:=
scheduler
(
cfg
,
runtime
);
err
!=
nil
{
...
...
@@ -195,7 +200,6 @@ func apiServer(ctx context.Context, cfg *config.Control, runtime *config.Control
argsMap
[
"service-account-key-file"
]
=
runtime
.
ServiceKey
argsMap
[
"service-account-issuer"
]
=
version
.
Program
argsMap
[
"api-audiences"
]
=
"unknown"
argsMap
[
"basic-auth-file"
]
=
runtime
.
PasswdFile
argsMap
[
"kubelet-certificate-authority"
]
=
runtime
.
ServerCA
argsMap
[
"kubelet-client-certificate"
]
=
runtime
.
ClientKubeAPICert
argsMap
[
"kubelet-client-key"
]
=
runtime
.
ClientKubeAPIKey
...
...
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