Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent proxy from starting if the SA does not match #61

Closed
enj opened this issue Mar 1, 2018 · 6 comments
Closed

Prevent proxy from starting if the SA does not match #61

enj opened this issue Mar 1, 2018 · 6 comments
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.

Comments

@enj
Copy link

enj commented Mar 1, 2018

We get the SA name as user input, and process it here:

// all OpenShift service accounts are OAuth clients, use this if we have it
if len(serviceAccount) > 0 {
if data, err := ioutil.ReadFile("/var/run/secrets/kubernetes.io/serviceaccount/namespace"); err == nil && len(data) > 0 {
defaults.ClientID = fmt.Sprintf("system:serviceaccount:%s:%s", strings.TrimSpace(string(data)), serviceAccount)
log.Printf("Defaulting client-id to %s", defaults.ClientID)
}
tokenPath := "/var/run/secrets/kubernetes.io/serviceaccount/token"
if data, err := ioutil.ReadFile(tokenPath); err == nil && len(data) > 0 {
defaults.ClientSecret = strings.TrimSpace(string(data))
log.Printf("Defaulting client-secret to service account token %s", tokenPath)
}
}

This code assumes the SA provided by user input is the same one that is running the pod (because we use that as the secret for the SA based OAuth client). It pulls the SA namespace from this as well.

We need to validate this instead of assuming the values are in agreement. We could do oc get user ~ with the SA token to make sure it matches (but I feel like there must be a better way to tell what SA is running a pod from inside the pod). The more correct thing would be a flag like --use-openshift-service-account=bool that just pulls the correct information from the pod / API.

xref: #60

@mrogers950
Copy link

@enj This sounds like a good idea to me.

@jparrill
Copy link

jparrill commented Mar 2, 2018

+1

@openshift-bot
Copy link

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@openshift-ci-robot openshift-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Aug 18, 2020
@openshift-bot
Copy link

Stale issues rot after 30d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle rotten
/remove-lifecycle stale

@openshift-ci-robot openshift-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Sep 17, 2020
@openshift-bot
Copy link

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Exclude this issue from closing again by commenting /lifecycle frozen.

/close

@openshift-ci-robot
Copy link

@openshift-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Exclude this issue from closing again by commenting /lifecycle frozen.

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.
Projects
None yet
Development

No branches or pull requests

5 participants