commit 9db6c41b372a6b70dc22b21859e1dc3b107de6fd Author: kimscott Date: Mon Sep 2 11:17:18 2019 +0900 init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b93c1ca --- /dev/null +++ b/.gitignore @@ -0,0 +1,45 @@ +/target/ +/bin/ +/.settings/ +*# +*.iml +*.ipr +*.iws +*.jar +*.sw? +*~ +.#* +.*.md.html +.DS_Store +.classpath +.factorypath +.gradle +.idea +.metadata +.project +.recommenders +.settings +.springBeans +/build +/code +MANIFEST.MF +_site/ +activemq-data +bin +build +build.log +dependency-reduced-pom.xml +dump.rdb +interpolated*.xml +lib/ +manifest.yml +overridedb.* +settings.xml +target +transaction-logs +.flattened-pom.xml +secrets.yml +.gradletasknamecache +.sts4-cache +node_modules +.dist/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..26ec245 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,4 @@ +FROM openjdk:8u212-jdk-alpine +COPY target/*SNAPSHOT.jar app.jar +EXPOSE 8080 +ENTRYPOINT ["java","-Xmx400M","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar","--spring.profiles.active=docker"] \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/cloudbuild.yaml b/cloudbuild.yaml new file mode 100644 index 0000000..1eafe33 --- /dev/null +++ b/cloudbuild.yaml @@ -0,0 +1,77 @@ +steps: + ### Build + - id: 'build' + name: 'gcr.io/cloud-builders/docker' + entrypoint: 'bash' + args: + - '-c' + - | + echo '$COMMIT_SHA =' $COMMIT_SHA + docker build -t gcr.io/$PROJECT_ID/$_PROJECT_NAME:$COMMIT_SHA . + ### Test + ### Publish + - id: 'publish' + name: 'gcr.io/cloud-builders/docker' + entrypoint: 'bash' + args: + - '-c' + - | + docker push gcr.io/$PROJECT_ID/$_PROJECT_NAME:$COMMIT_SHA + ### deploy + - id: 'deploy' + name: 'gcr.io/cloud-builders/gcloud' + entrypoint: 'bash' + args: + - '-c' + - | + PROJECT=$$(gcloud config get-value core/project) + gcloud container clusters get-credentials "$${CLOUDSDK_CONTAINER_CLUSTER}" \ + --project "$${PROJECT}" \ + --zone "$${CLOUDSDK_COMPUTE_ZONE}" + + cat < + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.1.1.RELEASE + + + com.example + boot-camp-gateway + 0.0.1-SNAPSHOT + boot-camp-gateway + + + 1.8 + Greenwich.RELEASE + + + + + + org.springframework.boot + spring-boot-actuator + + + org.springframework.cloud + spring-cloud-starter-gateway + + + + + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + pom + import + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + \ No newline at end of file diff --git a/src/main/java/com/example/template/Application.java b/src/main/java/com/example/template/Application.java new file mode 100644 index 0000000..4f9e0e6 --- /dev/null +++ b/src/main/java/com/example/template/Application.java @@ -0,0 +1,18 @@ +package com.example.template; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.ApplicationContext; + +@SpringBootApplication +public class Application { + + public static ApplicationContext applicationContext; + public static void main(String[] args) { + applicationContext = SpringApplication.run(Application.class, args); + } + + +} + + diff --git a/src/main/java/com/example/template/JwkSetEndpointConfiguration.java b/src/main/java/com/example/template/JwkSetEndpointConfiguration.java new file mode 100644 index 0000000..0bdf882 --- /dev/null +++ b/src/main/java/com/example/template/JwkSetEndpointConfiguration.java @@ -0,0 +1,31 @@ +//package com.example.template; +// +//import com.nimbusds.jose.jwk.JWKSet; +//import com.nimbusds.jose.jwk.RSAKey; +//import org.springframework.security.oauth2.provider.endpoint.FrameworkEndpoint; +//import org.springframework.web.bind.annotation.GetMapping; +//import org.springframework.web.bind.annotation.ResponseBody; +//import org.springframework.web.bind.annotation.RestController; +// +//import java.security.KeyPair; +//import java.security.Principal; +//import java.security.interfaces.RSAPublicKey; +//import java.util.Map; +// +//@FrameworkEndpoint +//@RestController +//public class JwkSetEndpointConfiguration { +// KeyPair keyPair; +// +// public JwkSetEndpointConfiguration(KeyPair keyPair) { +// this.keyPair = keyPair; +// } +// +// @GetMapping("/.well-known/jwks.json") +// @ResponseBody +// public Map getKey(Principal principal) { +// RSAPublicKey publicKey = (RSAPublicKey) this.keyPair.getPublic(); +// RSAKey key = new RSAKey.Builder(publicKey).build(); +// return new JWKSet(key).toJSONObject(); +// } +//} \ No newline at end of file diff --git a/src/main/java/com/example/template/ResourceServerConfiguration.java b/src/main/java/com/example/template/ResourceServerConfiguration.java new file mode 100644 index 0000000..4b160b2 --- /dev/null +++ b/src/main/java/com/example/template/ResourceServerConfiguration.java @@ -0,0 +1,42 @@ +//package com.example.template; +//import org.springframework.context.annotation.Bean; +//import org.springframework.context.annotation.Configuration; +//import org.springframework.core.io.ClassPathResource; +//import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity; +//import org.springframework.security.config.web.server.ServerHttpSecurity; +//import org.springframework.security.oauth2.provider.token.store.KeyStoreKeyFactory; +//import org.springframework.security.web.server.SecurityWebFilterChain; +// +//import java.security.KeyPair; +// +//@Configuration +//@EnableWebFluxSecurity +//public class ResourceServerConfiguration { +// +// @Bean +// SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) throws Exception { +// +// http +// .cors().and() +// .csrf().disable() +// .authorizeExchange() +// .pathMatchers("/oauth/**","/login/**","/.well-known/jwks.json").permitAll() +// .anyExchange().authenticated() +// .and() +// .oauth2ResourceServer() +// .jwt() +// ; +// +// return http.build(); +// } +// +// @Bean +// public KeyPair makeKeyPair(){ +// KeyPair keyPair = new KeyStoreKeyFactory( +// new ClassPathResource("server.jks"), "qweqwe".toCharArray()) +// .getKeyPair("uengine", "qweqwe".toCharArray()); +// return keyPair; +// } +// +// +//} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml new file mode 100644 index 0000000..7a42f83 --- /dev/null +++ b/src/main/resources/application.yml @@ -0,0 +1,85 @@ + +server: + port: 8088 + +--- +spring: + profiles: default +# security: +# oauth2: +# resourceserver: +# jwt: +# jwk-set-uri: http://localhost:8080/.well-known/jwks.json + cloud: + gateway: + routes: + - id: product + uri: http://localhost:8081 + predicates: + - Path=/product/** + - id: order + uri: http://localhost:8082 + predicates: + - Path=/order/** + - id: delivery + uri: http://localhost:8083 + predicates: + - Path=/deliverys/** + - id: marketing + uri: http://localhost:8084 + predicates: + - Path=/serveys/** + - id: servicecenter + uri: http://localhost:8081 + predicates: + - Path=/customers/** + globalcors: + corsConfigurations: + '[/**]': + allowedOrigins: + - "*" + allowedMethods: + - "*" + allowedHeaders: + - "*" + allowCredentials: true + + +--- +spring: + profiles: docker + cloud: + gateway: + routes: + - id: product + uri: http://product:8080 + predicates: + - Path=/product/** + - id: order + uri: http://order:8080 + predicates: + - Path=/order/** + - id: delivery + uri: http://delivery:8080 + predicates: + - Path=/deliveries/** + - id: marketing + uri: http://marketing:8080 + predicates: + - Path=/serveys/** + - id: servicecenter + uri: http://servicecenter:8080 + predicates: + - Path=/customers/** + globalcors: + corsConfigurations: + '[/**]': + allowedOrigins: + - "*" + allowedMethods: + - "*" + allowedHeaders: + - "*" + allowCredentials: true +server: + port: 8080 \ No newline at end of file diff --git a/src/main/resources/server.jks b/src/main/resources/server.jks new file mode 100644 index 0000000..ad255a9 Binary files /dev/null and b/src/main/resources/server.jks differ