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
3 changes: 2 additions & 1 deletion src/main/java/com/devsuperior/bds03/config/AppConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
@Configuration
public class AppConfig {

@Value("${jwt.secret}")
@Value("${jwt.secret}")
private String jwtSecret;


@Bean
public BCryptPasswordEncoder passwordEncoder() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdap

@Value("${security.oauth2.client.client-id}")
private String clientId;

@Value("${security.oauth2.client.client-secret}")
private String clientSecret;

Expand All @@ -45,7 +45,8 @@ public void configure(AuthorizationServerSecurityConfigurer security) throws Exc

@Override
public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
clients.inMemory()

clients.inMemory()
.withClient(clientId)
.secret(passwordEncoder.encode(clientSecret))
.scopes("read", "write")
Expand All @@ -55,9 +56,9 @@ public void configure(ClientDetailsServiceConfigurer clients) throws Exception {

@Override
public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {

endpoints.authenticationManager(authenticationManager)
.tokenStore(tokenStore)
.accessTokenConverter(accessTokenConverter);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void configure(ResourceServerSecurityConfigurer resources) throws Excepti
@Override
public void configure(HttpSecurity http) throws Exception {

// H2
// H2
if (Arrays.asList(env.getActiveProfiles()).contains("test")) {
http.headers().frameOptions().disable();
}
Expand All @@ -44,4 +44,5 @@ public void configure(HttpSecurity http) throws Exception {
.antMatchers(HttpMethod.GET, OPERATOR_GET).hasAnyRole("OPERATOR", "ADMIN")
.anyRequest().hasAnyRole("ADMIN");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder);

}

@Override
Expand All @@ -36,4 +37,5 @@ public void configure(WebSecurity web) throws Exception {
protected AuthenticationManager authenticationManager() throws Exception {
return super.authenticationManager();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.io.Serializable;

public class FieldMessage implements Serializable {

private static final long serialVersionUID = 1L;

private String fieldName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

@ControllerAdvice
public class ResourceExceptionHandler {

@ExceptionHandler(MethodArgumentNotValidException.class)
public ResponseEntity<ValidationError> validation(MethodArgumentNotValidException e, HttpServletRequest request) {
HttpStatus status = HttpStatus.UNPROCESSABLE_ENTITY;
Expand All @@ -30,4 +29,5 @@ public ResponseEntity<ValidationError> validation(MethodArgumentNotValidExceptio

return ResponseEntity.status(status).body(err);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ public class StandardError implements Serializable {

public StandardError() {
}

public Instant getTimestamp() {
return timestamp;
}

public void setTimestamp(Instant timestamp) {
this.timestamp = timestamp;
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/devsuperior/bds03/dto/EmployeeDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class EmployeeDTO implements Serializable {
private String email;

@NotNull(message = "Campo requerido")

private Long departmentId;

public EmployeeDTO() {
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ security.oauth2.client.client-secret=${CLIENT_SECRET:myclientsecret}

jwt.secret=${JWT_SECRET:MY-JWT-SECRET}
jwt.duration=${JWT_DURATION:86400}

1 change: 1 addition & 0 deletions src/main/resources/data.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
INSERT INTO tb_user (email, password) VALUES ('ana@gmail.com', '$2a$10$eACCYoNOHEqXve8aIWT8Nu3PkMXWBaOxJ9aORUYzfMQCbVBIhZ8tG');
INSERT INTO tb_user (email, password) VALUES ('bob@gmail.com', '$2a$10$eACCYoNOHEqXve8aIWT8Nu3PkMXWBaOxJ9aORUYzfMQCbVBIhZ8tG');


INSERT INTO tb_role (authority) VALUES ('ROLE_OPERATOR');
INSERT INTO tb_role (authority) VALUES ('ROLE_ADMIN');

Expand Down