spring-attic / springbox-cloud Goto Github PK
View Code? Open in Web Editor NEWSpring Cloud Reference Application
License: Apache License 2.0
Spring Cloud Reference Application
License: Apache License 2.0
https://github.com/mstine/springbox-cloud/blob/master/springbox-api-gateway/src/main/java/io/springbox/apigateway/services/recommendations/RecommendationsIntegrationService.java#L41 is trying to determine if the current userName
"likes" the movie in question.
The associated endpoint in springbox-recommendations
will be secured based on #2.
According to Syer, you should be able to inject an OAuth2RestOperations
and that will pass on the current token. However, I'm not sure if that will also have the RibbonInterceptor
, so we may need to do the Ribbon lookup manually.
Resolving this issue should determine what will work and implement it.
Hello when i start all services and then run script there is error :
./loadReviews.sh
{"error":"unauthorized","error_description":"Full authentication is required to access this resource"}{"error":"unauthorized","error_description":"Full authentication is required to access this resource"}{"error":"unauthorized","error_description":"Full authentication is required to access this resource"}{"error":"unauthorized","error_description":"Full authentication is required to access this resource"}{"error":"unauthorized","error_description":"Full authentication is required to access this resource"}{"error":"unauthorized","error_description":"Full authentication is required to access this resource"}{"error":"unauthorized","error_description":"Full authentication is required to access this resource"}{"error":"unauthorized","error_description":"Full authentication is required to access this resource"}
I'm running maven 3.3.3, jdk1.8 on my centos7 (x86_64). This is failing in tests. Not sure if this is critical but anyone knows what I'm missing here?
Thanks
[INFO] Final Memory: 38M/504M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.17:test (default-test) on project springbox-recommendations: There are test failures.
[ERROR]
[ERROR] Please refer to /root/spring-cloud-samples/springbox-cloud/springbox-recommendations/target/surefire-reports for the individual test results.
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.17:test (default-test) on project springbox-recommendations: There are test failures.
Please refer to /root/spring-cloud-samples/springbox-cloud/springbox-recommendations/target/surefire-reports for the individual test results.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
total 596
drwxr-xr-x. 2 root root 4096 Jul 14 06:57 ./
drwxr-xr-x. 9 root root 4096 Jul 14 07:00 ../
-rw-r--r--. 1 root root 213001 Jul 14 07:00 io.springbox.recommendations.SpringboxRecommendationsApplicationTests.txt
-rw-r--r--. 1 root root 382215 Jul 14 07:00 TEST-io.springbox.recommendations.SpringboxRecommendationsApplicationTests.xml
...skipping...
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoFailureException: There are test failures.
Please refer to /root/spring-cloud-samples/springbox-cloud/springbox-recommendations/target/surefire-reports for the individual test results.
at org.apache.maven.plugin.surefire.SurefireHelper.reportExecution(SurefireHelper.java:82)
at org.apache.maven.plugin.surefire.SurefirePlugin.handleSummary(SurefirePlugin.java:195)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:861)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:729)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 20 more
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn -rf :springbox-recommendations
Four controllers:
RecommendationsController
:
/recommendations/{userName}/likes/{mlId}
- OAUTH2 SECURED/recommendations/forUser/{userName}
- OPEN (eventually secure to just that user)/recommendations/forMovie/{mlId}
- OPENPersonController
:
/people
- OAUTH2 SECURED (eventually an admin function)MovieController
:
/movie
- OAUTH2 SECURED (eventually an admin function)LikesController
:
/likes
- OPEN (eventually secured to admin)/does/{userName}/like/{mlId}
- OAUTH2 SECURED (eventually secure to just that user)This code is currently in springbox-api-gateway/src/main/resources/static/js/hello.js
.
Should be given a proper name obviously.
Also - I am not a strong JS or Angular developer, so this could use some general love from @scottfrederick.
io.springbox.apigateway.SpringboxApiGatewayApplication
.io.springbox.apigateway.controllers.ApiGatewayController
has one endpoint, GET /movie/{mlId}
, which should be OPEN. However, if a Principal
is present, it will make a call to recommendationsIntegrationService.likes
to determine if this movie is "liked" by the currently logged in user.The io.springbox.reviews.controllers.ReviewController
controller currently has 3 endpoints:
/reviews
/reviews/{mlId}
/reviews
The first two endpoints should be accessible without authentication or authorization. The last endpoint should require a proper OAuth2 token.
Seems that some Oauth beans need to run on the same thread that the caller, this lead to errors bellow. Because methods are ran inside hystrix commands, we don't have access to the original thread.
Need to investigate further:
Error creating bean with name 'scopedTarget.oauth2ClientContext': Scope 'session' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton
java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.
0 = {java.lang.StackTraceElement@11409} "org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:352)"
1 = {java.lang.StackTraceElement@11410} "org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)"
2 = {java.lang.StackTraceElement@11411} "org.springframework.aop.target.SimpleBeanTargetSource.getTarget(SimpleBeanTargetSource.java:35)"
3 = {java.lang.StackTraceElement@11412} "org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:187)"
4 = {java.lang.StackTraceElement@11413} "com.sun.proxy.$Proxy90.getAccessToken(Unknown Source)"
5 = {java.lang.StackTraceElement@11414} "org.springframework.security.oauth2.client.OAuth2RestTemplate.doExecute(OAuth2RestTemplate.java:125)"
6 = {java.lang.StackTraceElement@11415} "org.springframework.web.client.RestTemplate.execute(RestTemplate.java:530)"
7 = {java.lang.StackTraceElement@11416} "org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:476)"
8 = {java.lang.StackTraceElement@11417} "io.springbox.apigateway.services.reviews.ReviewsIntegrationService$1.invoke(ReviewsIntegrationService.java:28)"
9 = {java.lang.StackTraceElement@11418} "sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)"
10 = {java.lang.StackTraceElement@11419} "sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)"
11 = {java.lang.StackTraceElement@11420} "sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)"
12 = {java.lang.StackTraceElement@11421} "java.lang.reflect.Method.invoke(Method.java:483)"
13 = {java.lang.StackTraceElement@11422} "com.netflix.hystrix.contrib.javanica.command.MethodExecutionAction.execute(MethodExecutionAction.java:101)"
14 = {java.lang.StackTraceElement@11423} "com.netflix.hystrix.contrib.javanica.command.MethodExecutionAction.executeWithArgs(MethodExecutionAction.java:80)"
15 = {java.lang.StackTraceElement@11424} "com.netflix.hystrix.contrib.javanica.command.MethodExecutionAction.execute(MethodExecutionAction.java:66)"
16 = {java.lang.StackTraceElement@11425} "com.netflix.hystrix.contrib.javanica.command.GenericCommand$1.execute(GenericCommand.java:45)"
17 = {java.lang.StackTraceElement@11426} "com.netflix.hystrix.contrib.javanica.command.AbstractHystrixCommand.process(AbstractHystrixCommand.java:161)"
18 = {java.lang.StackTraceElement@11427} "com.netflix.hystrix.contrib.javanica.command.GenericCommand.run(GenericCommand.java:42)"
19 = {java.lang.StackTraceElement@11428} "com.netflix.hystrix.HystrixCommand$1.call(HystrixCommand.java:294)"
20 = {java.lang.StackTraceElement@11429} "com.netflix.hystrix.HystrixCommand$1.call(HystrixCommand.java:289)"
21 = {java.lang.StackTraceElement@11430} "rx.Observable$1.call(Observable.java:144)"
22 = {java.lang.StackTraceElement@11431} "rx.Observable$1.call(Observable.java:136)"
23 = {java.lang.StackTraceElement@11432} "rx.Observable$1.call(Observable.java:144)"
24 = {java.lang.StackTraceElement@11433} "rx.Observable$1.call(Observable.java:136)"
25 = {java.lang.StackTraceElement@11434} "rx.Observable$1.call(Observable.java:144)"
26 = {java.lang.StackTraceElement@11435} "rx.Observable$1.call(Observable.java:136)"
27 = {java.lang.StackTraceElement@11436} "rx.Observable.unsafeSubscribe(Observable.java:7466)"
28 = {java.lang.StackTraceElement@11437} "com.netflix.hystrix.AbstractCommand$5.call(AbstractCommand.java:518)"
29 = {java.lang.StackTraceElement@11438} "com.netflix.hystrix.AbstractCommand$5.call(AbstractCommand.java:501)"
30 = {java.lang.StackTraceElement@11439} "rx.Observable.unsafeSubscribe(Observable.java:7466)"
31 = {java.lang.StackTraceElement@11440} "rx.internal.operators.OperatorSubscribeOn$1$1.call(OperatorSubscribeOn.java:62)"
32 = {java.lang.StackTraceElement@11441} "com.netflix.hystrix.strategy.concurrency.HystrixContexSchedulerAction$1.call(HystrixContexSchedulerAction.java:56)"
33 = {java.lang.StackTraceElement@11442} "com.netflix.hystrix.strategy.concurrency.HystrixContexSchedulerAction$1.call(HystrixContexSchedulerAction.java:47)"
34 = {java.lang.StackTraceElement@11443} "com.netflix.hystrix.strategy.concurrency.HystrixContexSchedulerAction.call(HystrixContexSchedulerAction.java:69)"
35 = {java.lang.StackTraceElement@11444} "rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:47)"
36 = {java.lang.StackTraceElement@11445} "java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)"
37 = {java.lang.StackTraceElement@11446} "java.util.concurrent.FutureTask.run(FutureTask.java:266)"
38 = {java.lang.StackTraceElement@11447} "java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)"
39 = {java.lang.StackTraceElement@11448} "java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)"
40 = {java.lang.StackTraceElement@11449} "java.lang.Thread.run(Thread.java:745)"
It would be nice add some database persistence example for OAuth tokens / User details and client credentials. Even using an in-memory DB (H2) it helps us to migrate to a real world scenario.
Hello it will be nice if you add some example how to add turbine and hystrix
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.