Skip to content

Commit

Permalink
Merge pull request #2 from StatCan/feat-jupyter-export
Browse files Browse the repository at this point in the history
feat: block jupyter download using export as
  • Loading branch information
blairdrummond authored Aug 16, 2021
2 parents f0aa6ad + 40575dd commit 2a38109
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions deploy/deploy.yaml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ spec:
- name: k8scc01covidacr-registry-connection
containers:
- name: notebook-auth-policy-checker
imagePullPolicy: IfNotPresent
image: k8scc01covidacr.azurecr.io/prob-notebook-controller:${IMAGE_SHA}
resources:
limits:
Expand Down
6 changes: 6 additions & 0 deletions kind/gatekeeper/constraint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ spec:
kinds:
- apiGroups: [""]
kinds: ["Pod"]
labelSelector:
matchExpressions:
- key: data.statcan.gc.ca/classification
operator: In
values:
- protected-b
1 change: 0 additions & 1 deletion kind/gatekeeper/constraintTemplate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ spec:
rego: |
package probauth
violation[{"msg": msg}] {
not input.review.object.metadata.labels["data.statcan.gc.ca/classification"] == "unclassified"
input.review.object.kind == "Pod"
ns := input.review.object.metadata.namespace
namePod := input.review.object.metadata.name
Expand Down
2 changes: 1 addition & 1 deletion kind/jupyter/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ prob: true
noprob: true
image:
image: jupyter/minimal-notebook
imagePullPolicy: Always
imagePullPolicy: IfNotPresent
command: ["jupyter"]
args:
- "notebook"
Expand Down
11 changes: 11 additions & 0 deletions pkg/controller/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,23 +88,34 @@ func (c *Controller) generateAuthorizationPolicy(notebook *v1.Notebook)(*istiose
{
To: []*v1beta1.Rule_To{
{
//Rstudio upload
Operation: &v1beta1.Operation{
Methods: []string{"POST"},
Paths: []string{fmt.Sprintf("/notebook/%s/%s/rstudio/upload", notebook.Namespace, notebook.Name)},
},
},
{
//Rstudio download
Operation: &v1beta1.Operation{
Methods: []string{"GET"},
Paths: []string{fmt.Sprintf("/notebook/%s/%s/rstudio/export*", notebook.Namespace, notebook.Name)},
},
},
{
//Jupyter download
Operation: &v1beta1.Operation{
Methods: []string{"GET"},
Paths: []string{fmt.Sprintf("/notebook/%s/%s/files*", notebook.Namespace, notebook.Name)},
},
},
{
//Jupyter download - convert as
Operation: &v1beta1.Operation{
Methods: []string{"GET"},
Paths: []string{fmt.Sprintf("/notebook/%s/%s/nbconvert*", notebook.Namespace, notebook.Name)},
},
},
// VS Code download - handled by the image
},
},
},
Expand Down

0 comments on commit 2a38109

Please sign in to comment.