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
02578a7e
Commit
02578a7e
authored
Mar 28, 2016
by
deads2k
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add missing attributes to authorization interface
parent
e01feae7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
8 deletions
+33
-8
handlers.go
pkg/apiserver/handlers.go
+3
-8
handlers_test.go
pkg/apiserver/handlers_test.go
+5
-0
interfaces.go
pkg/auth/authorizer/interfaces.go
+25
-0
No files found.
pkg/apiserver/handlers.go
View file @
02578a7e
...
@@ -398,17 +398,12 @@ func (r *requestAttributeGetter) GetAttribs(req *http.Request) authorizer.Attrib
...
@@ -398,17 +398,12 @@ func (r *requestAttributeGetter) GetAttribs(req *http.Request) authorizer.Attrib
attribs
.
Path
=
requestInfo
.
Path
attribs
.
Path
=
requestInfo
.
Path
attribs
.
Verb
=
requestInfo
.
Verb
attribs
.
Verb
=
requestInfo
.
Verb
// If the request was for a resource in an API group, include that info
attribs
.
APIGroup
=
requestInfo
.
APIGroup
attribs
.
APIGroup
=
requestInfo
.
APIGroup
attribs
.
APIVersion
=
requestInfo
.
APIVersion
// If a path follows the conventions of the REST object store, then
// we can extract the resource. Otherwise, not.
attribs
.
Resource
=
requestInfo
.
Resource
attribs
.
Resource
=
requestInfo
.
Resource
attribs
.
Subresource
=
requestInfo
.
Subresource
// If the request specifies a namespace, then the namespace is filled in.
// Assumes there is no empty string namespace. Unspecified results
// in empty (does not understand defaulting rules.)
attribs
.
Namespace
=
requestInfo
.
Namespace
attribs
.
Namespace
=
requestInfo
.
Namespace
attribs
.
Name
=
requestInfo
.
Name
return
&
attribs
return
&
attribs
}
}
...
...
pkg/apiserver/handlers_test.go
View file @
02578a7e
...
@@ -284,6 +284,8 @@ func TestGetAttribs(t *testing.T) {
...
@@ -284,6 +284,8 @@ func TestGetAttribs(t *testing.T) {
Path
:
"/api/v1/nodes/mynode"
,
Path
:
"/api/v1/nodes/mynode"
,
ResourceRequest
:
true
,
ResourceRequest
:
true
,
Resource
:
"nodes"
,
Resource
:
"nodes"
,
APIVersion
:
"v1"
,
Name
:
"mynode"
,
},
},
},
},
"namespaced resource"
:
{
"namespaced resource"
:
{
...
@@ -295,6 +297,8 @@ func TestGetAttribs(t *testing.T) {
...
@@ -295,6 +297,8 @@ func TestGetAttribs(t *testing.T) {
ResourceRequest
:
true
,
ResourceRequest
:
true
,
Namespace
:
"myns"
,
Namespace
:
"myns"
,
Resource
:
"pods"
,
Resource
:
"pods"
,
APIVersion
:
"v1"
,
Name
:
"mypod"
,
},
},
},
},
"API group resource"
:
{
"API group resource"
:
{
...
@@ -305,6 +309,7 @@ func TestGetAttribs(t *testing.T) {
...
@@ -305,6 +309,7 @@ func TestGetAttribs(t *testing.T) {
Path
:
"/apis/extensions/v1beta1/namespaces/myns/jobs"
,
Path
:
"/apis/extensions/v1beta1/namespaces/myns/jobs"
,
ResourceRequest
:
true
,
ResourceRequest
:
true
,
APIGroup
:
extensions
.
GroupName
,
APIGroup
:
extensions
.
GroupName
,
APIVersion
:
"v1beta1"
,
Namespace
:
"myns"
,
Namespace
:
"myns"
,
Resource
:
"jobs"
,
Resource
:
"jobs"
,
},
},
...
...
pkg/auth/authorizer/interfaces.go
View file @
02578a7e
...
@@ -48,9 +48,19 @@ type Attributes interface {
...
@@ -48,9 +48,19 @@ type Attributes interface {
// The kind of object, if a request is for a REST object.
// The kind of object, if a request is for a REST object.
GetResource
()
string
GetResource
()
string
// GetSubresource returns the subresource being requested, if present
GetSubresource
()
string
// GetName returns the name of the object as parsed off the request. This will not be present for all request types, but
// will be present for: get, update, delete
GetName
()
string
// The group of the resource, if a request is for a REST object.
// The group of the resource, if a request is for a REST object.
GetAPIGroup
()
string
GetAPIGroup
()
string
// GetAPIVersion returns the version of the group requested, if a request is for a REST object.
GetAPIVersion
()
string
// IsResourceRequest returns true for requests to API resources, like /api/v1/nodes,
// IsResourceRequest returns true for requests to API resources, like /api/v1/nodes,
// and false for non-resource endpoints like /api, /healthz, and /swaggerapi
// and false for non-resource endpoints like /api, /healthz, and /swaggerapi
IsResourceRequest
()
bool
IsResourceRequest
()
bool
...
@@ -83,7 +93,10 @@ type AttributesRecord struct {
...
@@ -83,7 +93,10 @@ type AttributesRecord struct {
Verb
string
Verb
string
Namespace
string
Namespace
string
APIGroup
string
APIGroup
string
APIVersion
string
Resource
string
Resource
string
Subresource
string
Name
string
ResourceRequest
bool
ResourceRequest
bool
Path
string
Path
string
}
}
...
@@ -112,10 +125,22 @@ func (a AttributesRecord) GetResource() string {
...
@@ -112,10 +125,22 @@ func (a AttributesRecord) GetResource() string {
return
a
.
Resource
return
a
.
Resource
}
}
func
(
a
AttributesRecord
)
GetSubresource
()
string
{
return
a
.
Subresource
}
func
(
a
AttributesRecord
)
GetName
()
string
{
return
a
.
Name
}
func
(
a
AttributesRecord
)
GetAPIGroup
()
string
{
func
(
a
AttributesRecord
)
GetAPIGroup
()
string
{
return
a
.
APIGroup
return
a
.
APIGroup
}
}
func
(
a
AttributesRecord
)
GetAPIVersion
()
string
{
return
a
.
APIVersion
}
func
(
a
AttributesRecord
)
IsResourceRequest
()
bool
{
func
(
a
AttributesRecord
)
IsResourceRequest
()
bool
{
return
a
.
ResourceRequest
return
a
.
ResourceRequest
}
}
...
...
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