From eaae8d9a01a4fcfb9501dbb60f68047e71b881e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=A3?= Date: Mon, 12 Feb 2024 15:53:42 -0300 Subject: [PATCH] Implement Spring Boot Actuator for application monitoring and management. --- .idea/workspace.xml | 32 +++++++++---------- pom.xml | 5 +++ .../wpdauth/security/WebSecurityConfig.java | 11 ++++--- src/main/resources/application.properties | 17 ++++++++++ 4 files changed, 44 insertions(+), 21 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 25ff725..47af410 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,11 +5,9 @@ - - - + - { + "keyToString": { + "RunOnceActivity.OpenProjectViewOnStart": "true", + "RunOnceActivity.ShowReadmeOnStart": "true", + "WebServerToolWindowFactoryState": "false", + "git-widget-placeholder": "main", + "last_opened_file_path": "C:/xampp/htdocs/java-wpd-auth/WPD-Auth-PR/WPD-Auth", + "node.js.detected.package.eslint": "true", + "node.js.detected.package.tslint": "true", + "node.js.selected.package.eslint": "(autodetect)", + "node.js.selected.package.tslint": "(autodetect)", + "nodejs_package_manager_path": "npm", + "settings.editor.selected.configurable": "reference.settings.project.maven.repository.indices" } -}]]> +} diff --git a/pom.xml b/pom.xml index e17f236..fbbd5a9 100644 --- a/pom.xml +++ b/pom.xml @@ -17,6 +17,11 @@ 16 + + org.springframework.boot + spring-boot-starter-actuator + + org.springframework.boot spring-boot-starter-data-jpa diff --git a/src/main/java/org/waterproofingdata/wpdauth/security/WebSecurityConfig.java b/src/main/java/org/waterproofingdata/wpdauth/security/WebSecurityConfig.java index cd85634..08abe4e 100644 --- a/src/main/java/org/waterproofingdata/wpdauth/security/WebSecurityConfig.java +++ b/src/main/java/org/waterproofingdata/wpdauth/security/WebSecurityConfig.java @@ -33,13 +33,16 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { // Entry points http.authorizeRequests()// - .antMatchers("/users/login").permitAll()// - .antMatchers("/users/signup").permitAll()// - .antMatchers("/users/existsByUsername").permitAll()// + .antMatchers("/actuator/**").hasRole("ADMIN") // + .antMatchers("/users/login").permitAll()// + .antMatchers("/users/signup").permitAll()// + .antMatchers("/users/existsByUsername").permitAll()// .antMatchers("/users/existsByNickname").permitAll()// .antMatchers("/forgotpasswords/findallforgotpasswordquestions").permitAll()// .antMatchers("/forgotpasswords/loginbyusernameandanswers").permitAll()// - .antMatchers("/h2-console/**/**").permitAll() + .antMatchers("/forgotpasswords/findallforgotpasswordquestions").permitAll() // + .antMatchers("/forgotpasswords/loginbyusernameandanswers").permitAll() // + .antMatchers("/forgotpasswords/loginbyusernameandanswers").permitAll()// // Disallow everything else.. .anyRequest().authenticated(); diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index ed55c87..fdc9d6e 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -27,3 +27,20 @@ UsersController.signup=Creates user and returns its JWT token. UsersController.delete=Deletes specific user by username. UsersController.search=Returns specific user by username. UsersController.me=Returns current user's data. + +# actuator +management.endpoint.health.show-details=always +#indica que health deve mostrar detalhes sempre + +management.endpoints.web.exposure.include=* +#alem do health e do info ele sempre vai export todos endpoints disponiveis + +info.app.name=@project.name@ +info.app.description=@project.description@ +info.app.version=@project.version@ +info.app.encoding=@project.build.sourceEncoding@ +info.app.java.version=@java.version@ +# puxa informacoes do projeto do pom.xml + +spring.boot.admin.client.url=http://localhost:8080 +# configurando o Spring Boot Admin Server \ No newline at end of file