-
Notifications
You must be signed in to change notification settings - Fork 2
Tring react #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Tring react #15
Changes from all commits
10eac24
fbd029f
25b5a80
44a0863
ef631b7
d315b3e
0ba83fc
ae7dd9f
1fa3cec
8659936
3588bdc
5c44dd6
aa240c2
83e9a91
e0ef7f9
529b273
c5b4682
1a84280
c5dfc3b
6895e33
2ff2174
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| <component name="ProjectRunConfigurationManager"> | ||
| <configuration default="false" name="Crome-debug" type="ChromiumRemoteDebugType" factoryName="Chromium Remote" port="56116" restartOnDisconnect="true"> | ||
| <method v="2" /> | ||
| </configuration> | ||
| </component> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| yarnPath: .yarn/releases/yarn-2.4.2.cjs |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,39 @@ | ||
| package ru.hedin.modelka; | ||
|
|
||
| import org.springframework.boot.SpringApplication; | ||
| import org.springframework.boot.autoconfigure.EnableAutoConfiguration; | ||
| import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.ComponentScan; | ||
| import org.springframework.web.servlet.config.annotation.CorsRegistry; | ||
| import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
|
|
||
| @SpringBootApplication | ||
|
|
||
| public class Application | ||
| { | ||
| public static void main(String[] args){ | ||
| SpringApplication.run( Application.class, args ); | ||
| } | ||
| } | ||
|
|
||
| /* | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. стоит убрать если это не нужно.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. не помню чтоб ставил, что ты хочешь убрать коменты или скобки ?
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. коменты |
||
| @Bean | ||
| public WebMvcConfigurer corsConfigurer() { | ||
| return new WebMvcConfigurer() { | ||
| @Override | ||
| public void addCorsMappings(CorsRegistry registry) { | ||
| registry.addMapping("/*") | ||
| .allowedOrigins("http://localhost:8080") | ||
| .allowedMethods("POST","GET") | ||
| // .allowedHeaders("Content-Type", "X-Requested-With", "accept", "Origin", "Access-Control-Request-Method", | ||
| // "Access-Control-Request-Headers") | ||
| .exposedHeaders("Access-Control-Allow-Origin", "Access-Control-Allow-Credentials") | ||
| // .allowCredentials(true).maxAge(3600); | ||
|
|
||
|
|
||
| ; | ||
| } | ||
| }; | ||
| */ | ||
| }; | ||
|
|
||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,48 @@ | ||
| package ru.hedin.modelka.config; | ||
|
|
||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.Configuration; | ||
| import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; | ||
| import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
| import org.springframework.web.servlet.config.annotation.*; | ||
|
|
||
| @EnableWebMvc | ||
| @Configuration | ||
| public class MvcConfig | ||
| implements WebMvcConfigurer | ||
| { | ||
| public void addViewControllers( ViewControllerRegistry registry ) | ||
| { | ||
| registry.addViewController( "/" ) | ||
| .setViewName( "index" ); | ||
| registry.addViewController( "/main" ) | ||
| .setViewName( "main" ); | ||
| registry.addViewController( "/login" ) | ||
| .setViewName( "login" ); | ||
| implements WebMvcConfigurer { | ||
| public void addViewControllers(ViewControllerRegistry registry) { | ||
| registry.addViewController("/") | ||
| .setViewName("index"); | ||
| registry.addViewController("/main") | ||
| .setViewName("main"); | ||
| registry.addViewController("/login") | ||
| .setViewName("login"); | ||
|
|
||
| } | ||
| } | ||
|
|
||
| // @Override | ||
| // @Bean | ||
|
|
||
| public void addCorsMappings(CorsRegistry registry) { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. А это нам сейчас нужно?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Нет наверное, если мы не вернемся к необходимости корс
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Не нужное давай убирать, если очень нонадобится поднимем в истории. |
||
|
|
||
|
|
||
|
|
||
|
|
||
| registry.addMapping("/**") | ||
| .allowedOrigins("http://localhost:3000") | ||
| .allowedMethods("POST","GET") | ||
| .allowedHeaders("*") | ||
| // .allowedHeaders("Content-Type", "X-Requested-With", "accept", "Origin", "Access-Control-Request-Method", | ||
| // "Access-Control-Request-Headers") | ||
| .exposedHeaders("Access-Control-Allow-Origin", "Access-Control-Allow-Credentials") | ||
| .allowCredentials(true).maxAge(3600); | ||
|
|
||
| ; | ||
|
|
||
| } | ||
|
|
||
| // | ||
| // @Bean | ||
| // @Override | ||
| // public void addCorsMappings(CorsRegistry registry) { | ||
| // registry.addMapping("/**").allowedMethods("POST"); | ||
| // } | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package ru.hedin.modelka.config; | ||
|
|
||
|
|
||
| import org.springframework.stereotype.Component; | ||
|
|
||
| import javax.servlet.*; | ||
| import javax.servlet.http.HttpServletResponse; | ||
| import java.io.IOException; | ||
|
|
||
| /* | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Лучше убрать закоментированное.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ну если убирать корс фильтр, то и все что в нем |
||
| @Component | ||
| public class SimpleCORSFilter implements Filter { | ||
|
|
||
| public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { | ||
| HttpServletResponse response = (HttpServletResponse) res; | ||
|
|
||
| response.setHeader("Access-Control-Allow-Origin", "*"); | ||
| response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); | ||
| response.setHeader("Access-Control-Max-Age", "3600"); | ||
| response.setHeader("Access-Control-Allow-Headers", "x-requested-with"); | ||
| chain.doFilter(req, res); | ||
| } | ||
|
|
||
| public void init(FilterConfig filterConfig) {} | ||
|
|
||
| public void destroy() {} | ||
|
|
||
| } | ||
| */ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,78 @@ | ||
| package ru.hedin.modelka.config; | ||
|
|
||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.ComponentScan; | ||
| import org.springframework.context.annotation.Configuration; | ||
| import org.springframework.context.annotation.ImportResource; | ||
| import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; | ||
| import org.springframework.security.config.annotation.authentication.configuration.EnableGlobalAuthentication; | ||
| import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; | ||
| import org.springframework.security.config.annotation.web.builders.HttpSecurity; | ||
| import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; | ||
| import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; | ||
| import org.springframework.security.core.userdetails.User; | ||
| import org.springframework.security.core.userdetails.UserDetails; | ||
| import org.springframework.security.core.userdetails.UserDetailsService; | ||
| import org.springframework.security.provisioning.InMemoryUserDetailsManager; | ||
| import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; | ||
| import org.springframework.security.crypto.password.PasswordEncoder; | ||
| import org.springframework.web.cors.CorsConfiguration; | ||
|
|
||
| @Configuration | ||
| //@EnableWebSecurity (debug = true) | ||
| /// give 2 bean AuthenticationManager - runtime @EnableGlobalMethodSecurity(prePostEnabled = true) | ||
| @EnableWebSecurity | ||
| @EnableGlobalAuthentication | ||
| @ComponentScan | ||
| @ImportResource("classpath:security.xml") | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Надо бы проверить будет ли все работать если @ImportResource("classpath:security.xml") утащить на основной конфиг а этот совсем убрать.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Это вобще другое, но надо проверю.. |
||
| public class WebSecurityConfig extends WebSecurityConfigurerAdapter { | ||
|
|
||
| @Override | ||
| protected void configure(HttpSecurity http) throws Exception { | ||
|
|
||
|
|
||
| // http.cors().configurationSource(request -> new CorsConfiguration().applyPermitDefaultValues()); | ||
| // | ||
| // | ||
| // http.formLogin().defaultSuccessUrl("/username", true); | ||
| // http.authorizeRequests() | ||
| // .anyRequest().authenticated() | ||
| // .and().httpBasic(); | ||
|
|
||
|
|
||
| /* | ||
|
|
||
| http | ||
| .csrf().disable() | ||
| .authorizeRequests() | ||
| .antMatchers("/register").permitAll() | ||
| .antMatchers("/log").permitAll() | ||
| .antMatchers("/username").permitAll() | ||
| .anyRequest().authenticated() | ||
|
|
||
| .antMatchers("/test/admin").hasRole("ROLE_ADMIN") | ||
| .antMatchers("/test/gm").hasRole("ROLE_GM") | ||
| .antMatchers("/test/user").hasRole("ROLE_USER") | ||
| .and() | ||
| .formLogin() | ||
| .loginPage("/login") | ||
| .permitAll() | ||
| .and() | ||
| .logout() | ||
| .permitAll() | ||
| .and().httpBasic(); | ||
| */ | ||
|
|
||
| } | ||
|
|
||
|
|
||
| // @Bean | ||
|
|
||
|
|
||
| /* | ||
| @Bean | ||
| public PasswordEncoder passwordEncoder(){ | ||
| return new BCryptPasswordEncoder(12); | ||
| } | ||
| */ | ||
|
|
||
| // @Override | ||
| // protected void configure(HttpSecurity http) throws Exception { | ||
| // http | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Зачем нам httpclient?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Чтоб добавить хедер с количеством записей в json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Клиент это зверь который вызывает по хттн другие хосты. Он не должен быть для этого нужен.