Commit e24606cc authored by Javi Corvi's avatar Javi Corvi
Browse files

development

parent 38d6aeab
Pipeline #24992 passed with stage
in 4 minutes and 22 seconds
......@@ -51,7 +51,10 @@
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<!-- <dependency>
<groupId>org.springframework.boot</groupId>
......
package es.bsc.inb.ades.rest.api.controllers;
import java.security.Principal;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -7,6 +8,7 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -23,6 +25,11 @@ public class DocumentController {
@Autowired
public DocumentService documentService;
@RequestMapping("/api/v1/basicauth")
public String validateLogin(Model model, Principal principal) {
return "login correct";
}
@RequestMapping("/documents/")
public List<Document> findAll() {
return documentService.findAll();
......
......@@ -9,9 +9,9 @@ import java.security.Principal;
@Controller
public class WebController {
@RequestMapping("/")
@RequestMapping("/api/v1/nada")
public String index(Model model, Principal principal) {
return "index";
return "login correct";
}
@GetMapping("/greeting")
public String greeting(@RequestParam(name="name", required=false, defaultValue="World") String name, Model model) {
......
package es.bsc.inb.ades.rest.api.security.basic.inmemory;
public class AuthenticationBean {
private String message;
public AuthenticationBean(String message) {
this.message = message;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
@Override
public String toString() {
return String.format("HelloWorldBean [message=%s]", message);
}
}
package es.bsc.inb.ades.rest.api.security.basic.inmemory;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
//Controller
@CrossOrigin(origins={ "http://localhost:3000", "http://localhost:4200", "http://localhost:8081" })
@RestController
public class BasicAuthenticationController {
@GetMapping(path = "/basicauth")
public AuthenticationBean helloWorldBean() {
//throw new RuntimeException("Some Error has Happened! Contact Support at ***-***");
return new AuthenticationBean("You are authenticated");
}
}
package es.bsc.inb.ades.rest.api.security.basic.inmemory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
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.WebSecurityConfigurerAdapter;
@Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable().
authorizeRequests().antMatchers(HttpMethod.OPTIONS, "/**").permitAll().anyRequest().authenticated()
.and().httpBasic();
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication().withUser("admin").password("{noop}password").roles("USER");
}
}
spring.application.name =ades_rest_api
#Spring Boot Port
server.port = ${SERVER_PORT}
#ADES Database
spring.data.mongodb.uri=${MONGO_URI}/etransafe
#PRETOX Database
spring.data.mongodb.uri=${MONGO_URI}
......@@ -3,7 +3,8 @@ spring.application.name =ades_rest_api
#server.port = ${SERVER_PORT}
server.port = 8090
#ADES Database
spring.data.mongodb.uri=mongodb://localhost:27017/etransafe
#spring.data.mongodb.uri=mongodb://localhost:27017/etransafe
spring.data.mongodb.uri=mongodb://etransafe_rw:etransafe_rw2019!@mdb-login.bsc.es:27017/etransafe
#development enviroment
#docker run -d -p 27017-27019:27017-27019 -v /home/javi/eTRANSAFE_DATA/mongo-data-dev://data/db --name mongodb mongo:4.0.4
......
Supports Markdown
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