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

[Merged by Bors] - Add support for LDAP authentication #180

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
bc32d74
Add LDAP to CRD
sbernauer Apr 21, 2022
7896c60
Watch AuthenticationClass CRD
sbernauer Apr 21, 2022
d1f1b49
Add secret-operator-columes for bind credentials and tls certs
sbernauer Apr 21, 2022
a2db46c
Move config into separate file
sbernauer Apr 21, 2022
748d565
Add Flask configs for LDAP
sbernauer Apr 21, 2022
8b7d5e0
validation mechanism expects true, not True
sbernauer Apr 21, 2022
abcd0a8
Add MAPBOX_API_KEY again
sbernauer Apr 21, 2022
bd60ed8
Fix order of initialize_logging and print_startup_string
sbernauer Apr 21, 2022
14708a1
docs: Add installation of commons and secret operator
sbernauer Apr 25, 2022
c4c07db
docs: Add short section about LDAP
sbernauer Apr 25, 2022
f38e534
Extract /stackable/secrets/ into constant
sbernauer Apr 26, 2022
d226945
Update docs/modules/ROOT/pages/installation.adoc
sbernauer May 3, 2022
d0cf44b
Update docs/modules/ROOT/pages/usage.adoc
sbernauer May 3, 2022
e03be25
Update rust/operator-binary/src/config.rs
sbernauer May 3, 2022
a0d56db
Remove adminUser from example
sbernauer May 3, 2022
87777a3
Remove uneeded #[serde(rename_all = "PascalCase")]
sbernauer May 3, 2022
1ad8a10
Make get_imports() a constant
sbernauer May 3, 2022
48c930b
Rework authenticationConfig to feedback
sbernauer May 4, 2022
685c11a
Update example
sbernauer May 4, 2022
c9aa9cc
Merge branch 'main' into feature/ldap-authn-2
sbernauer May 4, 2022
a40330f
Fix wrong link in CHANGELOG.md
sbernauer May 4, 2022
60812f8
commons-operator 0.1.0 released
sbernauer May 5, 2022
85f54d4
secret-operator 0.3.0 released
sbernauer May 5, 2022
d4076f2
Update to operators-rs 0.18.0. Remove MutualTlsVerification
sbernauer May 5, 2022
f07604d
Update to operators-rs 0.19.0
sbernauer May 5, 2022
985c934
cargo fmt
sbernauer May 5, 2022
743d7a8
Update rust/operator-binary/src/config.rs
sbernauer May 9, 2022
dc103d7
Make type Result non-public
sbernauer May 9, 2022
6f4c33d
Update postgres name
sbernauer May 9, 2022
01ecf02
Re-add adminUser to example
sbernauer May 10, 2022
458b7f2
Add "superset init" to CMD
sbernauer May 10, 2022
d9e1e76
cargo fmt
sbernauer May 10, 2022
0306046
cargo fmt
sbernauer May 10, 2022
8acdfa6
Refactor references_authentication_class
sbernauer May 11, 2022
c60740a
Wait for SupersetDB to be finished before starting Superset
sbernauer May 12, 2022
a8f6232
Merge remote-tracking branch 'origin/main' into feature/ldap-authn-2
sbernauer May 12, 2022
6df5300
Error out if SupersetDB failed
sbernauer May 12, 2022
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
2 changes: 1 addition & 1 deletion deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ exceptions = [
{ name = "stackable-superset-crd", allow = ["OSL-3.0"] },
{ name = "stackable-superset-operator", allow = ["OSL-3.0"] },
{ name = "stackable-superset-operator-binary", allow = ["OSL-3.0"] },
]
]

[[licenses.clarify]]
name = "ring"
Expand Down
36 changes: 36 additions & 0 deletions deploy/crd/supersetcluster.crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,42 @@ spec:
properties:
spec:
properties:
authenticationConfig:
nullable: true
properties:
methods:
items:
properties:
authenticationClass:
description: Name of the AuthenticationClass used to authenticate the users
type: string
ldapExtras:
description: "Additional LDAP settings. Can only be specified when the specified AuthenticationClass uses the LDAP protocol See [Flask LDAP documentation](https://flask-appbuilder.readthedocs.io/en/latest/security.html#authentication-ldap)"
nullable: true
properties:
syncRolesAt:
default: Registration
description: "If we should replace ALL the user's roles each login, or only on registration. Gets mapped to `AUTH_ROLES_SYNC_AT_LOGIN`"
enum:
- Registration
- Login
type: string
userRegistration:
default: true
description: "Allow users who are not already in the FAB DB. Gets mapped to `AUTH_USER_REGISTRATION`"
type: boolean
userRegistrationRole:
default: Public
description: "This role will be given in addition to any AUTH_ROLES_MAPPING. Gets mapped to `AUTH_USER_REGISTRATION_ROLE`"
type: string
type: object
required:
- authenticationClass
type: object
type: array
required:
- methods
type: object
credentialsSecret:
type: string
loadExamplesOnInit:
Expand Down
36 changes: 36 additions & 0 deletions deploy/helm/superset-operator/crds/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,42 @@ spec:
properties:
spec:
properties:
authenticationConfig:
nullable: true
properties:
methods:
items:
properties:
authenticationClass:
description: Name of the AuthenticationClass used to authenticate the users
type: string
ldapExtras:
description: "Additional LDAP settings. Can only be specified when the specified AuthenticationClass uses the LDAP protocol See [Flask LDAP documentation](https://flask-appbuilder.readthedocs.io/en/latest/security.html#authentication-ldap)"
nullable: true
properties:
syncRolesAt:
default: Registration
description: "If we should replace ALL the user's roles each login, or only on registration. Gets mapped to `AUTH_ROLES_SYNC_AT_LOGIN`"
enum:
- Registration
- Login
type: string
userRegistration:
default: true
description: "Allow users who are not already in the FAB DB. Gets mapped to `AUTH_USER_REGISTRATION`"
type: boolean
userRegistrationRole:
default: Public
description: "This role will be given in addition to any AUTH_ROLES_MAPPING. Gets mapped to `AUTH_USER_REGISTRATION_ROLE`"
type: string
type: object
required:
- authenticationClass
type: object
type: array
required:
- methods
type: object
credentialsSecret:
type: string
loadExamplesOnInit:
Expand Down
8 changes: 8 additions & 0 deletions deploy/helm/superset-operator/templates/roles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,11 @@ rules:
- supersetdbs
verbs:
- create
- apiGroups:
- authentication.stackable.tech
resources:
- authenticationclasses
verbs:
- get
- list
- watch
36 changes: 36 additions & 0 deletions deploy/manifests/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,42 @@ spec:
properties:
spec:
properties:
authenticationConfig:
nullable: true
properties:
methods:
items:
properties:
authenticationClass:
description: Name of the AuthenticationClass used to authenticate the users
type: string
ldapExtras:
description: "Additional LDAP settings. Can only be specified when the specified AuthenticationClass uses the LDAP protocol See [Flask LDAP documentation](https://flask-appbuilder.readthedocs.io/en/latest/security.html#authentication-ldap)"
nullable: true
properties:
syncRolesAt:
default: Registration
description: "If we should replace ALL the user's roles each login, or only on registration. Gets mapped to `AUTH_ROLES_SYNC_AT_LOGIN`"
enum:
- Registration
- Login
type: string
userRegistration:
default: true
description: "Allow users who are not already in the FAB DB. Gets mapped to `AUTH_USER_REGISTRATION`"
type: boolean
userRegistrationRole:
default: Public
description: "This role will be given in addition to any AUTH_ROLES_MAPPING. Gets mapped to `AUTH_USER_REGISTRATION_ROLE`"
type: string
type: object
required:
- authenticationClass
type: object
type: array
required:
- methods
type: object
credentialsSecret:
type: string
loadExamplesOnInit:
Expand Down
8 changes: 8 additions & 0 deletions deploy/manifests/roles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,11 @@ rules:
- supersetdbs
verbs:
- create
- apiGroups:
- authentication.stackable.tech
resources:
- authenticationclasses
verbs:
- get
- list
- watch
7 changes: 7 additions & 0 deletions docs/modules/ROOT/pages/installation.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ installation method. First ensure that you have installed the Stackable Operator
$ helm repo add stackable https://repo.stackable.tech/repository/helm-stable/
----

We also need some addition components of the Stackable Data Platform (if not installed already)
sbernauer marked this conversation as resolved.
Show resolved Hide resolved
[source,bash]
----
$ helm install commons-operator stackable/commons-operator
$ helm install secret-operator stackable/secret-operator
----

Then install the Stackable Operator for Apache Superset
[source,bash]
----
Expand Down
4 changes: 4 additions & 0 deletions docs/modules/ROOT/pages/usage.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ If the examples were loaded then some dashboards are already available:

image::superset-dashboard.png[Superset dashboard showing birth names]

== Authenticate users using LDAP
Superset supports authentication users against an LDAP server.
sbernauer marked this conversation as resolved.
Show resolved Hide resolved
Have a look at https://github.com/stackabletech/superset-operator/blob/main/examples/superset-with-ldap.yaml[the LDAP example] and the general xref:commons-operator::authenticationclass.adoc[Stackable Authentication] documentation.

== Connecting Apache Druid Clusters

The operator can automatically connect superset clusters to Apache Druid clusters managed by the https://docs.stackable.tech/druid/index.html[Stackable Druid Cluster].
Expand Down
160 changes: 160 additions & 0 deletions examples/superset-with-ldap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
# helm install --repo https://repo.stackable.tech/repository/helm-stable/ secret-operator secret-operator
# helm install --repo https://repo.stackable.tech/repository/helm-stable/ commons-operator commons-operator
# Until commons-operator is available officially: helm install --version 0.1.0-pr11 --repo https://repo.stackable.tech/repository/helm-test/ commons-operator commons-operator
sbernauer marked this conversation as resolved.
Show resolved Hide resolved
# helm install --repo https://charts.bitnami.com/bitnami --set auth.username=superset --set auth.password=superset --set auth.database=superset postgresql-superset postgresql

# Log in with user01/user01 or user02/user02
---
apiVersion: secrets.stackable.tech/v1alpha1
kind: SecretClass
metadata:
name: openldap-tls
spec:
backend:
autoTls:
ca:
# autoGenerate: true # Needed in a future secret-operator version
sbernauer marked this conversation as resolved.
Show resolved Hide resolved
secret:
name: openldap-tls-ca
namespace: default
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: openldap
labels:
app.kubernetes.io/name: openldap
spec:
selector:
matchLabels:
app.kubernetes.io/name: openldap
serviceName: openldap
replicas: 1
template:
metadata:
labels:
app.kubernetes.io/name: openldap
spec:
containers:
- name: openldap
image: docker.io/bitnami/openldap:2.5
env:
- name: LDAP_ADMIN_USERNAME
value: admin
- name: LDAP_ADMIN_PASSWORD
value: admin
- name: LDAP_USERS
value: user01,user02
sbernauer marked this conversation as resolved.
Show resolved Hide resolved
- name: LDAP_PASSWORDS
value: user01,user02
- name: LDAP_ENABLE_TLS
value: "yes"
- name: LDAP_TLS_CERT_FILE
value: /tls/tls.crt
- name: LDAP_TLS_KEY_FILE
value: /tls/tls.key
- name: LDAP_TLS_CA_FILE
value: /tls/ca.crt
ports:
# - name: ldap
# containerPort: 1389
- name: tls-ldap
containerPort: 1636
volumeMounts:
- name: tls
mountPath: /tls
volumes:
- name: tls
csi:
driver: secrets.stackable.tech
volumeAttributes:
secrets.stackable.tech/class: openldap-tls
secrets.stackable.tech/scope: pod
---
apiVersion: v1
kind: Service
metadata:
name: openldap
labels:
app.kubernetes.io/name: openldap
spec:
type: ClusterIP
ports:
# - name: ldap
# port: 389
# targetPort: ldap
- name: tls-ldap
port: 636
targetPort: tls-ldap
selector:
app.kubernetes.io/name: openldap
---
apiVersion: v1
kind: Secret
metadata:
name: superset-with-ldap-server-veri-tls-credentials
type: Opaque
stringData:
sbernauer marked this conversation as resolved.
Show resolved Hide resolved
adminUser.username: admin
adminUser.firstname: Superset
adminUser.lastname: Admin
adminUser.email: admin@superset.com
adminUser.password: admin
sbernauer marked this conversation as resolved.
Show resolved Hide resolved
connections.secretKey: thisISaSECRET_1234
connections.sqlalchemyDatabaseUri: postgresql://superset:superset@postgresql-superset.default.svc.cluster.local/superset
sbernauer marked this conversation as resolved.
Show resolved Hide resolved
---
apiVersion: authentication.stackable.tech/v1alpha1
kind: AuthenticationClass
metadata:
name: superset-with-ldap-server-veri-tls-ldap
spec:
provider:
ldap:
hostname: openldap.default.svc.cluster.local
port: 636
searchBase: ou=users,dc=example,dc=org
ldapFieldNames:
uid: uid
bindCredentials:
secretClass: superset-with-ldap-server-veri-tls-ldap-bind
tls:
verification:
server:
caCert:
secretClass: openldap-tls
---
apiVersion: secrets.stackable.tech/v1alpha1
kind: SecretClass
metadata:
name: superset-with-ldap-server-veri-tls-ldap-bind
spec:
backend:
k8sSearch:
searchNamespace:
pod: {}
---
apiVersion: v1
kind: Secret
metadata:
name: superset-with-ldap-server-veri-tls-ldap-bind
labels:
secrets.stackable.tech/class: superset-with-ldap-server-veri-tls-ldap-bind
stringData:
user: cn=admin,dc=example,dc=org
password: admin
---
apiVersion: superset.stackable.tech/v1alpha1
kind: SupersetCluster
metadata:
name: superset-with-ldap-server-veri-tls
spec:
version: 1.4.1
statsdExporterVersion: v0.22.4
credentialsSecret: superset-with-ldap-server-veri-tls-credentials
nodes:
roleGroups:
default:
config:
authenticationConfig:
methods:
- authenticationClass: superset-with-ldap-server-veri-tls-ldap
Loading