This commit is contained in:
Justiks 2025-02-20 16:25:27 +03:00
parent a62b4fc966
commit e5c270f1b1
3 changed files with 17 additions and 29 deletions

20
.idea/workspace.xml generated
View File

@ -4,12 +4,10 @@
<option name="autoReloadType" value="SELECTIVE" /> <option name="autoReloadType" value="SELECTIVE" />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="067ac1f0-be04-4fe4-85c6-f870334053b8" name="Changes" comment="basic auth :pig:"> <list default="true" id="067ac1f0-be04-4fe4-85c6-f870334053b8" name="Changes" comment="bugfix">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/example/nto/controller/AdminController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/example/nto/controller/AdminController.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/example/nto/controller/AuthController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/example/nto/controller/AuthController.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/main/java/com/example/nto/controller/AuthController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/example/nto/controller/AuthController.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/example/nto/controller/EmployeeController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/example/nto/controller/EmployeeController.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/main/java/com/example/nto/websecurity/WebSecurityConfig.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/example/nto/websecurity/WebSecurityConfig.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/example/nto/entity/Entry.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/example/nto/entity/Entry.java" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -201,7 +199,15 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1740052413527</updated> <updated>1740052413527</updated>
</task> </task>
<option name="localTasksCounter" value="14" /> <task id="LOCAL-00014" summary="bugfix">
<option name="closed" value="true" />
<created>1740056898416</created>
<option name="number" value="00014" />
<option name="presentableId" value="LOCAL-00014" />
<option name="project" value="LOCAL" />
<updated>1740056898416</updated>
</task>
<option name="localTasksCounter" value="15" />
<servers /> <servers />
</component> </component>
<component name="VcsManagerConfiguration"> <component name="VcsManagerConfiguration">
@ -215,10 +221,10 @@
<MESSAGE value="create new endpoints (employee edit)" /> <MESSAGE value="create new endpoints (employee edit)" />
<MESSAGE value="fix secure" /> <MESSAGE value="fix secure" />
<MESSAGE value="add Entiries table and bugfix" /> <MESSAGE value="add Entiries table and bugfix" />
<MESSAGE value="bugfix" />
<MESSAGE value="add endpoints" /> <MESSAGE value="add endpoints" />
<MESSAGE value="basic auth :pig:" /> <MESSAGE value="basic auth :pig:" />
<option name="LAST_COMMIT_MESSAGE" value="basic auth :pig:" /> <MESSAGE value="bugfix" />
<option name="LAST_COMMIT_MESSAGE" value="bugfix" />
</component> </component>
<component name="XDebuggerManager"> <component name="XDebuggerManager">
<breakpoint-manager> <breakpoint-manager>

View File

@ -25,9 +25,6 @@ import java.util.List;
@RestController @RestController
public class AuthController { public class AuthController {
@Autowired
private PasswordEncoder passwordEncoder;
class RoleResponse { class RoleResponse {
private boolean isAdmin; private boolean isAdmin;

View File

@ -36,6 +36,10 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
return super.authenticationManagerBean(); return super.authenticationManagerBean();
} }
/**
* Выгружаем всех юзеров из бд в оперативку, почему бы и нет
* @return
*/
@Bean @Bean
@DependsOnDatabaseInitialization @DependsOnDatabaseInitialization
public UserDetailsService userDetailsService() { public UserDetailsService userDetailsService() {
@ -55,25 +59,6 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
return inMemoryUserDetailsManager; return inMemoryUserDetailsManager;
} }
@Bean
public BCryptPasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
@Bean
public DaoAuthenticationProvider authenticationProvider() {
DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider();
authProvider.setUserDetailsService(userDetailsService());
authProvider.setPasswordEncoder(passwordEncoder());
return authProvider;
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.authenticationProvider(authenticationProvider());
}
@Override @Override
protected void configure(HttpSecurity http) throws Exception { protected void configure(HttpSecurity http) throws Exception {
http http