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
5f7fea2f
Commit
5f7fea2f
authored
Oct 23, 2015
by
Filip Grzadkowski
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #15974 from gambol99/rj/groups_fields_quoted
single column groups option in tokenfile
parents
ebee4bb3
ee691aa1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
5 deletions
+25
-5
authentication.md
docs/admin/authentication.md
+5
-1
tokenfile.go
plugin/pkg/auth/authenticator/token/tokenfile/tokenfile.go
+3
-2
tokenfile_test.go
.../pkg/auth/authenticator/token/tokenfile/tokenfile_test.go
+17
-2
No files found.
docs/admin/authentication.md
View file @
5f7fea2f
...
...
@@ -47,7 +47,11 @@ be changed without restarting apiserver.
The token file format is implemented in
`plugin/pkg/auth/authenticator/token/tokenfile/...`
and is a csv file with a minimum of 3 columns: token, user name, user uid, followed by
optional group names.
optional group names. Note, if you have more than one group the column must be double quoted e.g.
```
csv
token,user,uid,"group1,group2,group3"
```
When using token authentication from an http client the apiserver expects an
`Authorization`
header with a value of
`Bearer SOMETOKEN`
.
...
...
plugin/pkg/auth/authenticator/token/tokenfile/tokenfile.go
View file @
5f7fea2f
...
...
@@ -21,6 +21,7 @@ import (
"fmt"
"io"
"os"
"strings"
"k8s.io/kubernetes/pkg/auth/user"
)
...
...
@@ -58,8 +59,8 @@ func NewCSV(path string) (*TokenAuthenticator, error) {
}
tokens
[
record
[
0
]]
=
obj
if
len
(
record
)
>
3
{
obj
.
Groups
=
record
[
3
:
]
if
len
(
record
)
>
=
4
{
obj
.
Groups
=
strings
.
Split
(
record
[
3
],
","
)
}
}
...
...
plugin/pkg/auth/authenticator/token/tokenfile/tokenfile_test.go
View file @
5f7fea2f
...
...
@@ -29,8 +29,11 @@ func TestTokenFile(t *testing.T) {
auth
,
err
:=
newWithContents
(
t
,
`
token1,user1,uid1
token2,user2,uid2
token3,user3,uid3,group1,group2
token4,user4,uid4,group2
token3,user3,uid3,"group1,group2"
token4,user4,uid4,"group2"
token5,user5,uid5,group5
token6,user6,uid6,group5,otherdata
token7,user7,uid7,"group1,group2",otherdata
`
)
if
err
!=
nil
{
t
.
Fatalf
(
"unable to read tokenfile: %v"
,
err
)
...
...
@@ -64,9 +67,21 @@ token4,user4,uid4,group2
},
{
Token
:
"token5"
,
User
:
&
user
.
DefaultInfo
{
Name
:
"user5"
,
UID
:
"uid5"
,
Groups
:
[]
string
{
"group5"
}},
Ok
:
true
,
},
{
Token
:
"token6"
,
User
:
&
user
.
DefaultInfo
{
Name
:
"user6"
,
UID
:
"uid6"
,
Groups
:
[]
string
{
"group5"
}},
Ok
:
true
,
},
{
Token
:
"token7"
,
User
:
&
user
.
DefaultInfo
{
Name
:
"user7"
,
UID
:
"uid7"
,
Groups
:
[]
string
{
"group1"
,
"group2"
}},
Ok
:
true
,
},
{
Token
:
"token8"
,
},
}
for
i
,
testCase
:=
range
testCases
{
...
...
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