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

Migrate to keycloak #413

Merged
merged 9 commits into from
Nov 5, 2024
Merged

Migrate to keycloak #413

merged 9 commits into from
Nov 5, 2024

Conversation

Adzz
Copy link
Contributor

@Adzz Adzz commented Oct 29, 2024

in order to add ueberauth_oidcc I had to update telemetry_poller which triggered updating phoenix.

This then migrates to using keycloak and updates the tests for that use case.

@Adzz Adzz changed the title WIP WIP - keycloak Oct 29, 2024
In order to do this we needed to add the ueberauth_oidc library which
then involved updating a few other deps including Phoenix. But this
should now enable a user with the correct role logging into the app via
keycloak. It will reject any user who does not have the correct role.
@napilla
Copy link
Collaborator

napilla commented Nov 1, 2024

in order to add ueberauth_oidcc I had to update telemetry_poller which triggered updating phoenix.

This then tries to rip out cognito and add in keycloak. WIP

I realised I think we should use a unique role name for this app so that there is no chance of accidentally giving access to users of different apps here because they have a role with the same name in keycloak

the implementation is broadly working just need to fix tests now.

Posting here for prosperity: My understanding is roles are created per client (each application has a keycloak client) and if roles are named the same between clients there is no clash because the roles only come in during authentication with that particular client .

Either way, I think we are good with the role name we decided (document-viewer-admin)

@napilla
Copy link
Collaborator

napilla commented Nov 5, 2024

@Adzz I made some changes here, mostly to fix some warnings that came up failing the build and test step and making sure it integrates well with Keycloak DEV (looks like it worked well for me). Last steps here are to fix up the tests happy to work on that today

@Adzz
Copy link
Contributor Author

Adzz commented Nov 5, 2024

Hey no worry the tests are a nightmare so I can crack that out now, thanks for the contribution though!

@Adzz Adzz changed the title WIP - keycloak Migrate to keycloak Nov 5, 2024
@Adzz Adzz marked this pull request as ready for review November 5, 2024 17:51
@napilla
Copy link
Collaborator

napilla commented Nov 5, 2024

I'm still reviewing some other stuff in this PR, but it looks like its failing and I have one important thing that I think will need to be done to successfully work in deployed environments: can you add in ca-certificates as a dependency in this project's dockerfile?

See:
https://github.com/mbta/alerts_concierge/blob/d7b0b431bb2e25864e008bb17dbaaa3367387bf6/Dockerfile#L59

And the error that happens if you do not do this: https://www.notion.so/mbta-downtown-crossing/Implementing-a-Keycloak-integration-ebf669208d464986b4989294891b1d8e?pvs=4#49283e6e8bc0478e965a416f8cc5e8d8

This happened while I was testing APA and suspect it would happen here too.

Copy link
Collaborator

@napilla napilla left a comment

Choose a reason for hiding this comment

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

Looks good, I think we have to enable the one job before we merge though

@@ -11,7 +11,8 @@ defmodule DocumentViewer.Application do
DocumentViewerWeb.Telemetry,
# Start the PubSub system
{Phoenix.PubSub, name: DocumentViewer.PubSub},
Catalog.Supervisor,
# commenting out so I can start the app or attempt to.
# Catalog.Supervisor,
Copy link
Collaborator

Choose a reason for hiding this comment

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

we need this enabled when we merge in

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh yes great spot! will change

end)

assert log =~ "Ueberauth error: failed"
assert log =~ "Ueberauth error: Cross-Site Request Forgery attack"
Copy link
Collaborator

Choose a reason for hiding this comment

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

hahah, I don't like it but I was having trouble with this yesterday anyhow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think ultimately we are trying to test what happens when we get an error in ueberauth, which this does so I'm fine with it.

@Adzz Adzz force-pushed the move_to_keycloak branch 2 times, most recently from ad574f5 to ad55b88 Compare November 5, 2024 20:04
@Adzz Adzz merged commit a78368a into main Nov 5, 2024
5 checks passed
@Adzz Adzz deleted the move_to_keycloak branch November 5, 2024 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants