Skip to content

client can be redirected to the login page without being required to provide the credentials from the server. #10387

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,43 @@
<div id="swagger-ui"></div>
<script src="./swagger-ui-bundle.js" charset="UTF-8"> </script>
<script src="./swagger-ui-standalone-preset.js" charset="UTF-8"> </script>
<script src="./swagger-initializer.js" charset="UTF-8"> </script>
<script src="./swagger-initializer.js" charset="UTF-8">

const oidcConfig = {
clientId: "your-client-id",
discoveryUrl: "https://your-auth-server/.well-known/openid-configuration",
oauth2RedirectUrl: window.location.origin + "/oauth2-redirect.html"
};

window.onload = function () {

const ui = SwaggerUIBundle({
url: "/path/to/openapi.yaml", // Make sure this points to your OpenAPI spec
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
layout: "StandaloneLayout",

oauth2RedirectUrl: window.location.origin + "/oauth2-redirect.html", // OAuth2 redirect URL

// OAuth2 authentication configuration
oauth2: {
clientId: "YOUR_CLIENT_ID", // Replace with actual client ID
clientSecret: "YOUR_CLIENT_SECRET", // Optional, only needed for some flows

Choose a reason for hiding this comment

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

I would delete this line of code. It's bad practice to expose client secrets on a HTML/JS page that can everybody read. Use a public OIDC client configuration only which doesnt require a client secret.

authorizationUrl: "https://your-oidc-provider.com/oauth/authorize", // OIDC authorization URL
tokenUrl: "https://your-oidc-provider.com/oauth/token", // Token endpoint
scopes: ["openid", "profile", "email"], // Specify the required scopes
flow: "implicit", // Use implicit flow for OAuth2/OIDC
}
});

};

</script>


</body>
</html>