Commit d1758dd5 authored by benhoumine's avatar benhoumine

request post

parent 442fcd30
......@@ -54,20 +54,13 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20190722</version>
</dependency>
</dependencies>
<build>
......
package isima.f2.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
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;
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
public static final String[] PUBLIC_MATCHES = {
"**/**"
};
@Override
public void configure(HttpSecurity http) throws Exception{
http.authorizeRequests()
.antMatchers(PUBLIC_MATCHES).permitAll();
}
/*
@Override
protected void configure(HttpSecurity http) throws Exception {
http
//HTTP Basic authentication
.httpBasic()
.and()
.authorizeRequests()
.antMatchers(HttpMethod.GET, "/actions/**").hasRole("USER")
.antMatchers(HttpMethod.POST, "/actions").hasRole("ADMIN")
.antMatchers(HttpMethod.PUT, "/actions/**").hasRole("ADMIN")
.antMatchers(HttpMethod.PATCH, "/actions/**").hasRole("ADMIN")
.antMatchers(HttpMethod.DELETE, "/actions/**").hasRole("ADMIN")
.and()
.csrf().disable()
.formLogin().disable();
}
*/
// 2 utilisateur pour le demos
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication()
.withUser("user").password("{noop}password").roles("USER")
.and()
.withUser("admin").password("{noop}password").roles("USER", "ADMIN");
}
}
package isima.f2.controllers;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
......@@ -9,6 +10,7 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import isima.f2.model.Poubelle;
import isima.f2.services.ImpPoubelle;
......@@ -31,10 +33,9 @@ public class PoubelleController {
}
@PostMapping(value="/testpost")
public void testPost(@RequestParam String id) {
System.out.println("Test Post Id "+id);
@PostMapping ("/testpost")
@ResponseBody
public String testpost(@RequestParam Map <String, String> allParams) {
return "Les paramètres sont"+ allParams.entrySet ();
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment