feat(auth): rewrite authentication to not use oauth manage users in app instead #163
53 changed files with 1011 additions and 467 deletions
|
@ -51,6 +51,9 @@ dependencies {
|
|||
implementation("org.springframework.boot:spring-boot-starter-oauth2-client:3.4.5")
|
||||
runtimeOnly("org.postgresql:postgresql")
|
||||
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.8.8")
|
||||
implementation("io.jsonwebtoken:jjwt-api:0.11.5")
|
||||
runtimeOnly("io.jsonwebtoken:jjwt-impl:0.11.5")
|
||||
runtimeOnly("io.jsonwebtoken:jjwt-jackson:0.11.5")
|
||||
}
|
||||
|
||||
tasks.withType<Test> {
|
||||
|
|
|
@ -13,7 +13,6 @@ import org.springframework.web.client.RestTemplate;
|
|||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@SpringBootApplication
|
||||
public class CasinoApplication {
|
||||
|
|
|
@ -11,8 +11,8 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
|
@ -29,8 +29,8 @@ public class BlackJackGameController {
|
|||
}
|
||||
|
||||
@GetMapping("/blackjack/{id}")
|
||||
public ResponseEntity<Object> getGame(@PathVariable Long id, @RequestHeader("Authorization") String token) {
|
||||
Optional<UserEntity> optionalUser = userService.getCurrentUser(token);
|
||||
public ResponseEntity<Object> getGame(@PathVariable Long id) {
|
||||
Optional<UserEntity> optionalUser = userService.getCurrentUser();
|
||||
|
||||
if (optionalUser.isEmpty()) {
|
||||
throw new UserNotFoundException();
|
||||
|
@ -46,8 +46,8 @@ public class BlackJackGameController {
|
|||
}
|
||||
|
||||
@PostMapping("/blackjack/{id}/hit")
|
||||
public ResponseEntity<Object> hit(@PathVariable Long id, @RequestHeader("Authorization") String token) {
|
||||
Optional<UserEntity> optionalUser = userService.getCurrentUser(token);
|
||||
public ResponseEntity<Object> hit(@PathVariable Long id) {
|
||||
Optional<UserEntity> optionalUser = userService.getCurrentUser();
|
||||
|
||||
if (optionalUser.isEmpty()) {
|
||||
throw new UserNotFoundException();
|
||||
|
@ -63,8 +63,8 @@ public class BlackJackGameController {
|
|||
}
|
||||
|
||||
@PostMapping("/blackjack/{id}/stand")
|
||||
public ResponseEntity<Object> stand(@PathVariable Long id, @RequestHeader("Authorization") String token) {
|
||||
Optional<UserEntity> optionalUser = userService.getCurrentUser(token);
|
||||
public ResponseEntity<Object> stand(@PathVariable Long id) {
|
||||
Optional<UserEntity> optionalUser = userService.getCurrentUser();
|
||||
|
||||
if (optionalUser.isEmpty()) {
|
||||
throw new UserNotFoundException();
|
||||
|
@ -80,8 +80,8 @@ public class BlackJackGameController {
|
|||
}
|
||||
|
||||
@PostMapping("/blackjack/{id}/doubleDown")
|
||||
public ResponseEntity<Object> doubleDown(@PathVariable Long id, @RequestHeader("Authorization") String token) {
|
||||
Optional<UserEntity> optionalUser = userService.getCurrentUser(token);
|
||||
public ResponseEntity<Object> doubleDown(@PathVariable Long id) {
|
||||
Optional<UserEntity> optionalUser = userService.getCurrentUser();
|
||||
|
||||
if (optionalUser.isEmpty()) {
|
||||
throw new UserNotFoundException();
|
||||
|
@ -97,8 +97,8 @@ public class BlackJackGameController {
|
|||
}
|
||||
|
||||
@PostMapping("/blackjack/{id}/split")
|
||||
public ResponseEntity<Object> split(@PathVariable Long id, @RequestHeader("Authorization") String token) {
|
||||
Optional<UserEntity> optionalUser = userService.getCurrentUser(token);
|
||||
public ResponseEntity<Object> split(@PathVariable Long id) {
|
||||
Optional<UserEntity> optionalUser = userService.getCurrentUser();
|
||||
|
||||
if (optionalUser.isEmpty()) {
|
||||
throw new UserNotFoundException();
|
||||
|
@ -114,8 +114,8 @@ public class BlackJackGameController {
|
|||
}
|
||||
|
||||
@PostMapping("/blackjack/start")
|
||||
public ResponseEntity<Object> createBlackJackGame(@RequestBody @Valid BetDto betDto, @RequestHeader("Authorization") String token) {
|
||||
Optional<UserEntity> optionalUser = userService.getCurrentUser(token);
|
||||
public ResponseEntity<Object> createBlackJackGame(@RequestBody @Valid BetDto betDto) {
|
||||
Optional<UserEntity> optionalUser = userService.getCurrentUser();
|
||||
|
||||
if (optionalUser.isEmpty()) {
|
||||
throw new UserNotFoundException();
|
||||
|
|
30
backend/src/main/java/de/szut/casino/config/WebConfig.java
Normal file
30
backend/src/main/java/de/szut/casino/config/WebConfig.java
Normal file
|
@ -0,0 +1,30 @@
|
|||
package de.szut.casino.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration
|
||||
public class WebConfig {
|
||||
|
||||
@Value("${app.frontend-host}")
|
||||
private String frontendHost;
|
||||
|
||||
@Bean
|
||||
public WebMvcConfigurer corsConfigurer() {
|
||||
return new WebMvcConfigurer() {
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**")
|
||||
.allowedOrigins(frontendHost)
|
||||
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
|
||||
.allowedHeaders("*")
|
||||
.exposedHeaders("*")
|
||||
.allowCredentials(true)
|
||||
.maxAge(3600);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -7,19 +7,14 @@ import com.stripe.param.checkout.SessionCreateParams;
|
|||
import de.szut.casino.deposit.dto.AmountDto;
|
||||
import de.szut.casino.deposit.dto.SessionIdDto;
|
||||
import de.szut.casino.user.UserEntity;
|
||||
import de.szut.casino.user.UserRepository;
|
||||
import de.szut.casino.user.dto.KeycloakUserDto;
|
||||
import de.szut.casino.user.UserService;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
|
@ -34,23 +29,18 @@ public class DepositController {
|
|||
|
||||
private final TransactionService transactionService;
|
||||
|
||||
private final RestTemplate restTemplate;
|
||||
private UserService userService;
|
||||
|
||||
private final UserRepository userRepository;
|
||||
|
||||
|
||||
public DepositController(TransactionService transactionService, RestTemplate restTemplate, UserRepository userRepository) {
|
||||
public DepositController(TransactionService transactionService, UserService userService) {
|
||||
this.transactionService = transactionService;
|
||||
this.restTemplate = restTemplate;
|
||||
this.userRepository = userRepository;
|
||||
this.userService = userService;
|
||||
}
|
||||
|
||||
@PostMapping("/deposit/checkout")
|
||||
public ResponseEntity<SessionIdDto> checkout(@RequestBody @Valid AmountDto amountDto, @RequestHeader("Authorization") String token) throws StripeException {
|
||||
Stripe.apiKey = stripeKey;
|
||||
|
||||
KeycloakUserDto userData = getAuthentikUserInfo(token);
|
||||
Optional<UserEntity> optionalUserEntity = this.userRepository.findOneByAuthentikId(userData.getSub());
|
||||
Optional<UserEntity> optionalUserEntity = this.userService.getCurrentUser();
|
||||
|
||||
SessionCreateParams params = SessionCreateParams.builder()
|
||||
.addLineItem(SessionCreateParams.LineItem.builder()
|
||||
|
@ -78,13 +68,5 @@ public class DepositController {
|
|||
|
||||
return ResponseEntity.ok(new SessionIdDto(session.getId()));
|
||||
}
|
||||
|
||||
private KeycloakUserDto getAuthentikUserInfo(String token) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("Authorization", token);
|
||||
ResponseEntity<KeycloakUserDto> response = this.restTemplate.exchange("https://oauth.simonis.lol/application/o/userinfo/", HttpMethod.GET, new HttpEntity<>(headers), KeycloakUserDto.class);
|
||||
|
||||
return response.getBody();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,6 @@ import org.springframework.web.bind.annotation.ResponseStatus;
|
|||
@ResponseStatus(value = HttpStatus.NOT_FOUND)
|
||||
public class UserNotFoundException extends RuntimeException {
|
||||
public UserNotFoundException() {
|
||||
super("user not found");
|
||||
super("User not found");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,13 +3,15 @@ package de.szut.casino.lootboxes;
|
|||
import de.szut.casino.exceptionHandling.exceptions.InsufficientFundsException;
|
||||
import de.szut.casino.exceptionHandling.exceptions.UserNotFoundException;
|
||||
import de.szut.casino.user.UserEntity;
|
||||
import de.szut.casino.user.UserRepository;
|
||||
import de.szut.casino.user.UserService;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
public class LootBoxController {
|
||||
|
@ -17,7 +19,7 @@ public class LootBoxController {
|
|||
private final UserService userService;
|
||||
private final LootBoxService lootBoxService;
|
||||
|
||||
public LootBoxController(LootBoxRepository lootBoxRepository, UserRepository userRepository, UserService userService, LootBoxService lootBoxService) {
|
||||
public LootBoxController(LootBoxRepository lootBoxRepository, UserService userService, LootBoxService lootBoxService) {
|
||||
this.lootBoxRepository = lootBoxRepository;
|
||||
this.userService = userService;
|
||||
this.lootBoxService = lootBoxService;
|
||||
|
@ -29,7 +31,7 @@ public class LootBoxController {
|
|||
}
|
||||
|
||||
@PostMapping("/lootboxes/{id}")
|
||||
public ResponseEntity<Object> purchaseLootBox(@PathVariable Long id, @RequestHeader("Authorization") String token) {
|
||||
public ResponseEntity<Object> purchaseLootBox(@PathVariable Long id) {
|
||||
Optional<LootBoxEntity> optionalLootBox = lootBoxRepository.findById(id);
|
||||
if (optionalLootBox.isEmpty()) {
|
||||
return ResponseEntity.notFound().build();
|
||||
|
@ -37,7 +39,7 @@ public class LootBoxController {
|
|||
|
||||
LootBoxEntity lootBox = optionalLootBox.get();
|
||||
|
||||
Optional<UserEntity> optionalUser = userService.getCurrentUser(token);
|
||||
Optional<UserEntity> optionalUser = userService.getCurrentUser();
|
||||
if (optionalUser.isEmpty()) {
|
||||
throw new UserNotFoundException();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
package de.szut.casino.security;
|
||||
|
||||
import de.szut.casino.security.dto.AuthResponseDto;
|
||||
import de.szut.casino.security.dto.LoginRequestDto;
|
||||
import de.szut.casino.security.service.AuthService;
|
||||
import de.szut.casino.user.dto.CreateUserDto;
|
||||
import de.szut.casino.user.dto.GetUserDto;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/auth")
|
||||
public class AuthController {
|
||||
|
||||
@Autowired
|
||||
private AuthService authService;
|
||||
|
||||
@PostMapping("/login")
|
||||
public ResponseEntity<AuthResponseDto> authenticateUser(@Valid @RequestBody LoginRequestDto loginRequest) {
|
||||
AuthResponseDto response = authService.login(loginRequest);
|
||||
return ResponseEntity.ok(response);
|
||||
}
|
||||
|
||||
@PostMapping("/register")
|
||||
public ResponseEntity<GetUserDto> registerUser(@Valid @RequestBody CreateUserDto signUpRequest) {
|
||||
GetUserDto response = authService.register(signUpRequest);
|
||||
return ResponseEntity.ok(response);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package de.szut.casino.security;
|
||||
|
||||
import jakarta.servlet.*;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Component
|
||||
@Order(Ordered.HIGHEST_PRECEDENCE)
|
||||
public class CorsFilter implements Filter {
|
||||
|
||||
@Value("${app.frontend-host}")
|
||||
private String frontendHost;
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
|
||||
|
||||
HttpServletResponse response = (HttpServletResponse) res;
|
||||
HttpServletRequest request = (HttpServletRequest) req;
|
||||
|
||||
// Allow requests from the frontend
|
||||
response.setHeader("Access-Control-Allow-Origin", frontendHost);
|
||||
response.setHeader("Access-Control-Allow-Methods", "GET, POST, PUT, PATCH, DELETE, OPTIONS");
|
||||
response.setHeader("Access-Control-Allow-Headers", "*");
|
||||
response.setHeader("Access-Control-Expose-Headers", "*");
|
||||
response.setHeader("Access-Control-Allow-Credentials", "true");
|
||||
response.setHeader("Access-Control-Max-Age", "3600");
|
||||
|
||||
if ("OPTIONS".equalsIgnoreCase(request.getMethod())) {
|
||||
response.setStatus(HttpServletResponse.SC_OK);
|
||||
return;
|
||||
}
|
||||
|
||||
chain.doFilter(req, res);
|
||||
}
|
||||
}
|
|
@ -1,12 +1,22 @@
|
|||
package de.szut.casino.security;
|
||||
|
||||
import de.szut.casino.security.jwt.JwtAuthenticationFilter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.config.Customizer;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
|
||||
import org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration;
|
||||
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.config.http.SessionCreationPolicy;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.security.web.SecurityFilterChain;
|
||||
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
import org.springframework.web.cors.CorsConfigurationSource;
|
||||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
||||
|
@ -16,23 +26,51 @@ import java.util.List;
|
|||
|
||||
@Configuration
|
||||
@EnableWebSecurity
|
||||
@EnableMethodSecurity
|
||||
public class SecurityConfig {
|
||||
|
||||
@Value("${app.frontend-host}")
|
||||
private String frontendHost;
|
||||
|
||||
@Autowired
|
||||
private UserDetailsService userDetailsService;
|
||||
|
||||
@Autowired
|
||||
private JwtAuthenticationFilter jwtAuthenticationFilter;
|
||||
|
||||
@Bean
|
||||
public DaoAuthenticationProvider authenticationProvider() {
|
||||
DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider();
|
||||
|
||||
authProvider.setUserDetailsService(userDetailsService);
|
||||
authProvider.setPasswordEncoder(passwordEncoder());
|
||||
|
||||
return authProvider;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AuthenticationManager authenticationManager(AuthenticationConfiguration authConfig) throws Exception {
|
||||
return authConfig.getAuthenticationManager();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public PasswordEncoder passwordEncoder() {
|
||||
return new BCryptPasswordEncoder();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
|
||||
http
|
||||
.cors(Customizer.withDefaults())
|
||||
.cors(cors -> cors.configurationSource(corsConfigurationSource()))
|
||||
.csrf(csrf -> csrf.disable())
|
||||
.sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
|
||||
.authorizeHttpRequests(auth -> {
|
||||
auth.requestMatchers("/webhook", "/swagger/**", "/swagger-ui/**", "/health").permitAll()
|
||||
auth.requestMatchers("/auth/**", "/webhook", "/swagger/**", "/swagger-ui/**", "/health", "/error").permitAll()
|
||||
.requestMatchers(org.springframework.http.HttpMethod.OPTIONS, "/**").permitAll()
|
||||
.anyRequest().authenticated();
|
||||
})
|
||||
.oauth2ResourceServer(oauth2 -> oauth2.jwt(jwt ->
|
||||
jwt.jwtAuthenticationConverter(new CustomJwtAuthenticationConverter())
|
||||
));
|
||||
.authenticationProvider(authenticationProvider())
|
||||
.addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class);
|
||||
|
||||
return http.build();
|
||||
}
|
||||
|
@ -42,9 +80,10 @@ public class SecurityConfig {
|
|||
CorsConfiguration configuration = new CorsConfiguration();
|
||||
configuration.setAllowedOrigins(List.of(this.frontendHost));
|
||||
configuration.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"));
|
||||
configuration.setAllowedHeaders(Arrays.asList("authorization", "content-type", "x-auth-token", "Access-Control-Allow-Origin"));
|
||||
configuration.setExposedHeaders(List.of("x-auth-token"));
|
||||
configuration.setAllowedHeaders(Arrays.asList("Authorization", "Content-Type", "Accept", "Origin", "X-Requested-With", "Access-Control-Request-Method", "Access-Control-Request-Headers", "x-auth-token"));
|
||||
configuration.setExposedHeaders(Arrays.asList("Authorization", "Content-Type", "x-auth-token", "Access-Control-Allow-Origin", "Access-Control-Allow-Methods", "Access-Control-Allow-Headers"));
|
||||
configuration.setAllowCredentials(true);
|
||||
configuration.setMaxAge(3600L);
|
||||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||||
source.registerCorsConfiguration("/**", configuration);
|
||||
return source;
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package de.szut.casino.security.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AuthResponseDto {
|
||||
private String token;
|
||||
private String tokenType = "Bearer";
|
||||
|
||||
public AuthResponseDto(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package de.szut.casino.security.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class LoginRequestDto {
|
||||
@NotBlank(message = "Username or email is required")
|
||||
private String usernameOrEmail;
|
||||
|
||||
@NotBlank(message = "Password is required")
|
||||
private String password;
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package de.szut.casino.security.jwt;
|
||||
|
||||
import jakarta.servlet.FilterChain;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.security.web.authentication.WebAuthenticationDetailsSource;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.filter.OncePerRequestFilter;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Component
|
||||
public class JwtAuthenticationFilter extends OncePerRequestFilter {
|
||||
|
||||
@Autowired
|
||||
private JwtUtils jwtUtils;
|
||||
|
||||
@Autowired
|
||||
private UserDetailsService userDetailsService;
|
||||
|
||||
@Override
|
||||
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
|
||||
throws ServletException, IOException {
|
||||
try {
|
||||
String jwt = parseJwt(request);
|
||||
if (jwt != null) {
|
||||
String username = jwtUtils.extractUsername(jwt);
|
||||
|
||||
if (username != null && SecurityContextHolder.getContext().getAuthentication() == null) {
|
||||
UserDetails userDetails = userDetailsService.loadUserByUsername(username);
|
||||
|
||||
if (jwtUtils.validateToken(jwt, userDetails)) {
|
||||
UsernamePasswordAuthenticationToken authToken = new UsernamePasswordAuthenticationToken(
|
||||
userDetails, null, userDetails.getAuthorities());
|
||||
|
||||
authToken.setDetails(new WebAuthenticationDetailsSource().buildDetails(request));
|
||||
SecurityContextHolder.getContext().setAuthentication(authToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("Cannot set user authentication: {}", e);
|
||||
}
|
||||
|
||||
filterChain.doFilter(request, response);
|
||||
}
|
||||
|
||||
private String parseJwt(HttpServletRequest request) {
|
||||
String headerAuth = request.getHeader("Authorization");
|
||||
|
||||
if (StringUtils.hasText(headerAuth) && headerAuth.startsWith("Bearer ")) {
|
||||
return headerAuth.substring(7);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
package de.szut.casino.security.jwt;
|
||||
|
||||
import io.jsonwebtoken.Claims;
|
||||
import io.jsonwebtoken.Jwts;
|
||||
import io.jsonwebtoken.SignatureAlgorithm;
|
||||
import io.jsonwebtoken.security.Keys;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.security.Key;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Component
|
||||
public class JwtUtils {
|
||||
|
||||
@Value("${jwt.secret}")
|
||||
private String jwtSecret;
|
||||
|
||||
@Value("${jwt.expiration.ms}")
|
||||
private int jwtExpirationMs;
|
||||
|
||||
private Key getSigningKey() {
|
||||
return Keys.hmacShaKeyFor(jwtSecret.getBytes());
|
||||
}
|
||||
|
||||
public String generateToken(Authentication authentication) {
|
||||
UserDetails userDetails = (UserDetails) authentication.getPrincipal();
|
||||
return generateToken(userDetails.getUsername());
|
||||
}
|
||||
|
||||
public String generateToken(String username) {
|
||||
Map<String, Object> claims = new HashMap<>();
|
||||
return createToken(claims, username);
|
||||
}
|
||||
|
||||
private String createToken(Map<String, Object> claims, String subject) {
|
||||
Date now = new Date();
|
||||
Date expiryDate = new Date(now.getTime() + jwtExpirationMs);
|
||||
|
||||
return Jwts.builder()
|
||||
.setClaims(claims)
|
||||
.setSubject(subject)
|
||||
.setIssuedAt(now)
|
||||
.setExpiration(expiryDate)
|
||||
.signWith(getSigningKey(), SignatureAlgorithm.HS256)
|
||||
.compact();
|
||||
}
|
||||
|
||||
public String extractUsername(String token) {
|
||||
return extractClaim(token, Claims::getSubject);
|
||||
}
|
||||
|
||||
public Date extractExpiration(String token) {
|
||||
return extractClaim(token, Claims::getExpiration);
|
||||
}
|
||||
|
||||
public <T> T extractClaim(String token, Function<Claims, T> claimsResolver) {
|
||||
final Claims claims = extractAllClaims(token);
|
||||
return claimsResolver.apply(claims);
|
||||
}
|
||||
|
||||
private Claims extractAllClaims(String token) {
|
||||
return Jwts.parserBuilder()
|
||||
.setSigningKey(getSigningKey())
|
||||
.build()
|
||||
.parseClaimsJws(token)
|
||||
.getBody();
|
||||
}
|
||||
|
||||
private Boolean isTokenExpired(String token) {
|
||||
return extractExpiration(token).before(new Date());
|
||||
}
|
||||
|
||||
public Boolean validateToken(String token, UserDetails userDetails) {
|
||||
final String username = extractUsername(token);
|
||||
return (username.equals(userDetails.getUsername()) && !isTokenExpired(token));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package de.szut.casino.security.service;
|
||||
|
||||
import de.szut.casino.security.dto.AuthResponseDto;
|
||||
import de.szut.casino.security.dto.LoginRequestDto;
|
||||
import de.szut.casino.security.jwt.JwtUtils;
|
||||
import de.szut.casino.user.UserEntity;
|
||||
import de.szut.casino.user.UserService;
|
||||
import de.szut.casino.user.dto.CreateUserDto;
|
||||
import de.szut.casino.user.dto.GetUserDto;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class AuthService {
|
||||
|
||||
@Autowired
|
||||
private AuthenticationManager authenticationManager;
|
||||
|
||||
@Autowired
|
||||
private JwtUtils jwtUtils;
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
public AuthResponseDto login(LoginRequestDto loginRequest) {
|
||||
Authentication authentication = authenticationManager.authenticate(
|
||||
new UsernamePasswordAuthenticationToken(
|
||||
loginRequest.getUsernameOrEmail(),
|
||||
loginRequest.getPassword()));
|
||||
|
||||
SecurityContextHolder.getContext().setAuthentication(authentication);
|
||||
String jwt = jwtUtils.generateToken(authentication);
|
||||
|
||||
return new AuthResponseDto(jwt);
|
||||
}
|
||||
|
||||
public GetUserDto register(CreateUserDto signUpRequest) {
|
||||
UserEntity user = userService.createUser(signUpRequest);
|
||||
return new GetUserDto(
|
||||
user.getId(),
|
||||
user.getEmail(),
|
||||
user.getUsername(),
|
||||
user.getBalance()
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package de.szut.casino.security.service;
|
||||
|
||||
import de.szut.casino.user.UserEntity;
|
||||
import de.szut.casino.user.UserRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class UserDetailsServiceImpl implements UserDetailsService {
|
||||
|
||||
@Autowired
|
||||
private UserRepository userRepository;
|
||||
|
||||
@Override
|
||||
public UserDetails loadUserByUsername(String usernameOrEmail) throws UsernameNotFoundException {
|
||||
Optional<UserEntity> user = userRepository.findByUsername(usernameOrEmail);
|
||||
|
||||
if (user.isEmpty()) {
|
||||
user = userRepository.findByEmail(usernameOrEmail);
|
||||
}
|
||||
|
||||
UserEntity userEntity = user.orElseThrow(() ->
|
||||
new UsernameNotFoundException("User not found with username or email: " + usernameOrEmail));
|
||||
|
||||
return new org.springframework.security.core.userdetails.User(
|
||||
userEntity.getUsername(),
|
||||
userEntity.getPassword(),
|
||||
new ArrayList<>());
|
||||
}
|
||||
}
|
|
@ -8,10 +8,12 @@ import de.szut.casino.user.UserEntity;
|
|||
import de.szut.casino.user.UserService;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
@ -29,8 +31,8 @@ public class SlotController {
|
|||
}
|
||||
|
||||
@PostMapping("/slots/spin")
|
||||
public ResponseEntity<Object> spinSlots(@RequestBody @Valid BetDto betDto, @RequestHeader("Authorization") String token) {
|
||||
Optional<UserEntity> optionalUser = userService.getCurrentUser(token);
|
||||
public ResponseEntity<Object> spinSlots(@RequestBody @Valid BetDto betDto) {
|
||||
Optional<UserEntity> optionalUser = userService.getCurrentUser();
|
||||
|
||||
if (optionalUser.isEmpty()) {
|
||||
throw new UserNotFoundException();
|
||||
|
|
|
@ -1,43 +1,28 @@
|
|||
package de.szut.casino.user;
|
||||
|
||||
import de.szut.casino.exceptionHandling.exceptions.UserNotFoundException;
|
||||
import de.szut.casino.user.dto.CreateUserDto;
|
||||
import de.szut.casino.user.dto.GetUserDto;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping("/users")
|
||||
public class UserController {
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@PostMapping("/user")
|
||||
public ResponseEntity<?> createUser(@RequestBody @Valid CreateUserDto userData) {
|
||||
if (userService.exists(userData.getAuthentikId())) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.add("Location", "/user");
|
||||
@Autowired
|
||||
private UserMappingService userMappingService;
|
||||
|
||||
return new ResponseEntity<>(headers, HttpStatus.FOUND);
|
||||
}
|
||||
|
||||
return ResponseEntity.ok(userService.createUser(userData));
|
||||
}
|
||||
|
||||
@GetMapping("/user")
|
||||
public ResponseEntity<GetUserDto> getCurrentUser(@RequestHeader("Authorization") String token) {
|
||||
GetUserDto userData = userService.getCurrentUserAsDto(token);
|
||||
|
||||
if (userData == null) {
|
||||
throw new UserNotFoundException();
|
||||
}
|
||||
|
||||
return ResponseEntity.ok(userData);
|
||||
@GetMapping("/me")
|
||||
public ResponseEntity<GetUserDto> getCurrentUser() {
|
||||
return ResponseEntity.ok(userMappingService.mapToGetUserDto(userService.getCurrentUser().orElseThrow()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,16 +18,22 @@ public class UserEntity {
|
|||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
|
||||
@Column(unique = true)
|
||||
private String email;
|
||||
|
||||
@Column(unique = true)
|
||||
private String authentikId;
|
||||
private String username;
|
||||
|
||||
private String password;
|
||||
|
||||
@Column(precision = 19, scale = 2)
|
||||
private BigDecimal balance;
|
||||
|
||||
public UserEntity(String authentikId, String username, BigDecimal balance) {
|
||||
this.authentikId = authentikId;
|
||||
public UserEntity(String email, String username, String password, BigDecimal balance) {
|
||||
this.email = email;
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
this.balance = balance;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,19 +1,13 @@
|
|||
package de.szut.casino.user;
|
||||
|
||||
import de.szut.casino.user.dto.CreateUserDto;
|
||||
import de.szut.casino.user.dto.GetUserDto;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Service
|
||||
public class UserMappingService {
|
||||
|
||||
public GetUserDto mapToGetUserDto(UserEntity user) {
|
||||
return new GetUserDto(user.getAuthentikId(), user.getUsername(), user.getBalance());
|
||||
}
|
||||
|
||||
public UserEntity mapToUserEntity(CreateUserDto createUserDto) {
|
||||
return new UserEntity(createUserDto.getAuthentikId(), createUserDto.getUsername(), BigDecimal.ZERO);
|
||||
return new GetUserDto(user.getId(), user.getEmail(), user.getUsername(), user.getBalance());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
package de.szut.casino.user;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public interface UserRepository extends JpaRepository<UserEntity, Long> {
|
||||
@Query("SELECT u FROM UserEntity u WHERE u.authentikId = ?1")
|
||||
Optional<UserEntity> findOneByAuthentikId(String authentikId);
|
||||
Optional<UserEntity> findByUsername(String username);
|
||||
|
||||
boolean existsByAuthentikId(String authentikId);
|
||||
Optional<UserEntity> findByEmail(String email);
|
||||
|
||||
boolean existsByUsername(String username);
|
||||
|
||||
boolean existsByEmail(String email);
|
||||
}
|
||||
|
|
|
@ -1,16 +1,12 @@
|
|||
package de.szut.casino.user;
|
||||
|
||||
import de.szut.casino.user.dto.CreateUserDto;
|
||||
import de.szut.casino.user.dto.GetUserDto;
|
||||
import de.szut.casino.user.dto.KeycloakUserDto;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
|
@ -19,63 +15,30 @@ public class UserService {
|
|||
private UserRepository userRepository;
|
||||
|
||||
@Autowired
|
||||
private RestTemplate http;
|
||||
|
||||
@Autowired
|
||||
private UserMappingService mappingService;
|
||||
private PasswordEncoder passwordEncoder;
|
||||
|
||||
public UserEntity createUser(CreateUserDto createUserDto) {
|
||||
UserEntity user = mappingService.mapToUserEntity(createUserDto);
|
||||
userRepository.save(user);
|
||||
|
||||
return user;
|
||||
if (userRepository.existsByUsername(createUserDto.getUsername())) {
|
||||
throw new IllegalArgumentException("Username is already taken");
|
||||
}
|
||||
|
||||
public GetUserDto getUser(String authentikId) {
|
||||
Optional<UserEntity> user = this.userRepository.findOneByAuthentikId(authentikId);
|
||||
|
||||
return user.map(userEntity -> mappingService.mapToGetUserDto(userEntity)).orElse(null);
|
||||
if (userRepository.existsByEmail(createUserDto.getEmail())) {
|
||||
throw new IllegalArgumentException("Email is already in use");
|
||||
}
|
||||
|
||||
public GetUserDto getCurrentUserAsDto(String token) {
|
||||
KeycloakUserDto userData = getAuthentikUserInfo(token);
|
||||
|
||||
if (userData == null) {
|
||||
return null;
|
||||
}
|
||||
Optional<UserEntity> user = this.userRepository.findOneByAuthentikId(userData.getSub());
|
||||
|
||||
return user.map(userEntity -> mappingService.mapToGetUserDto(userEntity)).orElse(null);
|
||||
}
|
||||
|
||||
public Optional<UserEntity> getCurrentUser(String token) {
|
||||
KeycloakUserDto userData = getAuthentikUserInfo(token);
|
||||
|
||||
if (userData == null) {
|
||||
return Optional.empty();
|
||||
}
|
||||
return this.userRepository.findOneByAuthentikId(userData.getSub());
|
||||
}
|
||||
|
||||
private KeycloakUserDto getAuthentikUserInfo(String token) {
|
||||
try {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("Authorization", token);
|
||||
ResponseEntity<KeycloakUserDto> response = this.http.exchange(
|
||||
"https://oauth.simonis.lol/application/o/userinfo/",
|
||||
HttpMethod.GET,
|
||||
new HttpEntity<>(headers),
|
||||
KeycloakUserDto.class
|
||||
UserEntity user = new UserEntity(
|
||||
createUserDto.getEmail(),
|
||||
createUserDto.getUsername(),
|
||||
passwordEncoder.encode(createUserDto.getPassword()),
|
||||
BigDecimal.valueOf(10) // Starting balance
|
||||
);
|
||||
|
||||
return response.getBody();
|
||||
} catch (Exception e) {
|
||||
System.err.println("Error fetching user info from Authentik: " + e.getMessage());
|
||||
return null;
|
||||
}
|
||||
return userRepository.save(user);
|
||||
}
|
||||
|
||||
public boolean exists(String authentikId) {
|
||||
return userRepository.existsByAuthentikId(authentikId);
|
||||
public Optional<UserEntity> getCurrentUser() {
|
||||
String username = SecurityContextHolder.getContext().getAuthentication().getName();
|
||||
|
||||
return userRepository.findByUsername(username);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package de.szut.casino.user.dto;
|
||||
|
||||
import jakarta.validation.constraints.Email;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
@ -10,6 +13,15 @@ import lombok.Setter;
|
|||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class CreateUserDto {
|
||||
private String authentikId;
|
||||
@NotBlank(message = "Email is required")
|
||||
@Email(message = "Email should be valid")
|
||||
private String email;
|
||||
|
||||
@NotBlank(message = "Username is required")
|
||||
@Size(min = 3, max = 20, message = "Username must be between 3 and 20 characters")
|
||||
private String username;
|
||||
|
||||
@NotBlank(message = "Password is required")
|
||||
@Size(min = 6, message = "Password must be at least 6 characters")
|
||||
private String password;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,8 @@ import java.math.BigDecimal;
|
|||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class GetUserDto {
|
||||
private String authentikId;
|
||||
private Long id;
|
||||
private String email;
|
||||
private String username;
|
||||
private BigDecimal balance;
|
||||
}
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
package de.szut.casino.user.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class KeycloakUserDto {
|
||||
private String sub;
|
||||
private String preferred_username;
|
||||
}
|
|
@ -22,7 +22,7 @@ public class GetTransactionService {
|
|||
private TransactionRepository transactionRepository;
|
||||
|
||||
public UserTransactionsDto getUserTransactionsDto(String authToken, Integer limit, Integer offset) {
|
||||
Optional<UserEntity> user = this.userService.getCurrentUser(authToken);
|
||||
Optional<UserEntity> user = this.userService.getCurrentUser();
|
||||
if (user.isPresent()) {
|
||||
List<TransactionEntity> transactionEntities = this.transactionRepository.findByUserIdWithLimit(user.get(), limit, offset);
|
||||
Boolean hasMore = this.transactionRepository.hasMore(user.get(), limit, offset);
|
||||
|
|
|
@ -8,33 +8,15 @@ stripe.webhook.secret=${STRIPE_WEBHOOK_SECRET:whsec_746b6a488665f6057118bdb4a2b3
|
|||
app.frontend-host=${FE_URL:http://localhost:4200}
|
||||
|
||||
spring.application.name=casino
|
||||
#client registration configuration
|
||||
|
||||
spring.security.oauth2.client.registration.authentik.client-id=${AUTH_CLIENT_ID:MDqjm1kcWKuZfqHJXjxwAV20i44aT7m4VhhTL3Nm}
|
||||
spring.security.oauth2.client.registration.authentik.client-secret=${AUTH_CLIENT_SECRET:GY2F8te6iAVYt1TNAUVLzWZEXb6JoMNp6chbjqaXNq4gS5xTDL54HqBiAlV1jFKarN28LQ7FUsYX4SbwjfEhZhgeoKuBnZKjR9eiu7RawnGgxIK9ffvUfMkjRxnmiGI5}
|
||||
spring.security.oauth2.client.registration.authentik.provider=authentik
|
||||
spring.security.oauth2.client.registration.authentik.client-name=Authentik
|
||||
spring.security.oauth2.client.registration.authentik.scope=openid,email,profile
|
||||
spring.security.oauth2.client.registration.authentik.client-authentication-method=client_secret_basic
|
||||
spring.security.oauth2.client.registration.authentik.authorization-grant-type=authorization_code
|
||||
spring.security.oauth2.client.registration.authentik.redirect-uri={baseUrl}/login/oauth2/code/{registrationId}
|
||||
# JWT Configuration
|
||||
jwt.secret=${JWT_SECRET:5367566B59703373367639792F423F4528482B4D6251655468576D5A71347437}
|
||||
jwt.expiration.ms=${JWT_EXPIRATION_MS:86400000}
|
||||
|
||||
# Provider settings
|
||||
spring.security.oauth2.client.provider.authentik.issuer-uri=${AUTH_PROVIDER_ISSUER:https://oauth.simonis.lol/application/o/casino-dev/}
|
||||
spring.security.oauth2.client.provider.authentik.authorization-uri=${AUTH_PROVIDER_AUTHORIZE_URI:https://oauth.simonis.lol/application/o/authorize/}
|
||||
spring.security.oauth2.client.provider.authentik.token-uri=${AUTH_PROVIDER_TOKEN_URI:https://oauth.simonis.lol/application/o/token/}
|
||||
spring.security.oauth2.client.provider.authentik.user-info-uri=${AUTH_PROVIDER_USERINFO_URI:https://oauth.simonis.lol/application/o/userinfo/}
|
||||
spring.security.oauth2.client.provider.authentik.jwk-set-uri=${AUTH_PROVIDER_JWKS_URI:https://oauth.simonis.lol/application/o/casino-dev/jwks/}
|
||||
spring.security.oauth2.client.provider.authentik.user-name-attribute=${AUTH_PROVIDER_NAME_ATTR:preferred_username}
|
||||
|
||||
# Resource server config
|
||||
spring.security.oauth2.resourceserver.jwt.issuer-uri=${AUTH_JWT_ISSUER_URI:https://oauth.simonis.lol/application/o/casino-dev}/
|
||||
spring.security.oauth2.resourceserver.jwt.jwk-set-uri=${AUTH_JWT_JWT_SET_URI:https://oauth.simonis.lol/application/o/casino-dev/jwks/}
|
||||
|
||||
#OIDC provider configuration:
|
||||
# Logging
|
||||
logging.level.org.springframework.security=DEBUG
|
||||
#validating JWT token against our Authentik server
|
||||
|
||||
# Swagger
|
||||
springdoc.swagger-ui.path=swagger
|
||||
springdoc.swagger-ui.try-it-out-enabled=true
|
||||
|
||||
|
|
|
@ -21,11 +21,8 @@
|
|||
"@tailwindcss/postcss": "^4.0.3",
|
||||
"ajv": "8.17.1",
|
||||
"ajv-formats": "3.0.1",
|
||||
"angular-oauth2-oidc": "^19.0.0",
|
||||
"countup.js": "^2.8.0",
|
||||
"gsap": "^3.12.7",
|
||||
"keycloak-angular": "^19.0.0",
|
||||
"keycloak-js": "^26.0.0",
|
||||
"postcss": "^8.5.1",
|
||||
"rxjs": "~7.8.2",
|
||||
"tailwindcss": "^4.0.3",
|
||||
|
@ -757,8 +754,6 @@
|
|||
|
||||
"angular-eslint": ["angular-eslint@19.3.0", "", { "dependencies": { "@angular-devkit/core": ">= 19.0.0 < 20.0.0", "@angular-devkit/schematics": ">= 19.0.0 < 20.0.0", "@angular-eslint/builder": "19.3.0", "@angular-eslint/eslint-plugin": "19.3.0", "@angular-eslint/eslint-plugin-template": "19.3.0", "@angular-eslint/schematics": "19.3.0", "@angular-eslint/template-parser": "19.3.0", "@typescript-eslint/types": "^8.0.0", "@typescript-eslint/utils": "^8.0.0" }, "peerDependencies": { "eslint": "^8.57.0 || ^9.0.0", "typescript": "*", "typescript-eslint": "^8.0.0" } }, "sha512-19hkkH3z/2wGhKk3LfttEBkl6CtQP/tFK6/mJoO/MbIkXV0SSJWtbPbOpEaxICLlfCw0oR6W9OoQqByWkwXjkQ=="],
|
||||
|
||||
"angular-oauth2-oidc": ["angular-oauth2-oidc@19.0.0", "", { "dependencies": { "tslib": "^2.5.2" }, "peerDependencies": { "@angular/common": ">=19.0.0", "@angular/core": ">=19.0.0" } }, "sha512-EogHyF7MpCJSjSKIyVmdB8pJu7dU5Ilj9VNVSnFbLng4F77PIlaE4egwKUlUvk0i4ZvmO9rLXNQCm05R7Tyhcw=="],
|
||||
|
||||
"ansi-colors": ["ansi-colors@4.1.3", "", {}, "sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw=="],
|
||||
|
||||
"ansi-escapes": ["ansi-escapes@4.3.2", "", { "dependencies": { "type-fest": "^0.21.3" } }, "sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ=="],
|
||||
|
@ -1275,10 +1270,6 @@
|
|||
|
||||
"karma-source-map-support": ["karma-source-map-support@1.4.0", "", { "dependencies": { "source-map-support": "^0.5.5" } }, "sha512-RsBECncGO17KAoJCYXjv+ckIz+Ii9NCi+9enk+rq6XC81ezYkb4/RHE6CTXdA7IOJqoF3wcaLfVG0CPmE5ca6A=="],
|
||||
|
||||
"keycloak-angular": ["keycloak-angular@19.0.2", "", { "dependencies": { "tslib": "^2.3.1" }, "peerDependencies": { "@angular/common": "^19", "@angular/core": "^19", "@angular/router": "^19", "keycloak-js": "^18 || ^19 || ^20 || ^21 || ^22 || ^23 || ^24 || ^25 || ^26" } }, "sha512-GzQKC/jFJLZRmUxWOEXkla+6shDAZFAOe6Z3qsw916Ckb/UhZnO704HMZrd8xyVB3RH6xOcNCp45oHmIiqJ7dA=="],
|
||||
|
||||
"keycloak-js": ["keycloak-js@26.1.4", "", {}, "sha512-4h2RicCzIAtsjKIG8DIO+8NKlpWX2fiNkbS0jlbtjZFbIGGjbQBzjS/5NkyWlzxamXVow9prHTIgIiwfo3GAmQ=="],
|
||||
|
||||
"keyv": ["keyv@4.5.4", "", { "dependencies": { "json-buffer": "3.0.1" } }, "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw=="],
|
||||
|
||||
"kind-of": ["kind-of@6.0.3", "", {}, "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw=="],
|
||||
|
|
|
@ -33,9 +33,6 @@
|
|||
"ajv-formats": "3.0.1",
|
||||
"countup.js": "^2.8.0",
|
||||
"gsap": "^3.12.7",
|
||||
"angular-oauth2-oidc": "^19.0.0",
|
||||
"keycloak-angular": "^19.0.0",
|
||||
"keycloak-js": "^26.0.0",
|
||||
"postcss": "^8.5.1",
|
||||
"rxjs": "~7.8.2",
|
||||
"tailwindcss": "^4.0.3",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { ChangeDetectionStrategy, Component } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { RouterOutlet } from '@angular/router';
|
||||
import { FooterComponent } from './shared/components/footer/footer.component';
|
||||
import { FooterComponent } from '@shared/components/footer/footer.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
|
|
|
@ -5,7 +5,6 @@ import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
|
|||
import { routes } from './app.routes';
|
||||
import { provideHttpClient, withInterceptors } from '@angular/common/http';
|
||||
import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
|
||||
import { OAuthStorage, provideOAuthClient } from 'angular-oauth2-oidc';
|
||||
import { httpInterceptor } from '@shared/interceptor/http.interceptor';
|
||||
|
||||
export const appConfig: ApplicationConfig = {
|
||||
|
@ -15,10 +14,5 @@ export const appConfig: ApplicationConfig = {
|
|||
provideHttpClient(withInterceptors([httpInterceptor])),
|
||||
provideExperimentalZonelessChangeDetection(),
|
||||
provideAnimationsAsync(),
|
||||
provideOAuthClient(),
|
||||
{
|
||||
provide: OAuthStorage,
|
||||
useFactory: () => localStorage,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
|
|
@ -8,8 +8,14 @@ export const routes: Routes = [
|
|||
component: LandingComponent,
|
||||
},
|
||||
{
|
||||
path: 'auth/callback',
|
||||
loadComponent: () => import('./feature/login-success/login-success.component'),
|
||||
path: 'login',
|
||||
loadComponent: () =>
|
||||
import('./feature/auth/login/login.component').then((m) => m.LoginComponent),
|
||||
},
|
||||
{
|
||||
path: 'register',
|
||||
loadComponent: () =>
|
||||
import('./feature/auth/register/register.component').then((m) => m.RegisterComponent),
|
||||
},
|
||||
{
|
||||
path: 'home',
|
||||
|
@ -24,7 +30,6 @@ export const routes: Routes = [
|
|||
{
|
||||
path: 'game/slots',
|
||||
loadComponent: () => import('./feature/game/slots/slots.component'),
|
||||
canActivate: [authGuard],
|
||||
},
|
||||
{
|
||||
path: 'game/lootboxes',
|
||||
|
|
77
frontend/src/app/feature/auth/login/login.component.html
Normal file
77
frontend/src/app/feature/auth/login/login.component.html
Normal file
|
@ -0,0 +1,77 @@
|
|||
<app-navbar />
|
||||
|
||||
<div class="min-h-screen bg-deep-blue flex items-center justify-center">
|
||||
<div class="modal-card max-w-md w-full">
|
||||
<h2 class="modal-heading text-center">Anmelden</h2>
|
||||
|
||||
<div *ngIf="errorMessage" class="bg-accent-red text-white p-4 rounded mb-4">
|
||||
{{ errorMessage }}
|
||||
</div>
|
||||
|
||||
<form [formGroup]="loginForm" (ngSubmit)="onSubmit()" class="space-y-4">
|
||||
<div>
|
||||
<label for="usernameOrEmail" class="text-text-secondary text-sm font-medium mb-1 block">
|
||||
Benutzername oder E-Mail
|
||||
</label>
|
||||
<input
|
||||
id="usernameOrEmail"
|
||||
type="text"
|
||||
formControlName="usernameOrEmail"
|
||||
class="w-full px-4 py-2.5 bg-deep-blue-light/50 text-white rounded-lg my-1 border border-deep-blue-light/30 focus:border-emerald/50 focus:ring-1 focus:ring-emerald/50 outline-none transition-all duration-200"
|
||||
placeholder="Gib deinen Benutzernamen oder E-Mail ein"
|
||||
/>
|
||||
|
||||
<div
|
||||
*ngIf="form['usernameOrEmail'].touched && form['usernameOrEmail'].errors"
|
||||
class="text-accent-red mt-1 text-sm"
|
||||
>
|
||||
<span *ngIf="form['usernameOrEmail'].errors?.['required']">
|
||||
Benutzername oder E-Mail ist erforderlich
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="password" class="text-text-secondary text-sm font-medium mb-1 block">
|
||||
Passwort
|
||||
</label>
|
||||
<input
|
||||
id="password"
|
||||
type="password"
|
||||
formControlName="password"
|
||||
class="w-full px-4 py-2.5 bg-deep-blue-light/50 text-white rounded-lg my-1 border border-deep-blue-light/30 focus:border-emerald/50 focus:ring-1 focus:ring-emerald/50 outline-none transition-all duration-200"
|
||||
placeholder="Gib dein Passwort ein"
|
||||
/>
|
||||
|
||||
<div
|
||||
*ngIf="form['password'].touched && form['password'].errors"
|
||||
class="text-accent-red mt-1 text-sm"
|
||||
>
|
||||
<span *ngIf="form['password'].errors?.['required']">Passwort ist erforderlich</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="pt-2">
|
||||
<button
|
||||
type="submit"
|
||||
[disabled]="loginForm.invalid || isLoading"
|
||||
class="button-primary w-full py-2.5 rounded"
|
||||
>
|
||||
{{ isLoading ? 'Anmeldung läuft...' : 'Anmelden' }}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="mt-6 text-center">
|
||||
<p class="text-sm text-text-secondary">
|
||||
Noch kein Konto?
|
||||
<a
|
||||
routerLink="/register"
|
||||
class="font-medium text-emerald hover:text-emerald-light transition-all duration-200"
|
||||
>
|
||||
Registrieren
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
58
frontend/src/app/feature/auth/login/login.component.ts
Normal file
58
frontend/src/app/feature/auth/login/login.component.ts
Normal file
|
@ -0,0 +1,58 @@
|
|||
import { Component } from '@angular/core';
|
||||
import { FormBuilder, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
|
||||
import { Router, RouterLink } from '@angular/router';
|
||||
import { LoginRequest } from '../../../model/auth/LoginRequest';
|
||||
import { AuthService } from '../../../service/auth.service';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { NavbarComponent } from '@shared/components/navbar/navbar.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-login',
|
||||
standalone: true,
|
||||
imports: [CommonModule, ReactiveFormsModule, RouterLink, NavbarComponent],
|
||||
templateUrl: './login.component.html',
|
||||
})
|
||||
export class LoginComponent {
|
||||
loginForm: FormGroup;
|
||||
errorMessage = '';
|
||||
isLoading = false;
|
||||
|
||||
constructor(
|
||||
private fb: FormBuilder,
|
||||
private authService: AuthService,
|
||||
private router: Router
|
||||
) {
|
||||
this.loginForm = this.fb.group({
|
||||
usernameOrEmail: ['', [Validators.required]],
|
||||
password: ['', [Validators.required]],
|
||||
});
|
||||
}
|
||||
|
||||
get form() {
|
||||
return this.loginForm.controls;
|
||||
}
|
||||
|
||||
onSubmit(): void {
|
||||
if (this.loginForm.invalid) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.isLoading = true;
|
||||
this.errorMessage = '';
|
||||
|
||||
const loginRequest: LoginRequest = {
|
||||
usernameOrEmail: this.form['usernameOrEmail'].value,
|
||||
password: this.form['password'].value,
|
||||
};
|
||||
|
||||
this.authService.login(loginRequest).subscribe({
|
||||
next: () => {
|
||||
this.router.navigate(['/home']);
|
||||
},
|
||||
error: (err) => {
|
||||
this.isLoading = false;
|
||||
this.errorMessage = err.error?.message || 'Failed to login. Please check your credentials.';
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
102
frontend/src/app/feature/auth/register/register.component.html
Normal file
102
frontend/src/app/feature/auth/register/register.component.html
Normal file
|
@ -0,0 +1,102 @@
|
|||
<app-navbar />
|
||||
|
||||
<div class="min-h-screen bg-deep-blue flex items-center justify-center">
|
||||
<div class="modal-card max-w-md w-full">
|
||||
<h2 class="modal-heading text-center">Konto erstellen</h2>
|
||||
|
||||
<div *ngIf="errorMessage" class="bg-accent-red text-white p-4 rounded mb-4">
|
||||
{{ errorMessage }}
|
||||
</div>
|
||||
|
||||
<form [formGroup]="registerForm" (ngSubmit)="onSubmit()" class="space-y-4">
|
||||
<div>
|
||||
<label for="email" class="text-text-secondary text-sm font-medium mb-1 block">E-Mail</label>
|
||||
<input
|
||||
id="email"
|
||||
type="email"
|
||||
formControlName="email"
|
||||
class="w-full px-4 py-2.5 bg-deep-blue-light/50 text-white rounded-lg my-1 border border-deep-blue-light/30 focus:border-emerald/50 focus:ring-1 focus:ring-emerald/50 outline-none transition-all duration-200"
|
||||
placeholder="Gib deine E-Mail-Adresse ein"
|
||||
/>
|
||||
|
||||
<div
|
||||
*ngIf="form['email'].touched && form['email'].errors"
|
||||
class="text-accent-red mt-1 text-sm"
|
||||
>
|
||||
<span *ngIf="form['email'].errors?.['required']">E-Mail ist erforderlich</span>
|
||||
<span *ngIf="form['email'].errors?.['email']">
|
||||
Bitte gib eine gültige E-Mail-Adresse ein
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="username" class="text-text-secondary text-sm font-medium mb-1 block"
|
||||
>Benutzername</label
|
||||
>
|
||||
<input
|
||||
id="username"
|
||||
type="text"
|
||||
formControlName="username"
|
||||
class="w-full px-4 py-2.5 bg-deep-blue-light/50 text-white rounded-lg my-1 border border-deep-blue-light/30 focus:border-emerald/50 focus:ring-1 focus:ring-emerald/50 outline-none transition-all duration-200"
|
||||
placeholder="Wähle einen Benutzernamen"
|
||||
/>
|
||||
|
||||
<div
|
||||
*ngIf="form['username'].touched && form['username'].errors"
|
||||
class="text-accent-red mt-1 text-sm"
|
||||
>
|
||||
<span *ngIf="form['username'].errors?.['required']">Benutzername ist erforderlich</span>
|
||||
<span *ngIf="form['username'].errors?.['minlength']">
|
||||
Benutzername muss mindestens 3 Zeichen haben
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="password" class="text-text-secondary text-sm font-medium mb-1 block"
|
||||
>Passwort</label
|
||||
>
|
||||
<input
|
||||
id="password"
|
||||
type="password"
|
||||
formControlName="password"
|
||||
class="w-full px-4 py-2.5 bg-deep-blue-light/50 text-white rounded-lg my-1 border border-deep-blue-light/30 focus:border-emerald/50 focus:ring-1 focus:ring-emerald/50 outline-none transition-all duration-200"
|
||||
placeholder="Erstelle ein Passwort"
|
||||
/>
|
||||
|
||||
<div
|
||||
*ngIf="form['password'].touched && form['password'].errors"
|
||||
class="text-accent-red mt-1 text-sm"
|
||||
>
|
||||
<span *ngIf="form['password'].errors?.['required']">Passwort ist erforderlich</span>
|
||||
<span *ngIf="form['password'].errors?.['minlength']">
|
||||
Passwort muss mindestens 6 Zeichen haben
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="pt-2">
|
||||
<button
|
||||
type="submit"
|
||||
[disabled]="registerForm.invalid || isLoading"
|
||||
class="button-primary w-full py-2.5 rounded"
|
||||
>
|
||||
{{ isLoading ? 'Konto wird erstellt...' : 'Registrieren' }}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="mt-6 text-center">
|
||||
<p class="text-sm text-text-secondary">
|
||||
Bereits ein Konto?
|
||||
<a
|
||||
routerLink="/login"
|
||||
class="font-medium text-emerald hover:text-emerald-light transition-all duration-200"
|
||||
>
|
||||
Anmelden
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
75
frontend/src/app/feature/auth/register/register.component.ts
Normal file
75
frontend/src/app/feature/auth/register/register.component.ts
Normal file
|
@ -0,0 +1,75 @@
|
|||
import { Component } from '@angular/core';
|
||||
import { FormBuilder, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
|
||||
import { Router, RouterLink } from '@angular/router';
|
||||
import { RegisterRequest } from '../../../model/auth/RegisterRequest';
|
||||
import { AuthService } from '@service/auth.service';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { NavbarComponent } from '@shared/components/navbar/navbar.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-register',
|
||||
standalone: true,
|
||||
imports: [CommonModule, ReactiveFormsModule, RouterLink, NavbarComponent],
|
||||
templateUrl: './register.component.html',
|
||||
})
|
||||
export class RegisterComponent {
|
||||
registerForm: FormGroup;
|
||||
errorMessage = '';
|
||||
isLoading = false;
|
||||
|
||||
constructor(
|
||||
private fb: FormBuilder,
|
||||
private authService: AuthService,
|
||||
private router: Router
|
||||
) {
|
||||
this.registerForm = this.fb.group({
|
||||
email: ['', [Validators.required, Validators.email]],
|
||||
username: ['', [Validators.required, Validators.minLength(3)]],
|
||||
password: ['', [Validators.required, Validators.minLength(6)]],
|
||||
});
|
||||
}
|
||||
|
||||
get form() {
|
||||
return this.registerForm.controls;
|
||||
}
|
||||
|
||||
onSubmit(): void {
|
||||
if (this.registerForm.invalid) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.isLoading = true;
|
||||
this.errorMessage = '';
|
||||
|
||||
const registerRequest: RegisterRequest = {
|
||||
email: this.form['email'].value,
|
||||
username: this.form['username'].value,
|
||||
password: this.form['password'].value,
|
||||
};
|
||||
|
||||
this.authService.register(registerRequest).subscribe({
|
||||
next: () => {
|
||||
// After registration, log in the user
|
||||
this.authService
|
||||
.login({
|
||||
usernameOrEmail: registerRequest.email,
|
||||
password: registerRequest.password,
|
||||
})
|
||||
.subscribe({
|
||||
next: () => {
|
||||
this.router.navigate(['/home']);
|
||||
},
|
||||
error: () => {
|
||||
this.isLoading = false;
|
||||
this.errorMessage =
|
||||
'Registration successful but failed to login automatically. Please log in manually.';
|
||||
},
|
||||
});
|
||||
},
|
||||
error: (err) => {
|
||||
this.isLoading = false;
|
||||
this.errorMessage = err.error?.message || 'Failed to register. Please try again.';
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
|
@ -51,7 +51,7 @@ export default class BlackjackComponent implements OnInit {
|
|||
debtAmount = signal(0);
|
||||
|
||||
ngOnInit(): void {
|
||||
this.userService.currentUser$.subscribe((user) => {
|
||||
this.userService.getCurrentUser().subscribe((user) => {
|
||||
if (user) {
|
||||
this.balance.set(user.balance);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { ChangeDetectionStrategy, Component, inject, OnInit, signal } from '@angular/core';
|
||||
import { NavbarComponent } from '@shared/components/navbar/navbar.component';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { KeyValuePipe, NgClass, UpperCasePipe } from '@angular/common';
|
||||
import { KeyValuePipe, UpperCasePipe } from '@angular/common';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
|
||||
interface SlotResult {
|
||||
|
@ -13,7 +13,7 @@ interface SlotResult {
|
|||
@Component({
|
||||
selector: 'app-slots',
|
||||
standalone: true,
|
||||
imports: [NavbarComponent, KeyValuePipe, UpperCasePipe, NgClass, FormsModule],
|
||||
imports: [NavbarComponent, KeyValuePipe, UpperCasePipe, FormsModule],
|
||||
templateUrl: './slots.component.html',
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
|
|
|
@ -10,9 +10,29 @@
|
|||
<div class="welcome-bonus">200% bis zu 500€</div>
|
||||
<p class="bonus-description">+ 200 Freispiele</p>
|
||||
|
||||
<button class="w-full sm:w-auto button-primary px-6 sm:px-8 py-3 shadow-lg">
|
||||
Bonus Sichern
|
||||
</button>
|
||||
<div class="flex justify-center space-x-4 mt-6">
|
||||
@if (authService.isLoggedIn()) {
|
||||
<a
|
||||
routerLink="/home"
|
||||
class="w-full sm:w-auto button-primary px-6 sm:px-8 py-3 shadow-lg"
|
||||
>
|
||||
Spiele
|
||||
</a>
|
||||
} @else {
|
||||
<a
|
||||
routerLink="/register"
|
||||
class="w-full sm:w-auto button-primary px-6 sm:px-8 py-3 shadow-lg"
|
||||
>
|
||||
Konto erstellen
|
||||
</a>
|
||||
<a
|
||||
routerLink="/login"
|
||||
class="w-full sm:w-auto bg-slate-700 text-white hover:bg-slate-600 px-6 sm:px-8 py-3 shadow-lg rounded"
|
||||
>
|
||||
Anmelden
|
||||
</a>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="relative mb-16">
|
||||
|
|
|
@ -1,17 +1,20 @@
|
|||
import { ChangeDetectionStrategy, Component, OnDestroy, OnInit } from '@angular/core';
|
||||
import { ChangeDetectionStrategy, Component, inject, OnDestroy, OnInit } from '@angular/core';
|
||||
import { NgFor } from '@angular/common';
|
||||
import { NavbarComponent } from '@shared/components/navbar/navbar.component';
|
||||
import { RouterLink } from '@angular/router';
|
||||
import { AuthService } from '@service/auth.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-landing-page',
|
||||
standalone: true,
|
||||
imports: [NavbarComponent, NgFor],
|
||||
imports: [NavbarComponent, NgFor, RouterLink],
|
||||
templateUrl: './landing.component.html',
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class LandingComponent implements OnInit, OnDestroy {
|
||||
currentSlide = 0;
|
||||
private autoplayInterval: ReturnType<typeof setInterval> | undefined;
|
||||
authService: AuthService = inject(AuthService);
|
||||
|
||||
ngOnInit() {
|
||||
this.startAutoplay();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Component, ChangeDetectorRef } from '@angular/core';
|
||||
import { ChangeDetectorRef, Component } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { LootboxService } from '../services/lootbox.service';
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Component, OnInit, ChangeDetectorRef } from '@angular/core';
|
||||
import { ChangeDetectorRef, Component, OnInit } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { NavbarComponent } from '@shared/components/navbar/navbar.component';
|
||||
import { LootboxService } from '../services/lootbox.service';
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Injectable, inject } from '@angular/core';
|
||||
import { inject, Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Observable, catchError } from 'rxjs';
|
||||
import { catchError, Observable } from 'rxjs';
|
||||
import { LootBox, Reward } from 'app/model/LootBox';
|
||||
|
||||
@Injectable({
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
export interface User {
|
||||
authentikId: string;
|
||||
id: number;
|
||||
email: string;
|
||||
username: string;
|
||||
balance: number;
|
||||
}
|
||||
|
|
4
frontend/src/app/model/auth/AuthResponse.ts
Normal file
4
frontend/src/app/model/auth/AuthResponse.ts
Normal file
|
@ -0,0 +1,4 @@
|
|||
export interface AuthResponse {
|
||||
token: string;
|
||||
tokenType: string;
|
||||
}
|
4
frontend/src/app/model/auth/LoginRequest.ts
Normal file
4
frontend/src/app/model/auth/LoginRequest.ts
Normal file
|
@ -0,0 +1,4 @@
|
|||
export interface LoginRequest {
|
||||
usernameOrEmail: string;
|
||||
password: string;
|
||||
}
|
5
frontend/src/app/model/auth/RegisterRequest.ts
Normal file
5
frontend/src/app/model/auth/RegisterRequest.ts
Normal file
|
@ -0,0 +1,5 @@
|
|||
export interface RegisterRequest {
|
||||
email: string;
|
||||
username: string;
|
||||
password: string;
|
||||
}
|
|
@ -1,208 +1,97 @@
|
|||
import { inject, Injectable } from '@angular/core';
|
||||
import { AuthConfig, OAuthEvent, OAuthService } from 'angular-oauth2-oidc';
|
||||
import { UserService } from './user.service';
|
||||
import { User } from '../model/User';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { BehaviorSubject, Observable, tap } from 'rxjs';
|
||||
import { Router } from '@angular/router';
|
||||
import { environment } from '../../environments/environment';
|
||||
import { catchError, from, of } from 'rxjs';
|
||||
import { LoginRequest } from '../model/auth/LoginRequest';
|
||||
import { RegisterRequest } from '../model/auth/RegisterRequest';
|
||||
import { AuthResponse } from '../model/auth/AuthResponse';
|
||||
import { User } from '../model/User';
|
||||
import { environment } from '@environments/environment';
|
||||
|
||||
const TOKEN_KEY = 'token';
|
||||
const USER_KEY = 'user';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class AuthService {
|
||||
private readonly authConfig: AuthConfig = {
|
||||
issuer: 'https://oauth.simonis.lol/application/o/casino-dev/',
|
||||
clientId: environment.OAUTH_CLIENT_ID,
|
||||
dummyClientSecret: environment.OAUTH_CLIENT_SECRET,
|
||||
scope: `openid email profile ${environment.OAUTH_CLIENT_ID}`,
|
||||
responseType: 'code',
|
||||
redirectUri: window.location.origin + '/auth/callback',
|
||||
postLogoutRedirectUri: '',
|
||||
redirectUriAsPostLogoutRedirectUriFallback: false,
|
||||
oidc: true,
|
||||
requestAccessToken: true,
|
||||
tokenEndpoint: 'https://oauth.simonis.lol/application/o/token/',
|
||||
userinfoEndpoint: 'https://oauth.simonis.lol/application/o/userinfo/',
|
||||
strictDiscoveryDocumentValidation: false,
|
||||
skipIssuerCheck: true,
|
||||
disableAtHashCheck: true,
|
||||
requireHttps: false,
|
||||
showDebugInformation: false,
|
||||
sessionChecksEnabled: false,
|
||||
};
|
||||
private authUrl = `${environment.apiUrl}/auth`;
|
||||
private userUrl = `${environment.apiUrl}/users`;
|
||||
|
||||
private userService: UserService = inject(UserService);
|
||||
private oauthService: OAuthService = inject(OAuthService);
|
||||
private router: Router = inject(Router);
|
||||
private currentUserSubject: BehaviorSubject<User | null>;
|
||||
public currentUser: Observable<User | null>;
|
||||
|
||||
private user: User | null = null;
|
||||
constructor(
|
||||
private http: HttpClient,
|
||||
private router: Router
|
||||
) {
|
||||
this.currentUserSubject = new BehaviorSubject<User | null>(this.getUserFromStorage());
|
||||
this.currentUser = this.currentUserSubject.asObservable();
|
||||
|
||||
constructor() {
|
||||
this.oauthService.configure(this.authConfig);
|
||||
this.setupEventHandling();
|
||||
|
||||
const hasAuthParams =
|
||||
window.location.search.includes('code=') ||
|
||||
window.location.search.includes('token=') ||
|
||||
window.location.search.includes('id_token=');
|
||||
|
||||
if (hasAuthParams) {
|
||||
this.processCodeFlow();
|
||||
} else {
|
||||
this.checkExistingSession();
|
||||
// Check if token exists and load user data
|
||||
if (this.getToken()) {
|
||||
this.loadCurrentUser();
|
||||
}
|
||||
}
|
||||
|
||||
private processCodeFlow() {
|
||||
this.oauthService
|
||||
.tryLogin({
|
||||
onTokenReceived: () => {
|
||||
this.handleSuccessfulLogin();
|
||||
},
|
||||
public get currentUserValue(): User | null {
|
||||
return this.currentUserSubject.value;
|
||||
}
|
||||
|
||||
login(loginRequest: LoginRequest): Observable<AuthResponse> {
|
||||
return this.http.post<AuthResponse>(`${this.authUrl}/login`, loginRequest).pipe(
|
||||
tap((response) => {
|
||||
this.setToken(response.token);
|
||||
this.loadCurrentUser();
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error('Error processing code flow:', err);
|
||||
});
|
||||
);
|
||||
}
|
||||
|
||||
private checkExistingSession() {
|
||||
this.oauthService
|
||||
.loadDiscoveryDocumentAndTryLogin()
|
||||
.then((isLoggedIn) => {
|
||||
if (isLoggedIn && !this.user) {
|
||||
this.handleSuccessfulLogin();
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error('Error during initial login attempt:', err);
|
||||
});
|
||||
register(registerRequest: RegisterRequest): Observable<User> {
|
||||
return this.http.post<User>(`${this.authUrl}/register`, registerRequest);
|
||||
}
|
||||
|
||||
private setupEventHandling() {
|
||||
this.oauthService.events.subscribe((event: OAuthEvent) => {
|
||||
if (event.type === 'token_received') {
|
||||
this.handleSuccessfulLogin();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private handleSuccessfulLogin() {
|
||||
const claims = this.oauthService.getIdentityClaims();
|
||||
|
||||
if (claims && (claims['sub'] || claims['email'])) {
|
||||
this.processUserProfile(claims);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
from(this.oauthService.loadUserProfile())
|
||||
.pipe(
|
||||
catchError((error) => {
|
||||
console.error('Error loading user profile:', error);
|
||||
if (this.oauthService.hasValidAccessToken()) {
|
||||
this.oauthService.getAccessToken();
|
||||
const minimalProfile = {
|
||||
sub: 'user-' + Math.random().toString(36).substring(2, 10),
|
||||
preferred_username: 'user' + Date.now(),
|
||||
};
|
||||
return of({ info: minimalProfile });
|
||||
}
|
||||
return of(null);
|
||||
})
|
||||
)
|
||||
.subscribe((profile) => {
|
||||
if (profile) {
|
||||
this.processUserProfile(profile);
|
||||
} else {
|
||||
logout(): void {
|
||||
localStorage.removeItem(TOKEN_KEY);
|
||||
localStorage.removeItem(USER_KEY);
|
||||
this.currentUserSubject.next(null);
|
||||
this.router.navigate(['/']);
|
||||
}
|
||||
});
|
||||
} catch (err) {
|
||||
console.error('Exception in handleSuccessfulLogin:', err);
|
||||
if (this.oauthService.hasValidAccessToken()) {
|
||||
this.router.navigate(['/home']);
|
||||
} else {
|
||||
this.router.navigate(['/']);
|
||||
}
|
||||
}
|
||||
|
||||
isLoggedIn(): boolean {
|
||||
return !!this.getToken();
|
||||
}
|
||||
|
||||
private processUserProfile(profile: unknown) {
|
||||
this.fromUserProfile(profile as Record<string, unknown>).subscribe({
|
||||
getToken(): string | null {
|
||||
return localStorage.getItem(TOKEN_KEY);
|
||||
}
|
||||
|
||||
public loadCurrentUser(): void {
|
||||
this.http.get<User>(`${this.userUrl}/me`).subscribe({
|
||||
next: (user) => {
|
||||
this.user = user;
|
||||
this.router.navigate(['home']);
|
||||
this.setUser(user);
|
||||
},
|
||||
error: (err) => {
|
||||
console.error('Error creating/retrieving user:', err);
|
||||
if (this.oauthService.hasValidAccessToken()) {
|
||||
this.router.navigate(['/home']);
|
||||
} else {
|
||||
this.router.navigate(['/']);
|
||||
}
|
||||
error: () => {
|
||||
this.logout();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
login() {
|
||||
try {
|
||||
this.oauthService
|
||||
.loadDiscoveryDocument()
|
||||
.then(() => {
|
||||
this.oauthService.initLoginFlow();
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error('Error loading discovery document:', err);
|
||||
this.oauthService.initLoginFlow();
|
||||
});
|
||||
} catch (err) {
|
||||
console.error('Exception in login:', err);
|
||||
const redirectUri = this.authConfig.redirectUri || window.location.origin + '/auth/callback';
|
||||
const scope = this.authConfig.scope || 'openid email profile';
|
||||
const authUrl = `${this.authConfig.issuer}authorize?client_id=${this.authConfig.clientId}&redirect_uri=${encodeURIComponent(redirectUri)}&response_type=code&scope=${encodeURIComponent(scope)}`;
|
||||
window.location.href = authUrl;
|
||||
}
|
||||
private setToken(token: string): void {
|
||||
localStorage.setItem(TOKEN_KEY, token);
|
||||
}
|
||||
|
||||
logout() {
|
||||
try {
|
||||
this.user = null;
|
||||
|
||||
this.oauthService.logOut(true);
|
||||
|
||||
if (window.location.href.includes('id_token') || window.location.href.includes('logout')) {
|
||||
window.location.href = window.location.origin;
|
||||
private setUser(user: User): void {
|
||||
localStorage.setItem(USER_KEY, JSON.stringify(user));
|
||||
this.currentUserSubject.next(user);
|
||||
}
|
||||
|
||||
localStorage.removeItem('access_token');
|
||||
localStorage.removeItem('id_token');
|
||||
localStorage.removeItem('refresh_token');
|
||||
sessionStorage.removeItem('access_token');
|
||||
sessionStorage.removeItem('id_token');
|
||||
sessionStorage.removeItem('refresh_token');
|
||||
|
||||
this.router.navigate(['/']);
|
||||
} catch (err) {
|
||||
console.error('Exception in logout:', err);
|
||||
localStorage.clear();
|
||||
sessionStorage.clear();
|
||||
this.router.navigate(['/']);
|
||||
}
|
||||
private getUserFromStorage(): User | null {
|
||||
const user = localStorage.getItem(USER_KEY);
|
||||
return user ? JSON.parse(user) : null;
|
||||
}
|
||||
|
||||
isLoggedIn() {
|
||||
return this.oauthService.hasValidAccessToken();
|
||||
}
|
||||
|
||||
private fromUserProfile(profile: Record<string, unknown>) {
|
||||
return this.userService.getOrCreateUser(profile);
|
||||
}
|
||||
|
||||
getAccessToken() {
|
||||
return this.oauthService.getAccessToken();
|
||||
}
|
||||
|
||||
getUser() {
|
||||
return this.user;
|
||||
getUser(): User | null {
|
||||
return this.currentUserValue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,28 +2,19 @@ import { inject, Injectable } from '@angular/core';
|
|||
import { HttpClient } from '@angular/common/http';
|
||||
import { BehaviorSubject, catchError, EMPTY, Observable, tap } from 'rxjs';
|
||||
import { User } from '../model/User';
|
||||
import { AuthService } from '@service/auth.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class UserService {
|
||||
private http: HttpClient = inject(HttpClient);
|
||||
private currentUserSubject = new BehaviorSubject<User | null>(null);
|
||||
public currentUserSubject = new BehaviorSubject<User | null>(null);
|
||||
public currentUser$ = this.currentUserSubject.asObservable();
|
||||
|
||||
constructor() {
|
||||
this.getCurrentUser().subscribe();
|
||||
}
|
||||
|
||||
public getUser(id: string): Observable<User | null> {
|
||||
return this.http.get<User | null>(`/backend/user/${id}`).pipe(
|
||||
catchError(() => EMPTY),
|
||||
tap((user) => this.currentUserSubject.next(user))
|
||||
);
|
||||
}
|
||||
private http: HttpClient = inject(HttpClient);
|
||||
private authService = inject(AuthService);
|
||||
|
||||
public getCurrentUser(): Observable<User | null> {
|
||||
return this.http.get<User | null>('/backend/user').pipe(
|
||||
return this.http.get<User | null>('/backend/users/me').pipe(
|
||||
catchError(() => EMPTY),
|
||||
tap((user) => this.currentUserSubject.next(user))
|
||||
);
|
||||
|
@ -31,6 +22,7 @@ export class UserService {
|
|||
|
||||
public refreshCurrentUser(): void {
|
||||
this.getCurrentUser().subscribe();
|
||||
this.authService.loadCurrentUser();
|
||||
}
|
||||
|
||||
public updateLocalBalance(amount: number): void {
|
||||
|
@ -43,29 +35,4 @@ export class UserService {
|
|||
this.currentUserSubject.next(updatedUser);
|
||||
}
|
||||
}
|
||||
|
||||
public createUser(id: string, username: string): Observable<User> {
|
||||
return this.http
|
||||
.post<User>('/backend/user', {
|
||||
authentikId: id,
|
||||
username: username,
|
||||
})
|
||||
.pipe(tap((user) => this.currentUserSubject.next(user)));
|
||||
}
|
||||
|
||||
public getOrCreateUser(profile: Record<string, unknown>): Observable<User> {
|
||||
const info = profile['info'] as Record<string, unknown> | undefined;
|
||||
const id = (info?.['sub'] as string) || (profile['sub'] as string);
|
||||
const username =
|
||||
(info?.['preferred_username'] as string) ||
|
||||
(profile['preferred_username'] as string) ||
|
||||
(profile['email'] as string) ||
|
||||
(profile['name'] as string);
|
||||
|
||||
if (!id || !username) {
|
||||
throw new Error('Invalid user profile data');
|
||||
}
|
||||
|
||||
return this.createUser(id, username);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,12 @@
|
|||
|
||||
<div class="hidden md:flex items-center space-x-4">
|
||||
@if (!isLoggedIn) {
|
||||
<button (click)="login()" class="button-primary px-4 py-1.5">Anmelden</button>
|
||||
<a routerLink="/login" class="button-primary px-4 py-1.5">Anmelden</a>
|
||||
<a
|
||||
routerLink="/register"
|
||||
class="bg-emerald-700 text-white hover:bg-emerald-600 px-4 py-1.5 rounded"
|
||||
>Registrieren</a
|
||||
>
|
||||
}
|
||||
@if (isLoggedIn) {
|
||||
<div
|
||||
|
@ -66,7 +71,14 @@
|
|||
<a routerLink="/games" class="nav-mobile-link">Spiele</a>
|
||||
<div class="pt-2 space-y-2">
|
||||
@if (!isLoggedIn) {
|
||||
<button (click)="login()" class="button-primary w-full py-1.5">Anmelden</button>
|
||||
<a routerLink="/login" class="button-primary w-full py-1.5 block text-center"
|
||||
>Anmelden</a
|
||||
>
|
||||
<a
|
||||
routerLink="/register"
|
||||
class="bg-emerald-700 text-white hover:bg-emerald-600 w-full py-1.5 rounded block text-center"
|
||||
>Registrieren</a
|
||||
>
|
||||
}
|
||||
@if (isLoggedIn) {
|
||||
<button (click)="logout()" class="button-primary w-full py-1.5">Abmelden</button>
|
||||
|
|
|
@ -7,10 +7,10 @@ import {
|
|||
signal,
|
||||
} from '@angular/core';
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { AuthService } from '../../../service/auth.service';
|
||||
import { UserService } from '@service/user.service';
|
||||
import { AuthService } from '@service/auth.service';
|
||||
import { Subscription } from 'rxjs';
|
||||
import { AnimatedNumberComponent } from '@blackjack/components/animated-number/animated-number.component';
|
||||
import { UserService } from '@service/user.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-navbar',
|
||||
|
@ -24,12 +24,15 @@ export class NavbarComponent implements OnInit, OnDestroy {
|
|||
private authService: AuthService = inject(AuthService);
|
||||
isLoggedIn = this.authService.isLoggedIn();
|
||||
|
||||
private userService = inject(UserService);
|
||||
private userSubscription: Subscription | undefined;
|
||||
private authSubscription: Subscription | undefined;
|
||||
public balance = signal(0);
|
||||
private userService = inject(UserService);
|
||||
|
||||
ngOnInit() {
|
||||
this.userSubscription = this.userService.currentUser$.subscribe((user) => {
|
||||
// Subscribe to auth changes
|
||||
this.authSubscription = this.authService.currentUser.subscribe((user) => {
|
||||
this.isLoggedIn = !!user;
|
||||
this.balance.set(user?.balance ?? 0);
|
||||
console.log('Updated navbar balance:', user?.balance);
|
||||
});
|
||||
|
@ -41,13 +44,8 @@ export class NavbarComponent implements OnInit, OnDestroy {
|
|||
if (this.userSubscription) {
|
||||
this.userSubscription.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
login() {
|
||||
try {
|
||||
this.authService.login();
|
||||
} catch (error) {
|
||||
console.error('Login failed:', error);
|
||||
if (this.authSubscription) {
|
||||
this.authSubscription.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,21 +1,32 @@
|
|||
import { HttpInterceptorFn } from '@angular/common/http';
|
||||
import { inject } from '@angular/core';
|
||||
import { OAuthStorage } from 'angular-oauth2-oidc';
|
||||
|
||||
const TOKEN_KEY = 'token';
|
||||
|
||||
export const httpInterceptor: HttpInterceptorFn = (req, next) => {
|
||||
const oauthStorage = inject(OAuthStorage);
|
||||
const token = localStorage.getItem(TOKEN_KEY);
|
||||
|
||||
if (oauthStorage.getItem('access_token')) {
|
||||
// Always add CORS headers
|
||||
if (token) {
|
||||
return next(
|
||||
req.clone({
|
||||
setHeaders: {
|
||||
Authorization: 'Bearer ' + oauthStorage.getItem('access_token'),
|
||||
'Access-Control-Allow-Origin': '*',
|
||||
Authorization: `Bearer ${token}`,
|
||||
'Referrer-Policy': 'no-referrer',
|
||||
'Access-Control-Allow-Origin': '*',
|
||||
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',
|
||||
'Access-Control-Allow-Headers': '*',
|
||||
},
|
||||
})
|
||||
);
|
||||
} else {
|
||||
return next(req);
|
||||
return next(
|
||||
req.clone({
|
||||
setHeaders: {
|
||||
'Access-Control-Allow-Origin': '*',
|
||||
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',
|
||||
'Access-Control-Allow-Headers': '*',
|
||||
},
|
||||
})
|
||||
);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
export const environment = {
|
||||
STRIPE_KEY:
|
||||
'pk_test_51QrePYIvCfqz7ANgMizBorPpVjJ8S6gcaL4yvcMQnVaKyReqcQ6jqaQEF7aDZbDu8rNVsTZrw8ABek4ToxQX7KZe00jpGh8naG',
|
||||
OAUTH_CLIENT_ID: 'MDqjm1kcWKuZfqHJXjxwAV20i44aT7m4VhhTL3Nm',
|
||||
OAUTH_CLIENT_SECRET:
|
||||
'GY2F8te6iAVYt1TNAUVLzWZEXb6JoMNp6chbjqaXNq4gS5xTDL54HqBiAlV1jFKarN28LQ7FUsYX4SbwjfEhZhgeoKuBnZKjR9eiu7RawnGgxIK9ffvUfMkjRxnmiGI5',
|
||||
apiUrl: 'http://localhost:4200/backend',
|
||||
};
|
||||
|
|
Reference in a new issue