Browse Source

Implement Spring Boot Actuator for application monitoring and management.

main
Cauã 11 months ago
parent
commit
eaae8d9a01
  1. 32
      .idea/workspace.xml
  2. 5
      pom.xml
  3. 11
      src/main/java/org/waterproofingdata/wpdauth/security/WebSecurityConfig.java
  4. 17
      src/main/resources/application.properties

32
.idea/workspace.xml

@ -5,11 +5,9 @@
</component>
<component name="ChangeListManager">
<list default="true" id="e096f643-4c6b-4769-84b8-63aa85cd1521" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/org/waterproofingdata/wpdauth/controller/UsersController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/org/waterproofingdata/wpdauth/controller/UsersController.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/org/waterproofingdata/wpdauth/service/UsersService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/org/waterproofingdata/wpdauth/service/UsersService.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/org/waterproofingdata/wpdauth/security/WebSecurityConfig.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/org/waterproofingdata/wpdauth/security/WebSecurityConfig.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/application.properties" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/application.properties" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
@ -41,21 +39,21 @@
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"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",
"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"
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;WebServerToolWindowFactoryState&quot;: &quot;false&quot;,
&quot;git-widget-placeholder&quot;: &quot;main&quot;,
&quot;last_opened_file_path&quot;: &quot;C:/xampp/htdocs/java-wpd-auth/WPD-Auth-PR/WPD-Auth&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;reference.settings.project.maven.repository.indices&quot;
}
}]]></component>
}</component>
<component name="RecentsManager">
<key name="CreateClassDialog.RecentsKey">
<recent name="org.waterproofingdata.wpdauth.service" />

5
pom.xml

@ -17,6 +17,11 @@
<java.version>16</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>

11
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();

17
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
Loading…
Cancel
Save