nkviw18
Im new to spring and want to know if there is a way to allow specific backend endpoints to be called without being authenticated? For an example allow the GET List of Cars endpoint but for Editing or Creating, would need to be authenticated.
nkviw18
Im new to spring and want to know if there is a way to allow specific backend endpoints to be called without being authenticated? For an example allow the GET List of Cars endpoint but for Editing or Creating, would need to be authenticated.
Junior Osho
what would a combobox look like if it had a relationship?
import { Lancamento } from ‘./lancamento.model’;
Export class Employee {
EmpId: string;
EmpName: string;
DateOfBirth: Date;
EmailId: string;
Gender: string;
Address: string;
PinCode: string;
public lancamentos?: Lancamento,
}
Matt Raible
The answer to this question is outside the scope of this blog post. I’d recommend you checkout my JHipster 5 demo project for an example. It has a UI that contains drop-downs and entities with relationships between them.
Matt Raible
You should be able to use Spring Security’s configuration to enable this. For example:
http.authorizeRequests().antMatchers("/cars*").permitAll();
Matt Raible
My guess is you’re missing some properties. You might also try the latest version of our starter.
gora joop
Hello Matt,
Thank you for your article, very help full.
On my side i only make your application function when i switch the @EnableReseourceServer for @EnableOAuth2Sso in DemoApplication.java.
Here is the error i was getting in the browser console
ERROR HttpErrorResponse {headers: HttpHeaders, status: 401, statusText: “OK”, url: “http://localhost:8080/cool-cars”, ok: false, …}
When using @EnableReseourceServer the accessToken is read from the org.springframework.security.oauth2.provider.token.store.InMemoryTokenStore which is empty, with the @EnableOAuth2Sso ehe accessToken is read from the org.springframework.security.oauth2.provider.token.store.jwk.JwkTokenStore.
Is there something missing in the configuration on my side?
Yeming Huang
Yo Matt thanks for the guide.
If it’s not already mentioned. I suggest changing
getAll(): Observable<any> {
return this.http.get(’//localhost:8080/cool-cars’);
}
to
getAll(): Observable<any> {
return this.http.get(’//’ + window.location.hostname + ‘:5000/cool-cars’);
}
Or you will have to put up the ‘It works on my machine’ excuse all the time.
Matt Raible
If you use the same versions I used in this example, you shouldn’t have any issues. Can you try comparing your code to the example code on GitHub?
Matt Raible
Thanks for the tip!
Thuan Nguyen
have you solved this? i got the same error as you mentioned. plz help
Matt Raible
What are you using for your “issuer” and “clientId” values?
Thuan Nguyen
i’m using the issuer as “https://xxx.okta.com/oauth2…” and clientid as “0oajse877fMAGKWvUxxx”. when i make a request with the Authorization header, it returns with the error "Bearer error=“invalid_token”, error_description=“An error occurred while attempting to decode the Jwt: Couldn’t retrieve remote JWK set: org.springframework.web.client.HttpClientErrorException$Forbidden: 403 Forbidden”, error_uri=“https://tools.ietf.org/html…”
Matt Raible
Is your Spring Boot server behind a firewall or proxy? It seems like your values are correct. The only other thing I can think of is the values in your Spring Boot app’s application.yml
don’t match what’s in your Angular client.
Thuan Nguyen
just figure out that i’am using the okta-spring-boot@1.1.0 and spring-boot@2.1.4. I changes it back to your version and it works. thank you so much for your time
Enrique C.F.
Hello, I tried to insert the giphy images, but all time I have the same response. I was here: https://developer.okta.com/… And I had this problem:
https://uploads.disquscdn.c…
Any idea?
Matt Raible
I saw this myself when creating the latest version of this tutorial: Angular 8 + Spring Boot 2.2: Build a CRUD App Today!
You now need to create your own API key for GIPHY.
abhiram s
Hi Matt- Tried to execute above code in my local (Only spring boot session) and getting below error log in console:
2019-06-13 12:13:02.823 WARN 12012 — [main] ConfigServletWebServerApplicationContext :Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘init’ defined in com.poc.demo.DemoApplication: Unsatisfied dependency expressed through method ‘init’ parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘com.poc.repositories.UserRepository’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
--------------------------------------------------
Description:
Parameter 0 of method init in com.poc.demo.DemoApplication required a bean of type ‘com.poc.repositories.UserRepository’ that could not be found.
-----------------------------------------------------
Action:
Consider defining a bean of type ‘com.poc.repositories.UserRepository’ in your configuration.
Could you please help me here. Thank you.
Matt Raible
That’s a strange error since there’s no UserRepository in this tutorial. Can you compare your code with the example on GitHub and see if you can spot where the problem is? https://github.com/oktadeve…
abhiram s
Thanks for reply Matt. Instead of carRepository, i made UserRepository and extends CrudRepository as below. Also, I used @Repository annotation here. Please correct me if i can follow this way.
@Repository
public interface UserRepository extends CrudRepository<user, long=""> {
}
Matt Raible
It’s difficult for me to help you if you’re not using the same code as this tutorial. Your issue seems to be more of a generic Spring question. Make sure your UserRepository is in a class that’s being scanned by Spring. If that doesn’t work, can you create a GitHub repo and publish your code to it?