Get user from request and put in authz attribs.

Added integration tests for user-based auth.
This commit is contained in:
Eric Tune
2014-11-03 07:57:08 -08:00
parent 6c2212b37a
commit 3045035512
5 changed files with 240 additions and 11 deletions

View File

@@ -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()
}

View File

@@ -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)
}