Get user from request and put in authz attribs.
Added integration tests for user-based auth.
This commit is contained in:
@@ -16,10 +16,14 @@ limitations under the License.
|
||||
|
||||
package authorizer
|
||||
|
||||
import (
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/auth/user"
|
||||
)
|
||||
|
||||
// Attributes is an interface used by an Authorizer to get information about a request
|
||||
// that is used to make an authorization decision.
|
||||
type Attributes interface {
|
||||
// TODO: add attribute getter functions, e.g. GetUserName(), per #1430.
|
||||
GetUserName() string
|
||||
}
|
||||
|
||||
// Authorizer makes an authorization decision based on information gained by making
|
||||
@@ -28,3 +32,12 @@ type Attributes interface {
|
||||
type Authorizer interface {
|
||||
Authorize(a Attributes) (err error)
|
||||
}
|
||||
|
||||
// AttributesRecord implements Attributes interface.
|
||||
type AttributesRecord struct {
|
||||
User user.Info
|
||||
}
|
||||
|
||||
func (a *AttributesRecord) GetUserName() string {
|
||||
return a.User.GetName()
|
||||
}
|
||||
|
@@ -28,6 +28,7 @@ import (
|
||||
// RequestContext is the interface used to associate a user with an http Request.
|
||||
type RequestContext interface {
|
||||
Set(*http.Request, user.Info)
|
||||
Get(req *http.Request) (user.Info, bool)
|
||||
Remove(*http.Request)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user