Skip to content

Conversation

@bickelj
Copy link
Contributor

@bickelj bickelj commented Sep 16, 2025

To allow Keycloak logout from the OpenAPI documentation, this uses an OpenAPI plugin as a separate module. The reason for clean separation is inclusion of the "dom" module, which has no place in the node project except to be added to the swagger-ui browser code. Without this change, the logout only applies to the OpenAPI docs page and the PDC Keycloak session would remain. With this change, the logout really logs out of PDC Keycloak entirely.

Resolves #1915

@codecov
Copy link

codecov bot commented Sep 16, 2025

Codecov Report

❌ Patch coverage is 8.33333% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.78%. Comparing base (7cbf883) to head (d5efa6b).

Files with missing lines Patch % Lines
src/openapi/plugins/logout.ts 0.00% 11 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1935      +/-   ##
==========================================
- Coverage   93.06%   92.78%   -0.29%     
==========================================
  Files         304      305       +1     
  Lines        3534     3546      +12     
  Branches      505      524      +19     
==========================================
+ Hits         3289     3290       +1     
- Misses        245      256      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bickelj bickelj changed the title 1915 openapi single logout WIP Single logout/signout from OpenAPI docs Sep 16, 2025
@bickelj bickelj force-pushed the 1915-openapi-single-logout branch from f9ecac9 to 6909cfe Compare October 24, 2025 15:56
@bickelj
Copy link
Contributor Author

bickelj commented Oct 24, 2025

Argh:

sdk$ ./gradlew generateSwaggerCode
Starting a Gradle Daemon (subsequent builds will be faster)

> Task :generateSwaggerCodeTypescript FAILED
Exception in thread "main" org.openapitools.codegen.SpecValidationException: There were issues with the specification. The option can be disabled via validateSpec (Maven/Gradle) or --skip-validate-spec (CLI).
 | Error count: 1, Warning count: 2
Errors: 
        -attribute components.securitySchemes.auth.logoutUrl is unexpected
Warnings: 
        -attribute components.securitySchemes.auth.logoutUrl is unexpected

        at org.openapitools.codegen.config.CodegenConfigurator.toContext(CodegenConfigurator.java:717)
        at org.openapitools.codegen.config.CodegenConfigurator.toClientOptInput(CodegenConfigurator.java:744)
        at org.openapitools.codegen.cmd.Generate.execute(Generate.java:527)
        at org.openapitools.codegen.cmd.OpenApiGeneratorCommand.run(OpenApiGeneratorCommand.java:32)
        at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:66)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':generateSwaggerCodeTypescript'.
> Process 'command '/usr/lib/jvm/java-17-openjdk-amd64/bin/java'' finished with non-zero exit value 1

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 9s
4 actionable tasks: 3 executed, 1 up-to-date

@bickelj bickelj force-pushed the 1915-openapi-single-logout branch from 6909cfe to 8c9eea0 Compare October 24, 2025 16:07
@bickelj bickelj changed the title WIP Single logout/signout from OpenAPI docs Single logout via a small Swagger-UI plugin Oct 24, 2025
@bickelj bickelj force-pushed the 1915-openapi-single-logout branch from 8c9eea0 to f866b59 Compare October 27, 2025 16:50
@bickelj
Copy link
Contributor Author

bickelj commented Oct 27, 2025

This push incorporates an acceptable extension to the security schema prefixed with x- as described at https://swagger.io/docs/specification/v3_0/openapi-extensions/. Should pass sdk build and it does. No need for disabling lint rules in this one. It still has the mini plugin, though.

To allow Keycloak logout from the OpenAPI documentation, this uses an
OpenAPI plugin as a separate module. The reason for clean separation
is inclusion of the "dom" module, which has no place in the node
project except to be added to the `swagger-ui` browser code. Without
this change, the logout only applies to the OpenAPI docs page and the
PDC Keycloak session would remain. With this change, the logout really
logs out of PDC Keycloak entirely.

Issue #1915 Single logout from OpenAPI docs
@bickelj bickelj force-pushed the 1915-openapi-single-logout branch from f866b59 to d5efa6b Compare October 27, 2025 16:54
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Most changes here are due to the fully built OpenAPI plugin becoming a dependency of the main codebase.

@bickelj
Copy link
Contributor Author

bickelj commented Oct 27, 2025

Adding a test requires adding a new jest config with jsdom.

@bickelj bickelj requested a review from slifty October 27, 2025 17:20
@bickelj bickelj marked this pull request as ready for review October 27, 2025 17:20
@bickelj
Copy link
Contributor Author

bickelj commented Oct 28, 2025

@slifty While adapting the back-end codebase for essentially front-end code, I wonder if this would be a better fit as a front-end module. Or does the front-end assume too much about its modules?

@bickelj bickelj added this to Phase 6 Oct 28, 2025
@bickelj bickelj removed this from Phase 6 Oct 28, 2025
@slifty
Copy link
Member

slifty commented Nov 18, 2025

@bickelj did we end up moving this to it's own plugin outside of github?

@bickelj
Copy link
Contributor Author

bickelj commented Nov 20, 2025

@slifty I left off at https://code.librehq.com/ots/swagger-ui-logout/-/tree/initial-project-setup?ref_type=heads - making an automated test seems disproportionately difficult for such a common operation (a window.location.href redirect).

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.

Single logout from OpenAPI docs

3 participants