Commit Graph

807 Commits (3215e8535ae8afcf850fbaac9df7ff9abe42f9e0)

Author SHA1 Message Date
deads2k 5080a575ad add anytoken authenticator 2016-09-29 14:14:06 -04:00
Kubernetes Submit Queue d187997c94 Merge pull request #32386 from liggitt/anonymous-authenticated-groups
Automatic merge from submit-queue

Allow anonymous API server access, decorate authenticated users with system:authenticated group

When writing authorization policy, it is often necessary to allow certain actions to any authenticated user. For example, creating a service or configmap, and granting read access to all users

It is also frequently necessary to allow actions to any unauthenticated user. For example, fetching discovery APIs might be part of an authentication process, and therefore need to be able to be read without access to authentication credentials.

This PR:
* Adds an option to allow anonymous requests to the secured API port. If enabled, requests to the secure port that are not rejected by other configured authentication methods are treated as anonymous requests, and given a username of `system:anonymous` and a group of `system:unauthenticated`. Note: this should only be used with an `--authorization-mode` other than `AlwaysAllow`
* Decorates user.Info returned from configured authenticators with the group `system:authenticated`.

This is related to defining a default set of roles and bindings for RBAC (https://github.com/kubernetes/features/issues/2). The bootstrap policy should allow all users (anonymous or authenticated) to request the discovery APIs.

```release-note
kube-apiserver learned the '--anonymous-auth' flag, which defaults to true. When enabled, requests to the secure port that are not rejected by other configured authentication methods are treated as anonymous requests, and given a username of 'system:anonymous' and a group of 'system:unauthenticated'. 

Authenticated users are decorated with a 'system:authenticated' group.

NOTE: anonymous access is enabled by default. If you rely on authentication alone to authorize access, change to use an authorization mode other than AlwaysAllow, or or set '--anonymous-auth=false'.
```

c.f. https://github.com/kubernetes/kubernetes/issues/29177#issuecomment-244191596
2016-09-29 10:47:49 -07:00
Dr. Stefan Schimanski 6c75e922f3 Decouple NewRequestInfoResolver from GenericApiServer instance 2016-09-28 18:51:34 +02:00
Dr. Stefan Schimanski 10cbaf7ce0 Store RequestInfo in Context
... in order to replace the manual RequestInfoResolver dependency injection
through out the code.
2016-09-28 18:51:34 +02:00
Dr. Stefan Schimanski 6dc2f6337b Separate apiserver handler filters 2016-09-27 09:57:59 +02:00
Dr. Stefan Schimanski a2f943e7c1 Move panic handler into genericapiserver 2016-09-27 09:52:50 +02:00
Kubernetes Submit Queue a845c92207 Merge pull request #33368 from sttts/sttts-prune-serviceerrorhandler
Automatic merge from submit-queue

Prune unused parameters and call only once

Two parameters of `InstallServiceErrorHandler` were not used. Pruning them allows us to move the service error handler installation for each api group to be moved into the constructor.
2016-09-26 22:29:52 -07:00
Jordan Liggitt 5599ca3be5
Decorate authenticated users with system:authenticated group 2016-09-26 17:19:00 -04:00
Jordan Liggitt 0c36c5e556
Add anonymous auth to the auth chain 2016-09-26 17:19:00 -04:00
Hongchao Deng 6f3ac807fd pass SelectionPredicate instead of Filter to storage layer 2016-09-26 09:47:19 -07:00
Kubernetes Submit Queue 9455b1de54 Merge pull request #33157 from YuPengZTE/devEG
Automatic merge from submit-queue

'eg.' should be 'e.g.'
2016-09-24 00:53:38 -07:00
Kubernetes Submit Queue 501f264717 Merge pull request #33337 from mbohlool/o2
Automatic merge from submit-queue

Fix API Installer to generate unique Operation IDs

OperationIDs generated by api_installer.go may not be unique and that causes long auto-generated function names in swagger generated clients. This is a step toward making those IDs unique.

Reference Issue kubernetes/features#53 and #13414
2016-09-23 14:06:40 -07:00
mbohlool d228cc34f3 Fix API Installer to generate unique Operation IDs 2016-09-23 11:42:50 -07:00
Dr. Stefan Schimanski acf0a5264a Prune unused parameters and call only once 2016-09-23 14:53:09 +02:00
Dr. Stefan Schimanski 87356c0623 Cleanup handler chain 2016-09-23 12:03:58 +02:00
Philibert Dugas b557acf987
Update for the PR feedback 2016-09-22 13:30:04 -04:00
Philibert Dugas 9c2705a5a2
Apiserver don't log stacktrace when proxying
Attempt at closing #32747,

With the `RequestInfoResolver` struct, it's possible to inspect the
request and get the `Verb`. In this case, the `proxy` value is what I
was looking for to avoid logging stacktraces.

I'm wrapping the `.Log()` call with an `if` statement to remove all
stacktrace logging when we proxied through the apiserver

Another approach would have been to add another kind of
`StacktracePred` in the `httplog` package. I found this path to be
trickier to code as it's currently only accepting int values.
2016-09-22 12:08:06 -04:00
Kubernetes Submit Queue f230e6c7bc Merge pull request #33007 from smarterclayton/fix_versioned_event
Automatic merge from submit-queue

Correct versioned.Event output in Swagger

Fixes #24240

```release-note
The value of the `versioned.Event` object (returned by watch APIs) in the Swagger 1.2 schemas has been updated from `*versioned.Event` which was not expected by many client tools. The new value is consistent with other structs returned by the API.
```
2016-09-22 07:03:28 -07:00
Kubernetes Submit Queue aa935bb8a4 Merge pull request #33170 from soltysh/audit_improvements
Automatic merge from submit-queue

Remove closing audit log file and add error check when writing to audit

This picks the order fix from #33164. Additionally I've removed entirely closing the log file, since it didn't make sense where it was. I've also added error checks when actually writing to audit logs.

@sttts ptal

**1.4 justification:**

Risk: the code only runs if auditing is enabled with an apiserver flag. So the risk is low.
Rollback: nothing should depend on this
Cost: the auditing feature is broken because the impersonation filter is applied before and you might not see the proper user when using `--as` flag. Additionally no errors are logged if writing to audit fails.
2016-09-22 05:06:33 -07:00
Kubernetes Submit Queue 5af04d1dd1 Merge pull request #32876 from errordeveloper/more-cert-utils
Automatic merge from submit-queue

Refactor cert utils into one pkg, add funcs from bootkube for kubeadm to use

**What this PR does / why we need it**:

We have ended-up with rather incomplete and fragmented collection of utils for handling certificates. It may be worse to consider using `cfssl` for doing all of these things, but for now there is some functionality that we need in `kubeadm` that we can borrow from bootkube. It makes sense to move the utils from bookube into core, as discussed in #31221.

**Special notes for your reviewer**: I've taken the opportunity to review names of existing funcs and tried to make some improvements in that area (with help from @peterbourgon).

**Release note**:

```release-note
NONE
```
2016-09-22 01:29:46 -07:00
Maciej Szulik 5873c2679c Remove closing audit log file and add error check when writing to audit 2016-09-21 15:23:38 +02:00
YuPengZTE 5865a31e77 'eg.' should be 'e.g.'
Signed-off-by: YuPengZTE <yu.peng36@zte.com.cn>
2016-09-21 14:28:22 +08:00
Davanum Srinivas 25d4a70827 Allow secure access to apiserver from Admission Controllers
* Allow options.InsecurePort to be set to 0 to switch off insecure access
* In NewSelfClient, Set the TLSClientConfig to the cert and key files
  if InsecurePort is switched off
* Mint a bearer token that allows the client(s) created in NewSelfClient
  to talk to the api server
* Add a new authenticator that checks for this specific bearer token

Fixes #13598
2016-09-20 10:42:21 -04:00
Clayton Coleman c0b9528365
Pass a value for versioned.Event, not a pointer 2016-09-19 18:33:45 -04:00
Ilya Dmitrichenko 386fae4592
Refactor utils that deal with certs
- merge `pkg/util/{crypto,certificates}`
- add funcs from `github.com/kubernetes-incubator/bootkube/pkg/tlsutil`
- ensure naming of funcs is fairly consistent
2016-09-19 09:03:42 +01:00
Kubernetes Submit Queue 12d916750e Merge pull request #32387 from sttts/sttts-handler-cleanup
Automatic merge from submit-queue

Cleanup non-rest apiserver handlers

- rename MuxHelper -> PathRecorderMux
- move non-rest handlers into routes packages within genericapiserver and `pkg/routes` (those from master)
- move ui and logs handlers out of genericapiserver (they are
  not generic)
- make version handler configurable (`config.EnableVersion`)
2016-09-16 08:58:06 -07:00
Kubernetes Submit Queue a39cee990c Merge pull request #32751 from caesarxuchao/specific-error-rolling-update
Automatic merge from submit-queue

Specific error message on failed rolling update issued by older kubectl against 1.4 master

Fix #32706

`kubernetes-e2e-gke-1.4-1.3-kubectl-skew` (1.3 kubectl and 1.4 master) test suite failed with:
```
k8s.io] Kubectl client [k8s.io] Kubectl rolling-update should support rolling-update to same image [Conformance]
...
Error from server: object is being deleted: replicationcontrollers "e2e-test-nginx-rc" already exists error: exit status 1 not to have occurred
```

It's because the old RC had an orphanFinalizer, so it is not deleted from the key-value store immediately. In turn, the creation of the new RC of the same name failed. 

In this failure, the RC and pods are updated, it's just that the RC is of different name, i.e., original name + a hash generated based on podTemplate. The error is confusing to user, but not that bad. So this PR just prints a warning message to instruct users how to work around.

1.4 kubectl rolling-update uses different logic so it's working.

@lavalamp @gmarek @janetkuo @pwittrock 

cc @liggitt for the ctx changes.
2016-09-15 21:41:56 -07:00
Chao Xu c4ea205aeb print instruction in case of failed kubectl 1.3 rolling-update against 1.4 cluster 2016-09-15 17:20:39 -07:00
Adi Ofry b97b685b96 prevent printing of stack trace when proxying 304 requests in api gateway 2016-09-15 14:52:04 +03:00
Dr. Stefan Schimanski 7f78661d0b Cleanup non-rest apiserver handlers
- rename MuxHelper -> PathRecorderMux
- move non-rest handlers into routes packages within genericapiserver and
  `pkg/routes` (those from master)
- move ui and logs handlers out of genericapiserver (they are
  not generic)
- make version handler configurable (`config.EnableVersion`)
2016-09-15 13:22:45 +02:00
Johnny Bieren df6299d110 Fixed edited regex in audit_test unit test
Signed-off-by: Johnny Bieren <jbieren@redhat.com>
2016-09-14 14:08:41 -04:00
Johnny Bieren 6194bfb81d Fix audit_test regex for iso8601 timestamps
Signed-off-by: Johnny Bieren <jbieren@redhat.com>
2016-09-13 15:03:49 -04:00
mbohlool 54fee8c253 Improvements on OpenAPI spec generation:
- Generating models using go2idl library (no reflection anymore)
- Remove dependencies on go-restful/swagger
- Generate one swagger.json file for each web-service
- Bugfix: fixed a bug in trie implementation
2016-09-12 18:47:03 -07:00
Maciej Szulik b19fcdce29 Fix namespace in audit logs 2016-09-09 11:43:28 +02:00
Daniel Smith 1a23f5a79f Log useful information on 500's
* include error message in error (!!)
* add test verifying error message is correct for service ip allocation
2016-08-31 13:46:40 -07:00
jianhuiz 494129b089 add generated files 2016-08-22 23:00:23 -07:00
deads2k 432e6ecdae allow impersonating user.Info.Extra 2016-08-22 07:43:52 -04:00
Kubernetes Submit Queue 5b5a4145da Merge pull request #30821 from ardnaxelarak/21076_change_isEmpty_to_Empty
Automatic merge from submit-queue

Rename IsEmpty to Empty

addresses #21076
2016-08-22 00:54:28 -07:00
Kubernetes Submit Queue 7979801e54 Merge pull request #28860 from ericchiang/separate-apiserver-authz-options
Automatic merge from submit-queue

pkg/genericapiserver/options: don't import pkg/apiserver

Refactor the authorization options for the API server so
pkg/apiserver isn't directly imported by the options package.

Closes #28544

cc @smarterclayton

@madhusudancs, @nikhiljindal I've updated `federation/cmd/federation-apiserver/app/server.go` to include the RBAC options with this change. I don't know if this was intentionally left out in the first place but would like your feedback.
2016-08-21 09:49:14 -07:00
Kubernetes Submit Queue 7272cd09e3 Merge pull request #26541 from sttts/sttts-kubectl-exec-rc
Automatic merge from submit-queue

Return container command exit codes in kubectl run/exec

Fixes https://github.com/kubernetes/kubernetes/issues/26424
Based on https://github.com/kubernetes/kubernetes/pull/25273.

TODO:
- [x] add e2e tests
- [x] investigate `kubectl run` exit code for `--restart=Never` (compare issue #24533 and PR #25253)
- [x] document exit codes
2016-08-21 00:44:55 -07:00
Kubernetes Submit Queue d07348dd84 Merge pull request #30803 from deads2k/impersonate-groups
Automatic merge from submit-queue

allow group impersonation

Adds an "Impersonate-Group" header that can be used to specify exactly which groups to use on an impersonation request.  

This also restructures the code to make it easier to add the scopes header next.  This closely parallels the "Impersonate-User" header, so I figured I'd start easy.

@kubernetes/sig-auth 
@ericchiang are you comfortable reviewing?
2016-08-20 10:10:32 -07:00
bindata-mockuser ce7f003f57 Add protocol versions to pkg/util/wsstream 2016-08-20 15:58:10 +02:00
Kubernetes Submit Queue 78cb692327 Merge pull request #30736 from liggitt/close-websocket-watch
Automatic merge from submit-queue

Close websocket watch when client closes

fixes https://github.com/kubernetes/kubernetes/issues/30735
2016-08-19 15:47:47 -07:00
Kara Alexandra d12a66a422 Rename IsEmpty to Empty
Signed-off-by: Kara Alexandra <kalexandra@us.ibm.com>
2016-08-19 14:19:19 -07:00
Eric Chiang b4eaf625a0 pkg/genericapiserver/options: don't import pkg/apiserver
Refactor the authorization options for the API server so
pkg/apiserver isn't directly imported by the options package.
2016-08-18 13:01:50 -07:00
Clayton Coleman 12a5eeea17
Introduce GroupVersioner for capturing desired target version
Convert single GV and lists of GVs into an interface that can handle
more complex scenarios (everything internal, nothing supported). Pass
the interface down into conversion.
2016-08-18 14:45:00 -04:00
deads2k fb56512ea2 allow group impersonation 2016-08-18 08:02:44 -04:00
Jordan Liggitt fdb7c93a97
Close websocket watch when client closes 2016-08-17 15:20:05 -04:00
PingWang 8760ae697e implement restful for InstallLogsSupport
Signed-off-by: PingWang <wang.ping5@zte.com.cn>

add ws.doc

Signed-off-by: PingWang <wang.ping5@zte.com.cn>

run hack/update-swagger-spec.sh

Signed-off-by: PingWang <wang.ping5@zte.com.cn>

update update-swagger-spec.sh

Signed-off-by: PingWang <wang.ping5@zte.com.cn>

update apiserver_test.go

Signed-off-by: PingWang <wang.ping5@zte.com.cn>

update comment

Signed-off-by: PingWang <wang.ping5@zte.com.cn>
2016-08-16 09:09:02 +08:00
Kubernetes Submit Queue 3a71e8c9f4 Merge pull request #30457 from ericchiang/reorder-autenticators
Automatic merge from submit-queue

pkg/apiserver/authenticator: reorder oidc plugin to auth after service accounts

Both plugins verify JWTs, but the OpenID Connect plugin performs
much worse when faced with cache misses. Reorder the plugins so
the service account plugin tries to authenticate a bearer token
first.

I had a fun time with this by writing an OpenID Connect provider that stores its data in third party resources. When it's running in the cluster it uses a service account and caused some interesting behavior when the keys expired.

Our OpenID Connect plugin needs a more sophisticated caching model to avoid continuously re-requesting keys when seeing a lot of tokens it doesn't recognize. However, I feel this reordering is generally useful since service accounts will be more common than OpenID Connect tokens.

cc @kubernetes/sig-auth
2016-08-15 09:39:02 -07:00