-
Notifications
You must be signed in to change notification settings - Fork 25
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
Stops display of the token if not JWT and if Openshift cluster fetches the username from the master API #275
Stops display of the token if not JWT and if Openshift cluster fetches the username from the master API #275
Conversation
Was experimenting with the cluster REST API and tried this out. Seems to work correctly but will probably need tidying up if we want to include it. Anyway, post what you think of it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The username resolution logic looks good, but there are other comments that need to be addressed.
And while it's fine to support such case, it's important that it's just an edge case and should never impede the normal case with K8s and serviceaccount token by adding extra load. |
24dd89d
to
edf3ce2
Compare
Despite attempts to avoid an enquiry of the API Server to determine if it belongs to an OpenShift cluster, I have found no other way to get that result. The So the latest version:
|
edf3ce2
to
936bf87
Compare
Just an idea to explore: What about using local storage and cache the result on whether it's OCP or K8s there? The reasoning is that local storage is tied to a hostname and it's highly unlikely that the same hostname changes the type of cluster. If the result is cached, we only need to inquire once. If a similar inquiry has been done in other places in hawtio-online, we might also be able to use the cached result to remove extra burden on API server further. |
Yet another option might be that the nginx server holds the result of the inquiry [1] somewhere on the server in some way and provides an extra endpoint like [1] Lines 18 to 31 in 79baa70
|
…o#271) * In the corner-case that form-login is used to login to an OpenShift cluster, JWT decode is not able to decrypt it to provide the username. However, it is possible to fetch the user using the Openshift API. * To discover the subject: 1. Try retrieving the username using JWT decode; 2. Determine if the cluster is OpenShift by asking the master URI 3. In the event that the cluster is OpenShift then ask the master URI for the username
936bf87
to
e41053d
Compare
Went with the second approach, ie. injecting the flag from the server by adding it to osconsole/config.json. |
* Since nginx host server already enquires as whether the cluster is OpenShift, make this property available to hawtio by adding it to the osconsole/config.json * The effect is that the form-service no longer has to interrogate the master API to determine the same result.
e41053d
to
d925249
Compare
Asks the Openshift cluster for the username associated with the given token.
If using form-login and connecting to Openshift, it is possible to obtain the username associated with the login token using the OS REST API.
Adds a small function to the
form-service.ts
that fetches the username upon successful login.