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
79b525e5
Commit
79b525e5
authored
Nov 18, 2016
by
xilabao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auth duplicate detect, add warning message
parent
2c61d2f8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
2 deletions
+20
-2
BUILD
plugin/pkg/auth/authenticator/password/passwordfile/BUILD
+4
-1
passwordfile.go
.../auth/authenticator/password/passwordfile/passwordfile.go
+6
-0
BUILD
plugin/pkg/auth/authenticator/token/tokenfile/BUILD
+4
-1
tokenfile.go
plugin/pkg/auth/authenticator/token/tokenfile/tokenfile.go
+6
-0
No files found.
plugin/pkg/auth/authenticator/password/passwordfile/BUILD
View file @
79b525e5
...
...
@@ -14,7 +14,10 @@ go_library(
name = "go_default_library",
srcs = ["passwordfile.go"],
tags = ["automanaged"],
deps = ["//pkg/auth/user:go_default_library"],
deps = [
"//pkg/auth/user:go_default_library",
"//vendor:github.com/golang/glog",
],
)
go_test(
...
...
plugin/pkg/auth/authenticator/password/passwordfile/passwordfile.go
View file @
79b525e5
...
...
@@ -22,6 +22,7 @@ import (
"io"
"os"
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/auth/user"
)
...
...
@@ -43,6 +44,7 @@ func NewCSV(path string) (*PasswordAuthenticator, error) {
}
defer
file
.
Close
()
recordNum
:=
0
users
:=
make
(
map
[
string
]
*
userPasswordInfo
)
reader
:=
csv
.
NewReader
(
file
)
for
{
...
...
@@ -60,6 +62,10 @@ func NewCSV(path string) (*PasswordAuthenticator, error) {
info
:
&
user
.
DefaultInfo
{
Name
:
record
[
1
],
UID
:
record
[
2
]},
password
:
record
[
0
],
}
recordNum
++
if
_
,
exist
:=
users
[
obj
.
info
.
Name
];
exist
{
glog
.
Warningf
(
"duplicate username '%s' has been found in password file '%s', record number '%d'"
,
obj
.
info
.
Name
,
path
,
recordNum
)
}
users
[
obj
.
info
.
Name
]
=
obj
}
...
...
plugin/pkg/auth/authenticator/token/tokenfile/BUILD
View file @
79b525e5
...
...
@@ -14,7 +14,10 @@ go_library(
name = "go_default_library",
srcs = ["tokenfile.go"],
tags = ["automanaged"],
deps = ["//pkg/auth/user:go_default_library"],
deps = [
"//pkg/auth/user:go_default_library",
"//vendor:github.com/golang/glog",
],
)
go_test(
...
...
plugin/pkg/auth/authenticator/token/tokenfile/tokenfile.go
View file @
79b525e5
...
...
@@ -23,6 +23,7 @@ import (
"os"
"strings"
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/auth/user"
)
...
...
@@ -46,6 +47,7 @@ func NewCSV(path string) (*TokenAuthenticator, error) {
}
defer
file
.
Close
()
recordNum
:=
0
tokens
:=
make
(
map
[
string
]
*
user
.
DefaultInfo
)
reader
:=
csv
.
NewReader
(
file
)
reader
.
FieldsPerRecord
=
-
1
...
...
@@ -64,6 +66,10 @@ func NewCSV(path string) (*TokenAuthenticator, error) {
Name
:
record
[
1
],
UID
:
record
[
2
],
}
recordNum
++
if
_
,
exist
:=
tokens
[
record
[
0
]];
exist
{
glog
.
Warningf
(
"duplicate token has been found in token file '%s', record number '%d'"
,
path
,
recordNum
)
}
tokens
[
record
[
0
]]
=
obj
if
len
(
record
)
>=
4
{
...
...
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