Skip to content

Commit

Permalink
Merge pull request #45 from s-urbaniak/bump-v0.9.0
Browse files Browse the repository at this point in the history
Bump v0.9.0
  • Loading branch information
openshift-merge-robot committed May 7, 2021
2 parents 8d11a8f + a4c25ef commit 813c3da
Show file tree
Hide file tree
Showing 68 changed files with 1,967 additions and 399 deletions.
17 changes: 7 additions & 10 deletions .github/workflows/build.yml
Expand Up @@ -64,6 +64,10 @@ jobs:
run: |
VERSION=local make container
kind load docker-image ${QUAY_PATH}:local
until docker exec $(kind get nodes) crictl images | grep "${QUAY_PATH}"; do
echo "no kube-rbac-proxy image"
sleep 1
done
make test-e2e
publish:
runs-on: ubuntu-latest
Expand All @@ -74,22 +78,15 @@ jobs:
- generate
- build
- unit-tests
# Disable e2e-tests job requirement to avoid having flakes impacting
# image publication.
# This requirement should be uncommented once the flaky tests are fixed.
# - e2e-tests
- e2e-tests
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Login to Quay.io
uses: docker/login-actions@v1
uses: docker/login-action@v1
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Build images and push
run: |
TAG="$(git rev-parse --abbrev-ref HEAD | tr / -)-$(date +%Y-%m-%d)-$(git rev-parse --short HEAD)"
ID="$(docker images ${QUAY_PATH}:local --format "{{.ID}}")"
docker tag $ID ${QUAY_PATH}:$TAG
docker push ${QUAY_PATH}:$TAG
run: ./scripts/publish.sh
42 changes: 0 additions & 42 deletions .travis.yml

This file was deleted.

6 changes: 6 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,9 @@
## 0.9.0 / 2021-04-27

* [FEATURE] Support rewrites using HTTP headers in addition to query parameters. #104
* [FEATURE] Support pass-through of client certificates. #113
* [FEATURE] Support TLS 1.3. #120

## 0.8.0 / 2020-11-03

* [FEATURE] Add ability with the new `--ignore-paths` flag to define paths for which kube-rbac-proxy will proxy without performing authn/authz. This cannot be used with `--allow-paths`. #91
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Expand Up @@ -68,11 +68,11 @@ manifest-push: manifest-tool
push: crossbuild manifest-tool $(addprefix push-,$(ALL_ARCH)) manifest-push

curl-container:
docker build -f ./examples/example-client/Dockerfile -t quay.io/brancz/krp-curl:v0.0.1 .
docker build -f ./examples/example-client/Dockerfile -t quay.io/brancz/krp-curl:v0.0.2 .

run-curl-container:
@echo 'Example: curl -v -s -k -H "Authorization: Bearer `cat /var/run/secrets/kubernetes.io/serviceaccount/token`" https://kube-rbac-proxy.default.svc:8443/metrics'
kubectl run -i -t krp-curl --image=quay.io/brancz/krp-curl:v0.0.1 --restart=Never --command -- /bin/sh
kubectl run -i -t krp-curl --image=quay.io/brancz/krp-curl:v0.0.2 --restart=Never --command -- /bin/sh

grpcc-container:
docker build -f ./examples/grpcc/Dockerfile -t mumoshu/grpcc:v0.0.1 .
Expand Down
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
v0.8.0
v0.9.0
5 changes: 5 additions & 0 deletions examples/example-client-urlquery/Dockerfile
@@ -0,0 +1,5 @@
FROM alpine:3.7

RUN apk add --no-cache curl

CMD curl -v -s -k -H "Authorization: Bearer `cat /var/run/secrets/kubernetes.io/serviceaccount/token`" https://kube-rbac-proxy.default.svc:8443/metrics?namespace=default
2 changes: 1 addition & 1 deletion examples/example-client/Dockerfile
@@ -1,4 +1,4 @@
FROM alpine:3.7
FROM alpine:3.12

RUN apk add --no-cache curl

Expand Down
6 changes: 3 additions & 3 deletions examples/non-resource-url-token-request/README.md
Expand Up @@ -78,7 +78,7 @@ spec:
serviceAccountName: kube-rbac-proxy
containers:
- name: kube-rbac-proxy
image: quay.io/brancz/kube-rbac-proxy:v0.8.0
image: quay.io/brancz/kube-rbac-proxy:v0.9.0
args:
- "--secure-listen-address=0.0.0.0:8443"
- "--upstream=http://127.0.0.1:8081/"
Expand Down Expand Up @@ -144,7 +144,7 @@ spec:
restartPolicy: Never
containers:
- name: krp-curl
image: quay.io/brancz/krp-curl:v0.0.1
image: quay.io/brancz/krp-curl:v0.0.2
command:
- /bin/sh
- -c
Expand Down Expand Up @@ -237,7 +237,7 @@ spec:
restartPolicy: Never
containers:
- name: krp-curl
image: quay.io/brancz/krp-curl:v0.0.1
image: quay.io/brancz/krp-curl:v0.0.2
```

Then the log output should look something along the lines of:
Expand Down
2 changes: 1 addition & 1 deletion examples/non-resource-url-token-request/client.yaml
Expand Up @@ -10,7 +10,7 @@ spec:
restartPolicy: Never
containers:
- name: krp-curl
image: quay.io/brancz/krp-curl:v0.0.1
image: quay.io/brancz/krp-curl:v0.0.2
command:
- /bin/sh
- -c
Expand Down
2 changes: 1 addition & 1 deletion examples/non-resource-url-token-request/deployment.yaml
Expand Up @@ -63,7 +63,7 @@ spec:
serviceAccountName: kube-rbac-proxy
containers:
- name: kube-rbac-proxy
image: quay.io/brancz/kube-rbac-proxy:v0.8.0
image: quay.io/brancz/kube-rbac-proxy:v0.9.0
args:
- "--secure-listen-address=0.0.0.0:8443"
- "--upstream=http://127.0.0.1:8081/"
Expand Down
2 changes: 1 addition & 1 deletion examples/non-resource-url-token-request/wrong-client.yaml
Expand Up @@ -10,4 +10,4 @@ spec:
restartPolicy: Never
containers:
- name: krp-curl
image: quay.io/brancz/krp-curl:v0.0.1
image: quay.io/brancz/krp-curl:v0.0.2
4 changes: 2 additions & 2 deletions examples/non-resource-url/README.md
Expand Up @@ -78,7 +78,7 @@ spec:
serviceAccountName: kube-rbac-proxy
containers:
- name: kube-rbac-proxy
image: quay.io/brancz/kube-rbac-proxy:v0.8.0
image: quay.io/brancz/kube-rbac-proxy:v0.9.0
args:
- "--secure-listen-address=0.0.0.0:8443"
- "--upstream=http://127.0.0.1:8081/"
Expand Down Expand Up @@ -142,7 +142,7 @@ spec:
spec:
containers:
- name: krp-curl
image: quay.io/brancz/krp-curl:v0.0.1
image: quay.io/brancz/krp-curl:v0.0.2
restartPolicy: Never
backoffLimit: 4
```
Expand Down
2 changes: 1 addition & 1 deletion examples/non-resource-url/client.yaml
Expand Up @@ -9,6 +9,6 @@ spec:
spec:
containers:
- name: krp-curl
image: quay.io/brancz/krp-curl:v0.0.1
image: quay.io/brancz/krp-curl:v0.0.2
restartPolicy: Never
backoffLimit: 4
2 changes: 1 addition & 1 deletion examples/non-resource-url/deployment.yaml
Expand Up @@ -60,7 +60,7 @@ spec:
serviceAccountName: kube-rbac-proxy
containers:
- name: kube-rbac-proxy
image: quay.io/brancz/kube-rbac-proxy:v0.8.0
image: quay.io/brancz/kube-rbac-proxy:v0.9.0
args:
- "--secure-listen-address=0.0.0.0:8443"
- "--upstream=http://127.0.0.1:8081/"
Expand Down
2 changes: 1 addition & 1 deletion examples/non-resource-url/non-resource-url/README.md
Expand Up @@ -142,7 +142,7 @@ spec:
spec:
containers:
- name: krp-curl
image: quay.io/brancz/krp-curl:v0.0.1
image: quay.io/brancz/krp-curl:v0.0.2
restartPolicy: Never
backoffLimit: 4
```
Expand Down
2 changes: 1 addition & 1 deletion examples/non-resource-url/non-resource-url/client.yaml
Expand Up @@ -9,6 +9,6 @@ spec:
spec:
containers:
- name: krp-curl
image: quay.io/brancz/krp-curl:v0.0.1
image: quay.io/brancz/krp-curl:v0.0.2
restartPolicy: Never
backoffLimit: 4
2 changes: 1 addition & 1 deletion examples/oidc/deployment.yaml
Expand Up @@ -63,7 +63,7 @@ spec:
serviceAccountName: kube-rbac-proxy
containers:
- name: kube-rbac-proxy
image: quay.io/brancz/kube-rbac-proxy:v0.8.0
image: quay.io/brancz/kube-rbac-proxy:v0.9.0
args:
- "--insecure-listen-address=0.0.0.0:8444"
- "--upstream=http://127.0.0.1:8081/"
Expand Down
4 changes: 2 additions & 2 deletions examples/resource-attributes/README.md
Expand Up @@ -92,7 +92,7 @@ spec:
serviceAccountName: kube-rbac-proxy
containers:
- name: kube-rbac-proxy
image: quay.io/brancz/kube-rbac-proxy:v0.8.0
image: quay.io/brancz/kube-rbac-proxy:v0.9.0
args:
- "--secure-listen-address=0.0.0.0:8443"
- "--upstream=http://127.0.0.1:8081/"
Expand Down Expand Up @@ -165,7 +165,7 @@ spec:
spec:
containers:
- name: krp-curl
image: quay.io/brancz/krp-curl:v0.0.1
image: quay.io/brancz/krp-curl:v0.0.2
restartPolicy: Never
backoffLimit: 4
```
Expand Down
2 changes: 1 addition & 1 deletion examples/resource-attributes/client.yaml
Expand Up @@ -9,6 +9,6 @@ spec:
spec:
containers:
- name: krp-curl
image: quay.io/brancz/krp-curl:v0.0.1
image: quay.io/brancz/krp-curl:v0.0.2
restartPolicy: Never
backoffLimit: 4
2 changes: 1 addition & 1 deletion examples/resource-attributes/deployment.yaml
Expand Up @@ -74,7 +74,7 @@ spec:
serviceAccountName: kube-rbac-proxy
containers:
- name: kube-rbac-proxy
image: quay.io/brancz/kube-rbac-proxy:v0.8.0
image: quay.io/brancz/kube-rbac-proxy:v0.9.0
args:
- "--secure-listen-address=0.0.0.0:8443"
- "--upstream=http://127.0.0.1:8081/"
Expand Down
8 changes: 4 additions & 4 deletions examples/rewrites/README.md
Expand Up @@ -2,9 +2,9 @@

> Note to try this out with minikube, make sure you enable RBAC correctly as explained [here](../minikube-rbac).
RBAC differentiates in two types, that need to be authorized, resources and non-resoruces. A resource request authorization, could for example be, that a requesting entity needs to be authorized to perform the `get` action on a particular Kubernetes Deployment.
RBAC differentiates in two types, that need to be authorized, resources and non-resources. A resource request authorization, could for example be, that a requesting entity needs to be authorized to perform the `get` action on a particular Kubernetes Deployment.

Take the following example. We want to deploy a [prometheus-example-app](https://github.com/brancz/prometheus-example-app), and protect it with the kube-rbac-proxy. In this example we require a requesting entity to be allowed to call the `proxy` subresource on a Kubernetes Service called `kube-rbac-proxy`. This is configured in the file passed to the kube-rbac-proxy with the `--config-file` flag. Additionally the `--upstream` flag has to be set to configure the application that should be proxied to on successful authentication as well as authorization.
Take the following example. We want to deploy a [prometheus-example-app](https://github.com/brancz/prometheus-example-app), and protect it with the kube-rbac-proxy. In this example we require a requesting entity to be allowed to call the `metrics` subresource on a Kubernetes Namespace, the name of which is passed by the HTTP URL query parameter `namespace`. This is configured in the file passed to the kube-rbac-proxy with the `--config-file` flag. Additionally the `--upstream` flag has to be set to configure the application that should be proxied to on successful authentication as well as authorization.

The kube-rbac-proxy itself also requires RBAC access, in order to perform TokenReviews as well as SubjectAccessReviews. These are the APIs available from the Kubernetes API to authenticate and then validate the authorization of an entity.

Expand Down Expand Up @@ -94,7 +94,7 @@ spec:
serviceAccountName: kube-rbac-proxy
containers:
- name: kube-rbac-proxy
image: quay.io/brancz/kube-rbac-proxy:v0.8.0
image: quay.io/brancz/kube-rbac-proxy:v0.9.0
args:
- "--secure-listen-address=0.0.0.0:8443"
- "--upstream=http://127.0.0.1:8081/"
Expand All @@ -121,7 +121,7 @@ spec:

Once the prometheus-example-app is up and running, we can test it. In order to test it, we deploy a Job, that performs a `curl` against the above deployment. Because it has the correct RBAC roles, the request will succeed.

The Dockerfile of this container can be found [here](../example-client/Dockerfile).
The Dockerfile of this container can be found [here](../example-client-urlquery/Dockerfile).

```bash
$ kubectl create -f client-rbac.yaml
Expand Down
2 changes: 1 addition & 1 deletion examples/rewrites/deployment.yaml
Expand Up @@ -76,7 +76,7 @@ spec:
serviceAccountName: kube-rbac-proxy
containers:
- name: kube-rbac-proxy
image: quay.io/brancz/kube-rbac-proxy:v0.8.0
image: quay.io/brancz/kube-rbac-proxy:v0.9.0
args:
- "--secure-listen-address=0.0.0.0:8443"
- "--upstream=http://127.0.0.1:8081/"
Expand Down
1 change: 1 addition & 0 deletions go.mod
Expand Up @@ -4,6 +4,7 @@ go 1.13

require (
github.com/ghodss/yaml v1.0.0
github.com/google/go-cmp v0.5.4
github.com/oklog/run v1.0.0
github.com/spf13/pflag v1.0.5
golang.org/x/net v0.0.0-20200707034311-ab3426394381
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Expand Up @@ -144,6 +144,8 @@ github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M=
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/gofuzz v1.1.0 h1:Hsa8mG0dQ46ij8Sl2AYJDUv1oA9/d6Vk+3LG99Oe02g=
Expand Down
17 changes: 2 additions & 15 deletions main.go
Expand Up @@ -20,7 +20,6 @@ import (
"context"
"crypto/tls"
"flag"
"fmt"
"io/ioutil"
"net"
"net/http"
Expand Down Expand Up @@ -78,19 +77,6 @@ type configfile struct {
AuthorizationConfig *authz.Config `json:"authorization,omitempty"`
}

var versions = map[string]uint16{
"VersionTLS10": tls.VersionTLS10,
"VersionTLS11": tls.VersionTLS11,
"VersionTLS12": tls.VersionTLS12,
}

func tlsVersion(versionName string) (uint16, error) {
if version, ok := versions[versionName]; ok {
return version, nil
}
return 0, fmt.Errorf("unknown tls version %q", versionName)
}

func main() {
cfg := config{
auth: proxy.Config{
Expand Down Expand Up @@ -298,7 +284,7 @@ func main() {
})
}

version, err := tlsVersion(cfg.tls.minVersion)
version, err := k8sapiflag.TLSVersion(cfg.tls.minVersion)
if err != nil {
klog.Fatalf("TLS version invalid: %v", err)
}
Expand All @@ -310,6 +296,7 @@ func main() {

srv.TLSConfig.CipherSuites = cipherSuiteIDs
srv.TLSConfig.MinVersion = version
srv.TLSConfig.ClientAuth = tls.RequestClientCert

if err := http2.ConfigureServer(srv, nil); err != nil {
klog.Fatalf("failed to configure http2 server: %v", err)
Expand Down
7 changes: 7 additions & 0 deletions pkg/authz/auth.go
Expand Up @@ -36,6 +36,7 @@ type Config struct {
// rewritten on a given request.
type SubjectAccessReviewRewrites struct {
ByQueryParameter *QueryParameterRewriteConfig `json:"byQueryParameter,omitempty"`
ByHTTPHeader *HTTPHeaderRewriteConfig `json:"byHttpHeader,omitempty"`
}

// QueryParameterRewriteConfig describes which HTTP URL query parameter is to
Expand All @@ -44,6 +45,12 @@ type QueryParameterRewriteConfig struct {
Name string `json:"name,omitempty"`
}

// HTTPHeaderRewriteConfig describes which HTTP header is to
// be used to rewrite a SubjectAccessReview on a given request.
type HTTPHeaderRewriteConfig struct {
Name string `json:"name,omitempty"`
}

// ResourceAttributes describes attributes available for resource request authorization
type ResourceAttributes struct {
Namespace string `json:"namespace,omitempty"`
Expand Down

0 comments on commit 813c3da

Please sign in to comment.