project-pegaprox icon indicating copy to clipboard operation
project-pegaprox copied to clipboard

[Feature] OIDC login to portal

Open GreyChame1eon opened this issue 2 months ago • 5 comments

Describe the feature

This feature request grew from #248.

Let me explain. I want to give some users permission to control their own VMs, but they should not get information about the cluster (load, resources, etc.). So, I don't want to give them the cluster.read permission.

But without this permission, users cannot see VMs (even if they have the vm.view permission).

I have read #248 and understand that this is not a bug, but by design, and that I should use /portal in that case. OK, but for now, the login portal allows local logins only. So, an OIDC login button would be great!

Also, it would be perfect to have an auto-redirect to /portal for users who have the "portal only" setting, so all users can access the same URL.

Use Case

Give access to VMs for users that have only few VMs and don't want / should get information about all the cluster resources

Alternatives considered

Change ACLs as per #248 to give VM access without cluster.view permission

How important is this for you?

Would improve my workflow

Checklist

  • [X] I have searched existing issues and discussions to make sure this hasn't been requested before

GreyChame1eon avatar Sep 11 '26 06:09 GreyChame1eon

Two separate things here, and they're not equally far away.

The OIDC-to-portal half is closer than you'd think. The OIDC callback already hands back portal_only and honours a redirect_after, so the plumbing exists — what's missing is the button on the portal login page to start the flow. So less "portal is local-only" and more "nobody wired the entry point".

The auto-redirect is a fair point too. Right now a portal_only account that lands on / just gets logged out, which is a rough way of saying "wrong door".

Both sit on the OIDC login path though, and that's Nico's corner rather than mine — assigning to him. Noted, no promises on when.

Marcus · https://opencollective.com/pegaprox keeps this going if you're able

mkellermann97 avatar Sep 12 '26 07:09 mkellermann97

Correction to what I wrote yesterday — I had that wrong, sorry.

The SSO button on the portal login page already exists and has since April. portal.html asks /api/auth/check for oidc_enabled (that endpoint returns the flag even when you're not logged in), and if it's on you get a "Sign in with SSO" button under the password form that kicks off /api/auth/oidc/authorize?redirect_after=/portal. I went looking for the entry point yesterday and managed to miss it.

So if you're not seeing it: check that OIDC is actually enabled in Settings. The button is gated on that flag, nothing else. If it is enabled and there's still no button, say so and we'll dig — that would be a real bug rather than a missing feature.

The second half of your request stands though. A portal_only account that lands on / currently just gets logged out, which is a blunt way to say "wrong door". Redirecting instead is fair and still on the list.

mkellermann97 avatar Sep 13 '26 19:09 mkellermann97

Sorry for the long response; I spent some time reproducing it.

Here is why I cannot see that button in /portal. If I open /portal in a clean browser session, I can see the button. However, if I was previously logged into the main window, the button disappears. If I log out of the main window and refresh the /portal page, the button appears again.

At the same time, the button is not working in my case. The browser console error is:

portal:1 Uncaught ReferenceError: startOidcLogin is not defined
    at HTMLButtonElement.onclick (portal:1:1)
onclick @ portal:1

GreyChame1eon avatar Sep 16 '26 14:09 GreyChame1eon

That repro was worth the time - it's two separate bugs and you found both.

Button disappears when you're logged into the main window. /api/auth/check only puts oidc_enabled in its 401 response, never in the 200 one (api/auth.py, the flag is set inside the if not session: branch). Clean browser means no session means 401 means the flag arrives and the portal draws the button. With a main-window session the same request comes back 200 without the flag, so the portal concludes SSO is off. Log out of the main window and you're back to the 401 path - exactly the sequence you described.

The button does nothing. portal.html wraps its whole script in an IIFE, so nothing inside is global, while onclick="startOidcLogin()" resolves against the global scope only. The file exports every other inline handler explicitly - window.pAction, window.pConsole, window.closeModal and thirteen more - and startOidcLogin was left out. I diffed the full list: 17 inline handlers, 18 exports, and yours is the only one missing. So it's one forgotten line, not a broken feature.

Both are ours. I'm not going to touch the auth side myself though - OIDC is Nico's area by agreement here, and the first one changes what an endpoint returns, which deserves his eyes rather than mine. Assigned to him with the detail above. No date from me.

Thanks for chasing it that far, the console error saved a lot of guessing. If PegaProx is useful to you, https://opencollective.com/pegaprox is open.

Marcus

mkellermann97 avatar Sep 17 '26 07:09 mkellermann97

Both halves are done now. The button not working (startOidcLogin) was fixed in 1.3.0, and on Testing the portal reads the SSO setting from the public OIDC config instead of auth/check, so the button stays there while you're signed in to the main window; that comes with the next release. Also new: a portal-only account that opens / is sent to /portal instead of being signed out.

mkellermann97 avatar Oct 25 '26 15:10 mkellermann97