question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to add JSESSIONID cookie?

See original GitHub issue

springfox 2.6.1

I used ApiKey but not found cookie configuration.

@Configuration
@EnableSwagger2
public class ApiSwaggerConfig {

    @Autowired
    private Environment environment;

    @Bean
    public Docket api() {

        Set<String> protocols = new HashSet<>();
        protocols.add(environment.getProperty("swagger.protocol"));

        Set<String> producesList = new HashSet<>();
        producesList.add("application/json");

        return new Docket(DocumentationType.SWAGGER_2)
                .select()
//                .apis(RequestHandlerSelectors.basePackage("com.jakduk.restcontroller"))
                    .paths(PathSelectors.ant("/api/**"))
                .build()
                .protocols(protocols)
                .host(environment.getProperty("swagger.host"))
                .apiInfo(apiInfo())
                .useDefaultResponseMessages(false)
                .securitySchemes(Collections.singletonList(apiKey()))
                .produces(producesList);
    }

    @Bean
    SecurityConfiguration security() {
        return new SecurityConfiguration(
                "test-app-client-id",
                "test-app-client-secret",
                "test-app-realm",
                "test-app",
                "",
                ApiKeyVehicle.HEADER,
                "api_key",
                "," /*scope separator*/);
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("JakduK REST API with Swagger")
                .contact(new Contact("pio.", "https://jakduk.com", "phjang1983@daum.net"))
                .license("The MIT License (MIT)")
                .licenseUrl("https://github.com/JakduK/jakduk-api/blob/master/LICENSE")
                .build();
    }

    private ApiKey apiKey() {
        return new ApiKey("JSESSIONID", "api_key", "cookie");
    }
}

I want add cookie value.

curl -X GET --header 'Accept: application/json' -H "Cookie: JSESSIONID=136B750B08DA826CE5EA28261E47E135" 'http://localhost:8080/api/auth/user/attempt'

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:4
  • Comments:17 (4 by maintainers)

github_iconTop GitHub Comments

12reactions
dilipkrishcommented, Apr 28, 2018

When 3.0 of springfox is released… there isnt a planned date yet for it

6reactions
vrustia-owenscommented, Aug 1, 2018

any updates on this? really need this one.

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - setting Cookie: JSESSIONID on client request manually
problem is when the httpRequest gets to the server the "Cookie: JSESSIONID" header is there, session id is there; but the request.getSession( ...
Read more >
Setting the Secure and HTTPOnly flags on the JSESSIONID ...
To set the Secure flag on the JSESSIONID cookie: Go to the Session management panel below and make sure the option "Restrict cookies...
Read more >
Using HTTP cookies - MDN Web Docs
After receiving an HTTP request, a server can send one or more Set-Cookie headers with the response. The browser usually stores the cookie...
Read more >
How to change the Path attribute of the JSESSIONID cookie
The Path attribute of the JSESSIONID cookie can be changed within the web.xml for the webapp (e.g. <PASOE_instance>\webapps\MyApp\WEB-INF\web.
Read more >
Handling Cookies and a Session in a Java Servlet - Baeldung
2.1. Create a Cookie · 2.2. Set the Cookie Expiration Date · 2.3. Set the Cookie Domain · 2.4. Set the Cookie Path...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found