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

Guide: Securing a WildFly app on k8s with OIDC #2087

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

theashiot
Copy link

@theashiot theashiot commented Jan 31, 2024

cd /PATH/TO/ELYTRON/EXAMPLES/simple-webapp-oidc/charts
----

. Create a file `values.yml`.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @theashiot, apologies for the delayed response. I haven't gone through this in detail yet but yes, adding a file with the required configuration for k8s to the existing example would make sense.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @fjuma, i've created a PR to add the file: wildfly-security-incubator/elytron-examples#209

I'll updated the steps shortly.

Copy link
Author

@theashiot theashiot Feb 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updates the steps. Ready for review!

Please note that I haven't tested the steps for Quay. I have based them on https://www.wildfly.org/news/2023/06/16/deploy-on-kubernetes-with-helm/ . I'm facing some authentication problems with Quay.

I've tested the steps for Docker Hub.

@theashiot theashiot force-pushed the develop branch 2 times, most recently from 7303027 to b7060de Compare February 8, 2024 06:15
@theashiot theashiot marked this pull request as ready for review February 8, 2024 06:15

== Example Application

We use a simple web application in this guide that consists of a single https://github.com/wildfly-security/elytron-examples/blob/main/simple-webapp-oidc/src/main/java/org/wildfly/security/examples/SecuredServlet.java[servlet]. We show how to secure this servlet using OIDC. We will use the example in the https://github.com/wildfly-security-incubator/elytron-examples/tree/main/simple-webapp-oidc[simple-webapp-oidc] directory in the https://github.com/wildfly-security/elytron-examples[elytron-examples] repository.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, the examples repo is under the wildfly-security-incubator account.
https://github.com/wildfly-security-incubator/elytron-examples

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, fixed!

@theashiot
Copy link
Author

Hi @PrarthonaPaul,

I've made some updates. The steps for port-forwarding were missing. I've added them now. The steps work for dockerhub, but when i use quay, i get "ErrImagePull".

kubectl get pod
NAME                             READY   STATUS         RESTARTS      AGE
keycloak-65766c8d6b-tdnhn        1/1     Running        1 (42m ago)   75m
oidc-app-5d6f9974fd-srvrg        1/1     Running        0             26m
oidc-app-quay-79d48ff4df-lsb6l   0/1     ErrImagePull   0             68s

oidc-app-5d6f9974fd-srvrg is launched from dockerhub. oidc-app-quay-79d48ff4df-lsb6l is from quay.

I'm not able to figure out whats going wrong.

best,
ashwin

@PrarthonaPaul
Copy link
Contributor

Hi @PrarthonaPaul,

I've made some updates. The steps for port-forwarding were missing. I've added them now. The steps work for dockerhub, but when i use quay, i get "ErrImagePull".

kubectl get pod
NAME                             READY   STATUS         RESTARTS      AGE
keycloak-65766c8d6b-tdnhn        1/1     Running        1 (42m ago)   75m
oidc-app-5d6f9974fd-srvrg        1/1     Running        0             26m
oidc-app-quay-79d48ff4df-lsb6l   0/1     ErrImagePull   0             68s

oidc-app-5d6f9974fd-srvrg is launched from dockerhub. oidc-app-quay-79d48ff4df-lsb6l is from quay.

I'm not able to figure out whats going wrong.

best, ashwin

Hello @theashiot
It could be because you don't have your quay secret uploaded to k8.
Here are the steps to doing that for OpenShift: https://wildfly-security.github.io/wildfly-elytron/blog/in-progress-wildfly-feature-on-openshift/#configure-image-pull-secret

@theashiot
Copy link
Author

Thanks, @PrarthonaPaul for the reply! As discussed, i've removed all mentions of quay. I'll add quay-related info in a separate PR when i'm able to get it running.

best,
ashwin

:toc: macro
:toc-title:

You can secure your WildFly applications deployed on Kubernetes with OpenID Connect (OIDC). By using OIDC to secure applications, you delegate authentication to OIDC providers. This guide shows how to secure an example application deployed to WildFly on Kubernetes cluster running on your local machine, with OIDC using Keycloak as the OIDC provider.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/on Kubernetes cluster/on a Kubernetes cluster

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/OIDC provider/OpenID provider

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!


== Start Keycloak

We will be using Keycloak as our OIDC identity provider.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/OIDC identity provider/OpenID provider

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


We will be using Keycloak as our OIDC identity provider.

Follow the instructions, till "Log in to the Admin Console", provided in the https://www.keycloak.org/getting-started/getting-started-kube[Get started with Keycloak on Kubernetes] guide.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/till/up until

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

+
[source,subs=+quotes]
----
docker login __CONTAINER_REGISTRY__
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CONTAINER_REGISTRY seems to render a bit odd. Could we use <CONTAINER_REGISTRY> or something similar instead?

Copy link
Author

@theashiot theashiot May 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated all italics to <this_form>

docker tag simple-webapp-oidc __TAGGED_IMAGE__
----
+
Substitute __TAGGED_IMAGE__ as follows:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, renders in a way that's a bit hard to read.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@fjuma
Copy link
Contributor

fjuma commented May 7, 2024

Thanks for the post @theashiot! This looks great!

@PrarthonaPaul Would you be able to try out the steps from this post when you get a chance?

@theashiot
Copy link
Author

Thanks, @fjuma for the review! I've updated the content.

best,
ashwin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants