Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions admin/src/main/java/com/makeurpicks/AdminApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.oauth2.client.EnableOAuth2Sso;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
import org.springframework.context.annotation.Bean;
Expand All @@ -31,6 +33,7 @@
import org.springframework.security.web.csrf.CsrfTokenRepository;
import org.springframework.security.web.csrf.HttpSessionCsrfTokenRepository;
import org.springframework.security.web.header.HeaderWriterFilter;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.filter.OncePerRequestFilter;
import org.springframework.web.filter.RequestContextFilter;
import org.springframework.web.util.WebUtils;
Expand Down Expand Up @@ -94,4 +97,24 @@ private CsrfTokenRepository csrfTokenRepository() {
}

}

@Bean("loadBalancedRestTemplate")
@LoadBalanced
public RestTemplate restTemplate() {
return new RestTemplate();
}



@Autowired
private OAuth2ClientContext oAuth2ClientContext;

@Autowired
private OAuth2ProtectedResourceDetails oAuth2ProtectedResourceDetails;

@Bean
@LoadBalanced
OAuth2RestOperations secureRestTemplate() {
return new OAuth2RestTemplate(oAuth2ProtectedResourceDetails, oAuth2ClientContext);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public Player getPlayer() {
public void setPlayer(Player player) {
this.player = player;
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.userdetails.UserDetails;
Expand All @@ -18,14 +19,19 @@
import com.makeurpicks.exception.PlayerValidationException.PlayerExceptions;

@Service
@Configurable
public class PlayerService implements UserDetailsService {

@Autowired
private PlayerDao playerDao;

@Autowired
private PasswordEncoder passwordEncoder;


@Autowired
public PlayerService(PlayerDao playerDao, PasswordEncoder passwordEncoder) {
this.playerDao = playerDao;
this.passwordEncoder = passwordEncoder;
}

@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
Player player = playerDao.findByUsername(username);
Expand Down Expand Up @@ -78,5 +84,4 @@ private void validatePlayer(Player player)
if (!codes.isEmpty())
throw new PlayerValidationException(codes.toArray(new PlayerExceptions[codes.size()]));
}

}
4 changes: 2 additions & 2 deletions auth-server/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ spring:
hibernate:
dialect: org.hibernate.dialect.MySQL5Dialect
datasource:
url: jdbc:mysql://auth-db/player
username: root
url: jdbc:mysql://localhost:3303/player
username: dbuser
password: password
driver-class-name: com.mysql.jdbc.Driver

Expand Down
2 changes: 1 addition & 1 deletion auth-server/src/main/resources/bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ eureka:
instanceId: ${vcap.application.instance_id:${spring.application.name}:${random.value}}
client:
serviceUrl:
defaultZone: ${vcap.services.eureka-service.credentials.uri:http://eureka:8761}/eureka/
defaultZone: ${vcap.services.eureka-service.credentials.uri:http://localhost:8761}/eureka/


#---
Expand Down
66 changes: 33 additions & 33 deletions build/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
version: "2"

services:
config-server:
build: ../server-config/
networks:
- myp-network
ports:
- "8888:8888"
expose:
- "8888"
eureka:
image: springcloud/eureka
networks:
- myp-network
ports:
- "8761:8761"
expose:
- "8761"
# config-server:
# build: ../server-config/
# networks:
# - myp-network
# ports:
# - "8888:8888"
# expose:
# - "8888"
# eureka:
# image: springcloud/eureka
# networks:
# - myp-network
# ports:
# - "8761:8761"
# expose:
# - "8761"
# auth-server:
# build: ../auth-server/docker
# networks:
Expand Down Expand Up @@ -62,23 +62,23 @@ services:
- "3304:3306"
expose:
- "3304"
# game-db:
# image: mysql:latest
# build: mysql/
# environment:
# - MYSQL_ROOT_PASSWORD=admin123
# - MYSQL_USER=dbuser
# - MYSQL_PASSWORD=password
# - MYSQL_DATABASE=game
# volumes:
# - mysql-data:/home.scripts
# working_dir: "/home/scripts"
# networks:
# - myp-network
# ports:
# - "3305:3306"
# expose:
# - "3305"
game-db:
image: mysql:latest
#build: mysql/
environment:
- MYSQL_ROOT_PASSWORD=admin123
- MYSQL_USER=dbuser
- MYSQL_PASSWORD=password
- MYSQL_DATABASE=game
volumes:
- mysql-data:/home.scripts
working_dir: "/home/scripts"
networks:
- myp-network
ports:
- "3305:3306"
expose:
- "3305"
redis:
image: redis
networks:
Expand Down
28 changes: 28 additions & 0 deletions game/src/main/java/com/makeurpicks/GameApplication.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package com.makeurpicks;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
Expand All @@ -12,7 +15,12 @@
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.oauth2.client.OAuth2ClientContext;
import org.springframework.security.oauth2.client.OAuth2RestOperations;
import org.springframework.security.oauth2.client.OAuth2RestTemplate;
import org.springframework.security.oauth2.client.resource.OAuth2ProtectedResourceDetails;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
@EnableEurekaClient
Expand Down Expand Up @@ -45,4 +53,24 @@ public void configure(WebSecurity web) throws Exception {
}
}

@Autowired
private OAuth2ClientContext oAuth2ClientContext;

@Autowired
private OAuth2ProtectedResourceDetails oAuth2ProtectedResourceDetails;



@Bean(name = "loadBalancedRestTemplate")
@LoadBalanced
RestTemplate restTemplate() {
return new RestTemplate();
}


@Bean
@LoadBalanced
OAuth2RestOperations secureRestTemplate() {
return new OAuth2RestTemplate(oAuth2ProtectedResourceDetails, oAuth2ClientContext);
}
}
6 changes: 3 additions & 3 deletions game/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ spring:
hibernate:
dialect: org.hibernate.dialect.MySQL5Dialect
datasource:
url: jdbc:mysql://localhost/game
username: root
password: rage311
url: jdbc:mysql://localhost:3305/game
username: dbuser
password: password
driver-class-name: com.mysql.jdbc.Driver


Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
package com.makeurpicks.domain;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import java.io.Serializable;

public class AbstractModel implements Serializable {

@Id
@GeneratedValue
protected String id;

public String getId() {
Expand Down
13 changes: 10 additions & 3 deletions league/src/main/java/com/makeurpicks/domain/League.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
package com.makeurpicks.domain;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;

@Entity
public class League extends AbstractModel {



@Id
@GeneratedValue
protected String id;

private String leagueName;
private int paidFor=0;
private boolean money=false;
Expand All @@ -26,7 +32,8 @@ public class League extends AbstractModel {

private String seasonId;
private String adminId;



public String getLeagueName() {
return leagueName;
}
Expand Down
8 changes: 7 additions & 1 deletion league/src/main/java/com/makeurpicks/domain/Season.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
package com.makeurpicks.domain;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import java.io.Serializable;

@Entity
public class Season implements Serializable {

/**
*
*/
private static final long serialVersionUID = -1686980214059945687L;


@Id
@GeneratedValue
private String id;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.repository.Repository;

import com.makeurpicks.domain.Season;

public interface SeasonRepository extends Repository<Season, String> {//CrudRepository<Season, String>{
public interface SeasonRepository extends JpaRepository<Season, String> {//CrudRepository<Season, String>{

public List<Season> getSeasonsByLeagueType(String leaueType);
public Season save(Season season);
Expand Down
Loading