Skip to content
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

Pass basic auth parameter to task #134

Closed
vonWojtas opened this issue Nov 17, 2023 · 5 comments
Closed

Pass basic auth parameter to task #134

vonWojtas opened this issue Nov 17, 2023 · 5 comments

Comments

@vonWojtas
Copy link

Hey !

I would like to know your best practice for following scenario:

The swagger endpoint is protected with basic auth.
How could I pass username and password for the task to access the open api docs?

Or should I re-configure my setup?

I have a Spring Boot 3, Kotlin, regular WebMVC application and want to generate docs.

Thank you very much in advance for any possible help :)

@Donquih0te
Copy link

I guess there is currently no way to specify the authentication type and credentials.

val connection: HttpURLConnection =
URL(url).openConnection() as HttpURLConnection
connection.requestMethod = "GET"
connection.connect()

@vonWojtas
Copy link
Author

mhm. do you have an idea how I could do it easily anyways? 🤔

@JiangHongTiao
Copy link

JiangHongTiao commented Nov 29, 2023

With current implementation, it's not possible. What you can do is to create a PR, where you add a new plugin parameter: headers as map of key-values. Then you set those headers into connection request:

val connection: HttpURLConnection =
	URL(url).openConnection() as HttpURLConnection
connection.requestMethod = "GET"
headers.forEach { connection.setRequestProperty(it.key, it.value) }
connection.connect()

To test this out I believe you can create a test endpoint which will serialise all request headers and will return them. Then you can validate that all headers are present.

@japzio
Copy link

japzio commented May 3, 2024

Hi @vonWojtas @JiangHongTiao I have an open PR #144 , might also apply to this use-case

cc @bnasslahsen

@bnasslahsen
Copy link
Contributor

#144 should resolve this issue.

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

No branches or pull requests

5 participants