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

[Story] Use Password Authentication for Kubernetes #206

Open
ebaron opened this issue May 14, 2021 · 6 comments
Open

[Story] Use Password Authentication for Kubernetes #206

ebaron opened this issue May 14, 2021 · 6 comments
Assignees
Labels
feat New feature or request

Comments

@ebaron
Copy link
Member

ebaron commented May 14, 2021

Currently, Cryostat only authenticates users by default when run in OpenShift. We should configure password authentication when running on Kubernetes, perhaps generating credentials prior to deployment.

@ebaron
Copy link
Member Author

ebaron commented Apr 19, 2023

For now, I think it's enough to allow users to provide a secret through the Cryostat CRD containing the credentials in the format expected by Cryostat's BasicAuthManager.

From the Cryostat README:

The BasicAuthManager uses basic credential authentication configured with a standard Java properties file at $CRYOSTAT_CONFIG_PATH/cryostat-users.properties. The credentials stored in the Java properties file are the user name and a SHA-256 sum hex of the user's password. The property file contents should look like:

user1=abc123
user2=def987

Where abc123 and def987 are substituted for the SHA-256 sum hexes of the desired user passwords. These can be obtained by ex. echo -n PASS | sha256sum | cut -d' ' -f1.

If the user provides this secret, the operator should mount the properties file within the secret at the $CRYOSTAT_CONFIG_PATH/cryostat-users.properties within the Cryostat container. It should then set the CRYOSTAT_AUTH_MANAGER environment variable to io.cryostat.net.BasicAuthManager.

If the user doesn't provide the secret, then we fall back to the existing behaviour. On OpenShift, the OpenShiftAuthManager is used. On Kubernetes, the NoopAuthManager is used.

@ebaron
Copy link
Member Author

ebaron commented Apr 19, 2023

Hey @jaadbarg! This is the issue I had in mind.

@ebaron
Copy link
Member Author

ebaron commented Apr 19, 2023

Here's how the API could look:

// CryostatSpec defines the desired state of Cryostat.
type CryostatSpec struct {
	// ...

	// Options to configure how Cryostat authenticates users.
	// +optional
	// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Authentication Options"
	AuthenticationOptions *AuthenticationOptions `json:"authentication,omitempty"`
}
type AuthenticationOptions struct {
	// By providing a secret containing a credentials property file, Cryostat will use basic
	// authentication instead of the platform defaults. When unset on OpenShift, Cryostat will integrate
	// with OpenShift's OAuth Server (Recommended). When unset on Kubernetes, Cryostat will not
	// perform any form of authentication.
	// +optional
	// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Basic Authentication"
	BasicAuthentication *BasicAuthenticationSecret `json:"basicAuth,omitempty"`
}

// BasicAuthenticationSecret refers to a Secret containing credentials
// that Cryostat can use for basic authentication.
type BasicAuthenticationSecret struct {
	// Name of the Secret within Cryostat's namespace.
	// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:io.kubernetes:Secret"}
	SecretName string `json:"secretName"`
	// Key within secret containing the properties file. The properties file should contain one user per line,
	// with the syntax "user=passHex", where "user" is the username and "passHex" is the SHA-256 hash of the desired
	// password. The SHA-256 hash can be computed by tools such as "sha256sum".
	// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:text"}
	Filename string `json:"filename"`
}

@ebaron ebaron added the feat New feature or request label Apr 21, 2023
@jaadbarg
Copy link
Contributor

Hi @ebaron I can take this one👍👍

@ebaron ebaron changed the title Use Password Authentication for Kubernetes [Story] Use Password Authentication for Kubernetes Apr 21, 2023
@andrewazores
Copy link
Member

Looks like this was already completed. In 3.0 it will be implemented slightly differently via oauth2_proxy/openshift-oauth-proxy, but the CR API will be the same or very similar for the user perspective.

@ebaron
Copy link
Member Author

ebaron commented Apr 3, 2024

I think this is still outstanding, it was done in the Helm Chart but not in the operator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants