Comments (11)
Hi
I think I had a similar issue with an older spring-security version. What version of spring and spring-security do you use?
from blog.
Thanks for the quick response, so taking a look the versions are:
Spring: 5.0.5.RELEASE
Spring Boot: 2.0.1.RELEASE
Spring Security Core: 5.0.4.RELEASE
from blog.
Same I use for my demo.
Have you added the cors()
configuration in the security config
http
.cors() // <---------
.and()
from blog.
I have indeed I have the same setup for the server you have in the repo, in the security config:
protected void configure(HttpSecurity http) throws Exception {
http
.csrf().disable()
.cors().and()
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
// .httpBasic().and() //optional, if the service wants to be accessed via the browser
.authorizeRequests()
// endPoint configuration requiring authorization
.antMatchers("/signup").permitAll()
.antMatchers("/login").permitAll()
.antMatchers("/public").permitAll()
.anyRequest().authenticated().and()
.apply(new JWTConfigurer(this.tokenProvider));
}
from blog.
Is there also a @CrossOrigin
annotation on the Controller class where the /login mapping is located?
@RestController
@CrossOrigin
public class AuthController {
@PostMapping("/login")
public String authorize(@Valid @RequestBody User loginUser,
HttpServletResponse response) {
.....
}
}
from blog.
Indeed I have, I have uploaded my current server code in a repo on (https://github.com/iranicus/JWT_attempt) if you could take a ganders pls :>
from blog.
I will look tomorrow.
One quick thing you could try is to remove
spring.mvc.dispatch-options-request=true
in your application.properties file.
from blog.
Will do that was just added as part of a potential CORS fix, just removed it now but unfortunately no change.
from blog.
I have just tested my application and it works. I will try your project tomorrow.
from blog.
It works when you remove
//@ComponentScan({ "com.rdanby.jwt.security.jwt" })
on the JwtApplication class. This annotation only configures beans in the com.rdanby.jwt.security.jwt package and skips everything else
and add @component on the TokenProvider, because the application needs to inject this bean into other beans.
@Component
public class TokenProvider {
from blog.
Just added this now and it has fixed the issue, thanks loads. There is another issue I have ran into however with the /secret and /authenticate api calls which I'll bring up as a different issue.
from blog.
Related Issues (20)
- Runtime error -> jwt (Spring) HOT 2
- readAsArrayBuffer Not Supported HOT 1
- The example does not work HOT 1
- /secret and /authenticate routes returning 403 HOT 2
- Throws error HOT 1
- sw-push not works HOT 1
- sw-push , Error creating bean with name 'registryController'... HOT 8
- sw-push, can you tell me messagingSenderId and gcm_sender_id are the same? HOT 14
- [ionic] ts error: FileEntry not found HOT 9
- JWT Authentification: check username HOT 4
- console.log(reader.result ) is {} HOT 5
- [Ionic-4] - no longer working for me HOT 7
- Getting error in polyfills.js line 3 - calls to REST services are showing status as canceled HOT 1
- Runtime Error after building the app in Ionic 4 HOT 2
- Check if file is uploaded HOT 4
- Crop image before upload it HOT 1
- POST http://localhost:8080/clienterror net::ERR_CONNECTION_REFUSED HOT 8
- hotcodepush app on Ionic 4 fails to load the updates HOT 9
- uploaded Image not rendered directly on screen HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blog.