Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
10eac24
Postgres connected database spring on local host user = springuser pa…
fzhulitov Jun 9, 2021
fbd029f
Merge pull request #3 from hedinant/master
fzhulitov Jun 10, 2021
25b5a80
Merge remote-tracking branch 'origin/master'
fzhulitov Jun 10, 2021
44a0863
Postgres connected database spring on local host user = springuser pa…
fzhulitov Jun 10, 2021
ef631b7
Postgres connected database spring on local host user = springuser pa…
fzhulitov Jun 11, 2021
d315b3e
Registration backend and login Done all
fzhulitov Jun 13, 2021
0ba83fc
Merge pull request #5 from fzhulitov/trying_rifsec_fromdb
fzhulitov Jun 13, 2021
ae7dd9f
Front some tring///
fzhulitov Jun 15, 2021
1fa3cec
Front sending login, come to server part, going out with 405, but fec…
fzhulitov Jun 22, 2021
8659936
WORK if not identified
fzhulitov Jun 29, 2021
3588bdc
WORK if not identified
fzhulitov Jun 29, 2021
5c44dd6
Merge branch 'hedinant:master' into master
fzhulitov Jun 29, 2021
aa240c2
login and username works without unneeded redirects
hedinant Jun 29, 2021
83e9a91
Merge pull request #6 from hedinant/Tring-react
fzhulitov Jun 30, 2021
e0ef7f9
WORK if not identified
fzhulitov Jun 30, 2021
529b273
WORK if not identified
fzhulitov Jun 30, 2021
c5b4682
registration work
fzhulitov Jul 1, 2021
1a84280
Merge branch 'Tring-react' of https://github.com/fzhulitov/modelka in…
fzhulitov Jul 2, 2021
c5dfc3b
registration work
fzhulitov Jul 3, 2021
6895e33
Merge branch 'master' of https://github.com/fzhulitov/modelka into Tr…
fzhulitov Jul 3, 2021
2ff2174
registration work
fzhulitov Jul 3, 2021
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
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,11 @@
/modelka.iml
/ui/ui.iml
/main.iml
/src/main/resources/static/node_modules/
/src/main/.yarn/*
!.yarn/cache
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
5 changes: 5 additions & 0 deletions .run/Crome-debug.run.xml
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>
52 changes: 43 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,23 @@
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.2.1.RELEASE</version>
</plugin>
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-compiler-plugin</artifactId>-->
<!-- <configuration>-->
<!-- <source>8</source>-->
<!-- <target>8</target>-->
<!-- </configuration>-->
<!-- </plugin>-->
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.12.0</version>
</plugin>



</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>static/node_modules/**/*.*</exclude>
</excludes>
</resource>
</resources>
</build>

<dependencies>
Expand All @@ -39,7 +47,12 @@
<!-- <artifactId>jackson-databind</artifactId>-->
<!-- <version>2.9.10.5</version>-->
<!-- </dependency>-->

<dependency>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.12.0</version>
<type>maven-plugin</type>
</dependency>
<dependency>
<groupId>org.mozilla</groupId>
<artifactId>rhino</artifactId>
Expand All @@ -55,6 +68,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Зачем нам httpclient?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Чтоб добавить хедер с количеством записей в json

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Клиент это зверь который вызывает по хттн другие хосты. Он не должен быть для этого нужен.

<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
Expand All @@ -78,10 +95,27 @@
<artifactId>hibernate-entitymanager</artifactId>
<version>5.4.27.Final</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.postgresql/postgresql -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.20</version>
</dependency>
<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>
</dependency>
<!-- Base64 clases (added by Http)
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.13</version>
</dependency>-->
</dependencies>
</project>
1 change: 1 addition & 0 deletions src/main/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yarnPath: .yarn/releases/yarn-2.4.2.cjs
31 changes: 29 additions & 2 deletions src/main/java/ru/hedin/modelka/Application.java
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 );
}
}

/*
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

стоит убрать если это не нужно.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не помню чтоб ставил, что ты хочешь убрать коменты или скобки ?

Copy link
Owner

Choose a reason for hiding this comment

The 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);


;
}
};
*/
};

};
54 changes: 41 additions & 13 deletions src/main/java/ru/hedin/modelka/config/MvcConfig.java
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) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А это нам сейчас нужно?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нет наверное, если мы не вернемся к необходимости корс

Copy link
Owner

Choose a reason for hiding this comment

The 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");
// }
};
12 changes: 6 additions & 6 deletions src/main/java/ru/hedin/modelka/config/PersistenceJPAConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
@Bean
public DataSource dataSource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName("org.h2.Driver");
dataSource.setUrl("jdbc:h2:mem:db;DB_CLOSE_DELAY=-1");
dataSource.setUsername("sa");
dataSource.setPassword("");
dataSource.setDriverClassName("org.postgresql.ds.PGSimpleDataSource");
dataSource.setUrl("jdbc:postgresql://localhost:5432/spring");
dataSource.setUsername("springuser");
dataSource.setPassword("12345");

return dataSource;
}
Expand Down Expand Up @@ -72,9 +72,9 @@ public PersistenceExceptionTranslationPostProcessor exceptionTranslation(){

Properties additionalProperties() {
Properties properties = new Properties();
properties.setProperty("hibernate.hbm2ddl.auto", "create-drop");
properties.setProperty("hibernate.hbm2ddl.auto", "update");
// properties.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQL5Dialect");
properties.setProperty("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
properties.setProperty("hibernate.dialect", "org.hibernate.dialect.PostgresPlusDialect");

return properties;
}
Expand Down
30 changes: 30 additions & 0 deletions src/main/java/ru/hedin/modelka/config/SimpleCORSFilter.java
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;

/*
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше убрать закоментированное.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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() {}

}
*/

66 changes: 62 additions & 4 deletions src/main/java/ru/hedin/modelka/config/WebSecurityConfig.java
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")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Надо бы проверить будет ли все работать если @ImportResource("classpath:security.xml") утащить на основной конфиг а этот совсем убрать.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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
Expand Down
Loading