How to expose Swagger UI without authentication? - java

I'm trying to make the SwaggerUi interface not ask for authorization every time I boot.
I tried to enter in my Configure class:
.authorizeRequests().antMatchers("/actuator/**","/mypath/**").permitAll()
and
.authorizeRequests().antMatchers("/mypath/**").permitAll()
but without success.
Actuator on the other hand works fine without authorization with this code structure
Thanks everyone for a possible answer!

The basic problem is that even in the Sprinc-doc documentation they put you the case that you entered too. In order to make the code work you have to enter multiple permissions, one for each path. In your case it will have to be something like this:
.authorizeRequests().antMatchers("/actuator/**","/v2/**","/mypath/**","/swagger.yml","/anypath/").permitAll()

Try this:
.authorizeRequests().antMatchers("/swagger-ui/**").permitAll()
Then just go here:
http://localhost:[YOUR PORT]/swagger-ui/
p.s Don't forget the / at the end of the URL :)

Related

JAX-RS #Path with allowed slashes collide with other resources

I am trying to allow slashes in my Path:
#Path("/user/{login}/points")
by using this solution so it becomes:
#Path("/user/{login : .+}/points")
but it will not work anytime a user names their account e.g
test/points
because only "test" will be passed. It works fine with test/test or any other login not ending with /points.
I have no idea how should I solve this. I need it as String param and it's set by user.
Thanks for any help!
Looks like I found the solution myself with a little help of #YCF_L (sadly he deleted his comment).
Solution:
#Path("/user/{login : .+(?=\\/points)}")

Microstrategy URL API

Reading from this link, link, link, link, link and this SO answer about Microstrategy URL API, I want to pass the answer to one or more prompts in the request to that the report document is executed automatically without requiring the user to enter information.
When I tried to use valuePromptAnswer method for multiple prompt, Microstrategy only take the first argument. The other argument doensn't works. Here are the URL
http://111.222.333.444/MicroStrategy/servlet/mstrWeb?Server=******&Project=*****&Port=0&evt=4001&src=mstrWeb.4001&reportID=226F3C76422512B0E56995939C230DF1&visMode=0&reportViewMode=1&valuePromptAnswers=12^11
The microstrategy only takes the first argument.
Using elementsPromptAnswers generate the same result, only the first prompt receive the value
http://111.222.333.444/MicroStrategy/servlet/mstrWeb?Server=****&Project=***&Port=0&evt=4001&src=mstrWeb.4001&reportID=226F3C76422512B0E56995939C230DF1&visMode=0&reportViewMode=1&elementsPromptAnswers=F9365CA24CFDFD394F3D01ACB4EA5F21:1;474209F94C5C6140979F31848D01E40F:2
Using objectPromptAnswer generate the same result
http://111.222.333.444/MicroStrategy/servlet/mstrWeb?Server=****&Project=****&Port=0&evt=4001&src=mstrWeb.4001&reportID=226F3C76422512B0E56995939C230DF1&visMode=0&reportViewMode=1&objectsPromptAnswers=474209F94C5C6140979F31848D01E40F~12~DistChl
I've read the documentation carefully for each step by step. What I'm missed out? Is there any configuration on server side to accept all argument / parameters?
Thanks in advance.
We had did the thing you talk about using the next url:
mstrWeb?port=0&evt=2048001&src=mstrWeb.2048001&documentID=YOURDOCUMENTID&valuePromptAnswers={&Prompt1&}^{&Prompt2&}^{&Prompt3&}^{&Prompt4&}^{&Prompt5&}^{&Prompt6&}&promptAnswerMode=2
In the previous example, {&Prompt1&}, {&Prompt2&}, etc. are responses of a previous prompt. In your case, the url to create should be the next url:
mstrWeb?port=0&evt=2048001&src=mstrWeb.2048001&documentID=226F3C76422512B0E56995939C230DF1&valuePromptAnswers=12^11&promptAnswerMode=2
I think that your problem could be on the evt or promptAnswerMode parameters, because if these are not correctly configured it can get in troubles.
Hope that this answer solves your problem.
Greetings.

Ng file upload - url JAVA SPRING

I have quick and relatively easy question I think, but I don't get it so here I am.
So, I've got something like this:
file.upload = Upload.upload({
url: 'sendemail',
data: {file: file}
});
Whatever about rest of the code. I want to know for what is that url: section. It's for my java spring #RequestMapping("/sendemail")? Or it is for folder on my server to store the file?
Please answer me, I just want to know it :<
So when you are using Java Spring. It provides you a lots of cool annotations.
One of them is
#RequestMapping()
This annotation helps for routing your services. So when you write RequestMapping("/sendemail"), it looks for the end point sendemail and does the job accordingly.
Now to your question,
So {url: 'sendemail'} specifies that the url should end with /sendemail so as to do the mentioned job.

How to hit the rest endpoint that has `:.*` as a part of the path param field

I am using the Stash's REST API in my project. My task is to get the tag details for a specific tag. After checking the Stash's REST API documentation, I found the correct endpoint that I should be using. It is
/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/tags/{name:.*}
Please see this link for the Stash's REST API documentation.
There is one more endpoint /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/tags
With this endpoint I am able to retrieve all the tags. The StashTag object looks something like this.
{
"id": "refs/tags/v4.0.0",
"displayId": "v4.0.0",
"latestChangeset": "234dadf41742cfc2a10cadc7c2364438bd8891c5",
"latestCommit": "234dadf41742cfc2a10cadc7c2278658bd8891c5"
"hash" : "null"
}
My first problem is, I don't know which field to use as the parameter for {name:.*}. Should it be the displayId or Id or anything else.
The second problem is, I don't understand what it means to have : (colon) followed by a . (dot) in the endpoint /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/tags/{name:.*}.
Can someone explain me what is the purpose of :. in the path param and how to hit this kind of an endpoint. Also an example of the complete endpoint would be nice.
So far I have tried hitting
https://stashtest.abc.com/rest/api/1.0/projects/KARTIK/repos/kartiks-test-repository/tags/v4.0.0
https://stashtest.abc.com/rest/api/1.0/projects/KARTIK/repos/kartiks-test-repository/tags/refs/tags/v4.0.0
None of these endpoints work.
Any help is appreciated.
The {name:.*} is really just saying that the field name can be anything. Chalk this one up to poor documentation on their part. Think of it like Regex field, because that's exactly what it is. I'm sure at one point they had something like ^[0-9] then went back and changed it when they realized using only tag numbers would omit anyone using their lightweight tag features.
Remove the v from your tag version and see if that helps. If it does not, I would also recommend creating a lightweight tag (something like mytag) and seeing if you can hit it that way (i.e., /kartiks-test-repository/tags/mytag).
But looking at that documentation is telling me that your v in your tag name is throwing off the REST call.

OCPsoft Rewrite Rule no longer works after Update from 1.0.5 to 1.1.0

When updating OCPsoft Rewrite from Version 1.0.5.Final to 1.1.0.Final the following Rule no longer works and I don't know how to fix it:
.addRule(
Join.path("/{i}/{d}")
.where("i").matches("[-_a-zA-Z0-9~*]{8}")
.where("d").matches("[-_a-zA-Z0-9~*]{32}")
.to("/resources/html/user/doSomething.html?i={i}&d={d}")
)
In the Rewrite changelog there is one point that could help you help me:
Configuration strings are now literal. Regular expressions must be configured through a >parameter such as: .defineRule().when(Path.matches("/{*}").where("*").matches(".*"))
The exception I get is the following one:
Exception starting filter OCPsoft Rewrite Filter
java.lang.NullPointerException
at org.ocpsoft.rewrite.servlet.config.rule.Join.where(Join.java:199)
at org.ocpsoft.rewrite.servlet.config.rule.Join.where(Join.java:47)
at com.myapp.util.RewriteConfigurationProvider.getConfiguration(RewriteConfigurationProvider.java:39)
...
The following did the trick, I just had to reorder the join clauses:
.addRule(
Join.path("/{i}/{d}")
.to("/resources/html/user/doSomething.html")
.where("i").matches("[-_a-zA-Z0-9~*]{8}")
.where("d").matches("[-_a-zA-Z0-9~*]{32}")
.withRequestBinding();
)
Thanks to Lincoln, who figured this out and answered my question on the Rewrite support forums.
Hmm.. that does look like a bug, I'll try to reproduce this, but you shouldn't need to re-define {i} and {d} in the target URL. Join will handle that for you automatically if you use request binding, like so:
.addRule(
Join.path("/{i}/{d}")
.where("i").matches("[-_a-zA-Z0-9~*]{8}")
.where("d").matches("[-_a-zA-Z0-9~*]{32}")
.to("/resources/html/user/doSomething.html").withRequestBinding();
)
I'm guessing if you do that, your problem will go away. You can also use .withInboundCorrection() if you'd like to redirect requests for the old .html URL to the new URL.
If you still have a problem with this, please post on the support forums and we'll get it figured out :)
Sorry you had trouble, hopefully it won't be trouble any more :)

Categories

Resources