Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
1f6725c
Use auth plugin to create users and set its password if plugin requir…
alereca Feb 16, 2023
bc1e3ea
Define default auth plugin and use password values in order to keep p…
alereca Feb 22, 2023
0ab2e22
Add missing ResourceOptionsAsClauses cr assignation in user create
alereca Feb 22, 2023
c9e65f8
Replace as with by in create and alter user queries
alereca Feb 24, 2023
2c6ba73
Set AuthPlugin as an user observation to be included in user status
alereca Feb 25, 2023
3e710a6
Include AuthPlugin in observed fields and apply alter query only of u…
alereca Feb 25, 2023
6b453fe
Add missing comma in grant select query (observe method)
alereca Feb 27, 2023
6529b9e
Add space in grant select query (observe method)
alereca Feb 27, 2023
46c3d00
Merge branch 'master' into feat/support-authentication-plugins-like-l…
alereca Oct 18, 2025
e71cc6e
refactor: apply chlunde suggestion of using either nil or empty strin…
alereca Oct 18, 2025
89c48e4
refactor: replace pointer package usage with ptr package
alereca Oct 19, 2025
0f1c5e6
docs: update authPlugin field from user spec to use database default …
alereca Oct 19, 2025
7f0f5a2
docs: add examples for MySQL users with different authentication plugins
alereca Oct 19, 2025
5f01d39
docs: correct example user name for caching_sha2_password authentication
alereca Oct 19, 2025
f691e40
refactor(mysql): streamline password handling and user creation/updat…
alereca Oct 19, 2025
2b7f14f
feat(mysql): add AuthPlugin and UsePassword support to namespaced Use…
alereca Oct 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions apis/cluster/mysql/v1alpha1/user_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@ type UserParameters struct {
// +optional
ResourceOptions *ResourceOptions `json:"resourceOptions,omitempty"`

// AuthPlugin sets the mysql authentication plugin.
// If not specified (nil or empty string), the database server's default authentication plugin is used.
// This allows compatibility with different MySQL/MariaDB versions and their default authentication methods.
// Common plugins: caching_sha2_password (MySQL 8.0+), mysql_native_password, authentication_ldap_simple, etc.
// +optional
// +kubebuilder:validation:Pattern:=^([a-z]+_)+[a-z]+$
AuthPlugin *string `json:"authPlugin,omitempty"`

// UsePassword indicate whether the provided AuthPlugin requires setting a password, defaults to true
// +optional
UsePassword *bool `json:"usePassword,omitempty" default:"true"`
// BinLog defines whether the create, delete, update operations of this user are propagated to replicas. Defaults to true
// +optional
BinLog *bool `json:"binlog,omitempty"`
Expand Down Expand Up @@ -74,6 +85,9 @@ type ResourceOptions struct {
type UserObservation struct {
// ResourceOptionsAsClauses represents the applied resource options
ResourceOptionsAsClauses []string `json:"resourceOptionsAsClauses,omitempty"`

// AuthPlugin represents the applied mysql authentication plugin
AuthPlugin *string `json:"authPlugin,omitempty"`
}

// +kubebuilder:object:root=true
Expand Down
15 changes: 15 additions & 0 deletions apis/cluster/mysql/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions apis/namespaced/mysql/v1alpha1/user_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ type UserParameters struct {
// +optional
PasswordSecretRef *xpv1.LocalSecretKeySelector `json:"passwordSecretRef,omitempty"`

// AuthPlugin specifies the authentication plugin to use for the user.
// If not specified (nil or empty string), the database server's default authentication plugin is used.
// Common values include "mysql_native_password", "caching_sha2_password", "authentication_ldap_simple".
// See https://dev.mysql.com/doc/refman/8.0/en/authentication-plugins.html
// +optional
// +kubebuilder:validation:Pattern:=^([a-z]+_)+[a-z]+$
AuthPlugin *string `json:"authPlugin,omitempty"`

// UsePassword indicate whether the provided AuthPlugin requires setting a password, defaults to true
// +optional
UsePassword *bool `json:"usePassword,omitempty" default:"true"`

// ResourceOptions sets account specific resource limits.
// See https://dev.mysql.com/doc/refman/8.0/en/user-resources.html
// +optional
Expand Down Expand Up @@ -73,6 +85,9 @@ type ResourceOptions struct {

// A UserObservation represents the observed state of a MySQL user.
type UserObservation struct {
// AuthPlugin is the authentication plugin currently configured for the user
AuthPlugin *string `json:"authPlugin,omitempty"`

// ResourceOptionsAsClauses represents the applied resource options
ResourceOptionsAsClauses []string `json:"resourceOptionsAsClauses,omitempty"`
}
Expand Down
15 changes: 15 additions & 0 deletions apis/namespaced/mysql/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 52 additions & 0 deletions examples/cluster/mysql/user_with_auth_plugin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
# Example: User with custom authentication plugin (e.g., LDAP)
# Some authentication plugins like authentication_ldap_simple don't require
# passwords, so usePassword is set to false
apiVersion: mysql.sql.crossplane.io/v1alpha1
kind: User
metadata:
name: example-ldap-user
spec:
forProvider:
authPlugin: authentication_ldap_simple
usePassword: false # LDAP authentication doesn't use a MySQL password
providerConfigRef:
name: example
---
# Example: User with specific authentication plugin and password
# For plugins that require passwords like caching_sha2_password
apiVersion: mysql.sql.crossplane.io/v1alpha1
kind: User
metadata:
name: example-caching-sha2-user
spec:
forProvider:
authPlugin: caching_sha2_password
passwordSecretRef:
name: example-pw
namespace: default
key: password
writeConnectionSecretToRef:
name: example-sha2-connection-secret
namespace: default
providerConfigRef:
name: example
---
# Example: User without authPlugin specified (uses database server default)
# This is the recommended approach for maximum compatibility
# across different MySQL/MariaDB versions
apiVersion: mysql.sql.crossplane.io/v1alpha1
kind: User
metadata:
name: example-default-user
spec:
forProvider:
passwordSecretRef:
name: example-pw
namespace: default
key: password
writeConnectionSecretToRef:
name: example-default-connection-secret
namespace: default
providerConfigRef:
name: example
51 changes: 51 additions & 0 deletions examples/namespaced/mysql/user_with_auth_plugin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
# Example: Namespaced User with custom authentication plugin (e.g., LDAP)
# Some authentication plugins like authentication_ldap_simple don't require
# passwords, so usePassword is set to false
apiVersion: mysql.sql.m.crossplane.io/v1alpha1
kind: User
metadata:
name: example-ldap-user
namespace: default
spec:
forProvider:
authPlugin: authentication_ldap_simple
usePassword: false # LDAP authentication doesn't use a MySQL password
providerConfigRef:
name: example
---
# Example: Namespaced User with specific authentication plugin and password
# For plugins that require passwords like caching_sha2_password
apiVersion: mysql.sql.m.crossplane.io/v1alpha1
kind: User
metadata:
name: example-caching-sha2-user
namespace: default
spec:
forProvider:
authPlugin: caching_sha2_password
passwordSecretRef:
name: example-pw
key: password
writeConnectionSecretToRef:
name: example-sha2-connection-secret
providerConfigRef:
name: example
---
# Example: Namespaced User without authPlugin specified (uses database server default)
# This is the recommended approach for maximum compatibility
# across different MySQL/MariaDB versions
apiVersion: mysql.sql.m.crossplane.io/v1alpha1
kind: User
metadata:
name: example-default-user
namespace: default
spec:
forProvider:
passwordSecretRef:
name: example-pw
key: password
writeConnectionSecretToRef:
name: example-default-connection-secret
providerConfigRef:
name: example
16 changes: 16 additions & 0 deletions package/crds/mysql.sql.crossplane.io_users.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ spec:
description: UserParameters define the desired state of a MySQL user
instance.
properties:
authPlugin:
description: |-
AuthPlugin sets the mysql authentication plugin.
If not specified (nil or empty string), the database server's default authentication plugin is used.
This allows compatibility with different MySQL/MariaDB versions and their default authentication methods.
Common plugins: caching_sha2_password (MySQL 8.0+), mysql_native_password, authentication_ldap_simple, etc.
pattern: ^([a-z]+_)+[a-z]+$
type: string
binlog:
description: BinLog defines whether the create, delete, update
operations of this user are propagated to replicas. Defaults
Expand Down Expand Up @@ -117,6 +125,10 @@ spec:
connections to the server by an account
type: integer
type: object
usePassword:
description: UsePassword indicate whether the provided AuthPlugin
requires setting a password, defaults to true
type: boolean
type: object
managementPolicies:
default:
Expand Down Expand Up @@ -211,6 +223,10 @@ spec:
description: A UserObservation represents the observed state of a
MySQL user.
properties:
authPlugin:
description: AuthPlugin represents the applied mysql authentication
plugin
type: string
resourceOptionsAsClauses:
description: ResourceOptionsAsClauses represents the applied resource
options
Expand Down
16 changes: 16 additions & 0 deletions package/crds/mysql.sql.m.crossplane.io_users.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ spec:
description: UserParameters define the desired state of a MySQL user
instance.
properties:
authPlugin:
description: |-
AuthPlugin specifies the authentication plugin to use for the user.
If not specified (nil or empty string), the database server's default authentication plugin is used.
Common values include "mysql_native_password", "caching_sha2_password", "authentication_ldap_simple".
See https://dev.mysql.com/doc/refman/8.0/en/authentication-plugins.html
pattern: ^([a-z]+_)+[a-z]+$
type: string
binlog:
description: BinLog defines whether the create, delete, update
operations of this user are propagated to replicas. Defaults
Expand Down Expand Up @@ -98,6 +106,10 @@ spec:
connections to the server by an account
type: integer
type: object
usePassword:
description: UsePassword indicate whether the provided AuthPlugin
requires setting a password, defaults to true
type: boolean
type: object
managementPolicies:
default:
Expand Down Expand Up @@ -164,6 +176,10 @@ spec:
description: A UserObservation represents the observed state of a
MySQL user.
properties:
authPlugin:
description: AuthPlugin is the authentication plugin currently
configured for the user
type: string
resourceOptionsAsClauses:
description: ResourceOptionsAsClauses represents the applied resource
options
Expand Down
Loading