Deepling of url of microflow and OIDC

0
Hi, in mendix, I have a microflow with an url, but when I open the url using the SSO with OIDC module, it shows the default page and not the url of the microflow. How to configure OIDC so that it show the url of the microflow ? Thanks
asked
3 answers
0

Hi,

I finally managed it with cookies and no changes on OIDC setup : 

- add script to theme\web\login.html (bellow)

- add a nanoflow on the page after redirect and add a dataview with data source a nanoflow that executes the javascript

 

 

## page after redirect

var redirectUrl = '';

let value = "; " + document.cookie;

let parts = value.split("; " + 'redirect-url' + "=");

if (parts.length === 2) {

redirectUrl = parts.pop().split(";").shift();

//remove the cookie

document.cookie = 'redirect-url=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';

window.location.href = redirectUrl;

}

 

## script to theme\web\login.html

        <script>function getBaseURL(url) {    const regex = /^(https?:\/\/[^\/]+)/;    const match = url.match(regex);    var url = match ? match[1] : "";    if (url.endsWith('/')) {        url = url.slice(0, -1);    }    return url;}

function setCookie(name, value, days) {    let expires = "";    if (days) {        const date = new Date();        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));        expires = "; expires=" + date.toUTCString();    }    document.cookie = name + "=" + (value || "") + expires + "; path=/";}    function removeStartingSlash(text) {    return text.replace(/^\/+/, '');}

function extractFragment(url) {    var arr = url.split('#');    if(arr.length > 1){        return removeStartingSlash(arr[1] || "");    }    return "";}    

const baseUrl = getBaseURL(window.location.href);//http://localhost:8080/login.html#/OpenOffer/13 => http://localhost:8080const fragment = extractFragment(window.location.href);//OpenOffer/13const redirectUrl =  baseUrl + "/p/" + fragment;if(fragment != ''){    setCookie("redirect-url", redirectUrl, 1);}                </script>

answered
0

Hi Sebastien, 

I'm facing a smiliar issue and wondering if you go eloborate on how you solved this.

answered
0

Hi,


This is usually not an OIDC configuration problem itself. The original URL needs to be preserved through the OIDC login flow.


If you are using Mendix 10.6+, the recommended approach is to use the built-in Page URL / Microflow URL functionality instead of the deprecated Deep Link module. Mendix explicitly supports Page and Microflow URLs with OIDC SSO and redirects the user back to the requested URL after successful authentication.


For example, if the microflow has a URL like:

https://myapp.com/mf/myMicroflow

the flow should be:

User opens Microflow URL
        ↓
OIDC authentication
        ↓
IdP login
        ↓
Mendix OIDC callback
        ↓
Original Microflow URL is restored
        ↓
Microflow executes

What to check

    • Configure a URL for the microflowOpen the microflow.
    • In Properties → URL, configure the required URL.
    • If the microflow has parameters, configure them as URL parameters as required.
  1. Make sure OIDC SSO is configured to preserve the original URL.
  2. The current OIDC SSO module supports Page URLs and Microflow URLs specifically for this login continuation scenario.
  3. If you are still using the old Deep Link module, check the LoginLocation constant.
  4. For OIDC it should be:
/oauth/v2/login?cont=

The important part is the trailing = because the original deep-link URL is appended to the cont parameter.


For example:

/oauth/v2/login?cont=<original-url>

  1. If you're on Mendix 10.6+, I would avoid implementing new functionality with the old Deep Link module. It was deprecated in 10.6 and replaced by built-in Page URLs and Microflow URLs.


One more important point: if the microflow URL is supposed to execute a microflow and then open a page, Mendix supports that behavior—the microflow runs during client startup, and if it contains a Show a page action, that page is opened instead of the home page.


So the key is: don't configure OIDC to redirect simply to the default index.html; preserve the original Page/Microflow URL through the authentication continuation (cont) flow.


answered