Skip to content

Conversation

@MikeNeilson
Copy link
Contributor

@MikeNeilson MikeNeilson commented Oct 15, 2025

Fixes #1356.

Definitely still needs work (should only try the initOAuth if an OAuth based security scheme is actually present, but it gets the idea across.

Unfortunately, at least using the default Swagger Authentication system, I don't think I can do what I wanted where one, in the auth button, could have a login that would automatically work and pass the additional required query parameter. The SwaggerUI code simply doesn't do anything with extension values provided in the scheme.

However, that really only affects the SwaggerUI not usages of the application itself. So I'm inclined not to worry about it and will strip of some of the extra elements I added to the code.

Good news is, does pre-populate the client id, and the login flow behaves correctly; I was redirected to the local docker-compose keycloak and saw the kc_idp_hint field on the request so in environment should behave the same.

@MikeNeilson MikeNeilson requested a review from krowvin October 15, 2025 19:30
@MikeNeilson
Copy link
Contributor Author

@krowvin Perhaps it would make more sense to just integrate the groundwater login dialog instead of relying on the Swagger UI system? I'm fairly certain it's not difficult to do; should be able to hook into the internal auth bits that fill in those details.

@MikeNeilson MikeNeilson force-pushed the feature/1356-openid-configuration branch from d3c1058 to c0d9242 Compare October 22, 2025 21:29
@MikeNeilson
Copy link
Contributor Author

Now includes client_id value within an extension field. Considering

  1. In the Swagger-UI we have to tell users what it is
  2. Anyone with developer tools, or possibly even just eyeballs on an address bar, can see it
    Thus this is not secret information and we should just provide it.

krowvin
krowvin previously approved these changes Oct 23, 2025
Copy link
Collaborator

@krowvin krowvin left a comment

Choose a reason for hiding this comment

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

Up to you if you want to change these things. Tossing info out there!

(There's CI/CD you can setup to remove console logs... before prod)

},
onComplete: () => {
const spec = JSON.parse(ui.spec().get("spec"));
console.log(JSON.stringify(spec.components.securitySchemes));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove the logs if you are ready for prime time!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Still draft, just push that change up before lunch in case the computer crashed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The log statements should be gone now.

// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
// const env = loadEnv(mode, process.cwd(), "");
const env = loadEnv(mode, process.cwd(), "");
Copy link
Collaborator

@krowvin krowvin Oct 23, 2025

Choose a reason for hiding this comment

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

This works with Node, but you should also see

https://vite.dev/guide/env-and-mode

i.e.

const CUSTOM_VAR = import.meta.env.VITE_CUSTOM_VAR

Where you prefix with VITE_ to avoid accidental env var injection.. from your .env files

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, was wondering why that that was comment out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

well, that doesn't actually work within the vite.config.js

@MikeNeilson MikeNeilson marked this pull request as ready for review October 23, 2025 20:46
@MikeNeilson
Copy link
Contributor Author

Okay, now it's ready. Once it deploys to -dev you should be able to use the very first OIDC option ("Code") and not have to know the client id and get forwarded through the various identity provides and otherwise login as usual.

@krowvin
Copy link
Collaborator

krowvin commented Oct 23, 2025

Should be able to use the very first OIDC option

Confirming the user still clicks the green Authorize button, then selected the option in there?

Then later we might add a Login button somewhere that could also tie into that?

I imagine SwaggerUI (constructor) has a callback we can use to setup a Login button. Let me know if you want me to look into that first before trying to setup the GWW login methods. (It only supports direct-login right now afaik)

@MikeNeilson
Copy link
Contributor Author

Should be able to use the very first OIDC option

Confirming the user still clicks the green Authorize button, then selected the option in there?

Then later we might add a Login button somewhere that could also tie into that?

I imagine SwaggerUI (constructor) has a callback we can use to setup a Login button. Let me know if you want me to look into that first before trying to setup the GWW login methods. (It only supports direct-login right now afaik)

Correct, other than not needing to already know the client id, and being able to choose the first option, the user side flow is the same. (They will get redirected to the auth server, but people should be used to that by now in general.)

@MikeNeilson MikeNeilson force-pushed the feature/1356-openid-configuration branch from 9879386 to bd274af Compare October 29, 2025 14:39
@MikeNeilson
Copy link
Contributor Author

@jbkolze @oskarhurst @krowvin FYI, keycloak login in -dev is currently broken due to the cache buster code sending unknown parameters to the keycloak instance which then intentionally fails since it doesn't like unknown query parameters.

Somebody give this a look when you have time. There will likely be improvements to the SecurityScheme extension in a follow up, like providing a link to a graphic. Work on opendcs/rest_api#574 is informing that. (Plan to share the extension design since... why not, same need.)

@MikeNeilson MikeNeilson force-pushed the feature/1356-openid-configuration branch from bd274af to 25c1edf Compare November 26, 2025 16:29
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.

Modify OpenID configuration settings to process and allow an x-kc_idp_hint field

3 participants