fix: add missing selector label (#26) Signed-off-by: Ashish Malik <b218008@iiit-bh.ac.in>
K8s-authz is authorization middleware for Kubernetes, which is based on Casbin.
go get github.com/casbin/k8s-authz
This middleware uses K8s validation admission webhook to check the policies defined by casbin, for every request related to the pods. The K8s API server needs to know when to send the incoming request to our admission controller. For this part, we have defined a validation webhook which would proxy the requests for the pods and perform policy verification on it. The user would be allowed to perform the operations on the pods, only if the casbin enforcer authorizes it. The enforcer checks the roles of the user defined in the policies. This middleware would be deployed on the k8s cluster.
Before proceeding, make sure to have the following-
./gen_cert.sh
docker build -t casbin/k8s_authz:0.1 .
Define the casbin policies in the model.conf and policy.csv. You can refer the docs to get to know more about the working of these policies.
Before deploying, you can change the ports in main.go and also in the validation webhook configuration file depending on your usage.
Deploy the validation controller and the webhook on k8s cluster by running:-
kubectl apply -f deployment.yaml
secret to place the certificates for security purposes.kubectl create secret generic casbin -n default \ --from-file=key.pem=certs/casbin-key.pem \ --from-file=cert.pem=certs/casbin-crt.pem
secret.Now the server should be running and ready to validate the requests for the operations on the pods.
You can check the official docs for more detailed explaination.
In case of any query, you can ask on our gitter channel.