asrocha

asrocha

Hello everyone,

I’m working on a Phoenix 1.7 application that requires authentication and authorization using Keycloak. This application is a SAAS multi-tenant system, where the Phoenix 1.7 front-end communicates with a Python Django back-end. Each tenant is identified by a subdomain, such as “my-tenant.blueparachute.io,” and each tenant corresponds to a separate Keycloak realm. The Django back-end handles tenancy perfectly, but I’m facing challenges in implementing the same with Elixir and Phoenix using Pow and PowAssent.

Here’s what I have done so far in my configuration, although I’m currently forcing the tenant to “dogfooding” for the sake of progress:

elixirCopy code

config :bpfe, :pow_assent,
  providers: [
    blueparachute: [
      site: "http://iam.blueparachute.io:8081/auth/realms/dogfooding",
      client_id: "dogfooding_auth_client",
      client_secret: "JHbZvvfuaen2H37genUHHUubhUANuP3z",
      strategy: Assent.Strategy.OIDC,
      redirect_uri: "http://{@tenant}.blueparachute.io:4000/auth/blueparachute/callback"
    ],
  ]

The Problems:

  1. When I generate links to providers in my Phoenix view:
<%= for link <- PowAssent.Phoenix.ViewHelpers.provider_links(@conn, tenant: @tenant) do %>
  <span class="btn btn-primary"><%= link %></span>
<% end %>

The redirect_uri is not constructed correctly. It always redirects to “blueparachute.io/auth/blueparachue/callback” without including the “dogfooding” tenant. I need assistance in rewriting the URL to include the correct tenant.

  1. I need to understand how to handle the callback. Specifically, I want to perform operations such as inserting users into the database, creating sessions, and so on. I’ve been working on this for the past two weeks but haven’t found a reliable solution.

Your guidance and assistance would be greatly appreciated. Thank you!

Showing Posts 1 to 5

tomazbracic

tomazbracic

Hi @asrocha,

I hope you’ll get some productive help. I asked many times for some guidance in “integration” cases and specifically for Keycloak, since I truly believe that if there would be more help/activity in this integration part, the whole ecosystem would benefit since new opportunities would open (integration with Enterprise ecosystems, … ) and specifically because it is a totally natural state to have heterogeneous systems in your solution. I wish some of more wise people would react on this and put some effort into this.

Regardles what I just wrote, you still have your problem. :slight_smile: Hope someone helps you (and others with that too).

Kind regards,
Tomaz

linusdm

linusdm

Hey,

I’ve documented how to integrate Assent with the code generated by phx.gen.auth before here:

https://github.com/linusdm/phx_gen_auth_meets_assent

This might give you an idea how to do the integration. Keep in mind that this is not integrating the full Pow goodies (so it won’t answer your first question), which afaik, makes phx.gen.auth unneeded.

bobek

bobek

I have still not got to use it in production, but these types of problems seem to be a perfect match for Ash. Namely Multitenancy — ash v3.29.3 in this case.

asrocha

asrocha OP

Hi,
@tomazbracic, thanks for aswer.
I came from Python ( where I have many years of experience in backend and architecture) and open source world solutions (I newbie in Elixir in Phoenix, it is Challenger think elixir way), but I believe that a complex problem, need a solutions that solve the problem:
I recoment for everyone Keycloak a authentication and authorization solution for application that have multiples (cloud, microservice, frontend, backend) etc.
I 'm not found the way that Phoenix works satisfactory with multi-tenancy in keycloak, but When I found that I will share to the community.

asrocha

asrocha OP

Hi,
@linusdm Thanks for answer
I will clone your repository and try understand your code and approach.
Thanks for your time and attention.

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews