Skip to content

Commit

Permalink
Merge branch 'master' into dev
Browse files Browse the repository at this point in the history
# Conflicts:
#	pom.xml
#	src/main/java/org/teapot/backend/controller/user/UserController.java
  • Loading branch information
serjihsklovski committed Jun 26, 2017
2 parents 3e9094f + d9ab6ca commit c336609
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;
import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer;
import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerSecurityConfigurer;


@Configuration
Expand All @@ -26,6 +27,11 @@ public void configure(AuthorizationServerEndpointsConfigurer configurer) throws
configurer.userDetailsService(userDetailsService);
}

@Override
public void configure(AuthorizationServerSecurityConfigurer security) throws Exception {
security.allowFormAuthenticationForClients();
}

@Override
public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
clients.inMemory().withClient("client")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ public User registerUser(@RequestBody User user,
}

user.setRegistrationDate(LocalDate.now());
user.setPassword(passwordEncoder.encode(user.getPassword()));

if (auth == null) {
user = userRepository.save(user);
verificationMailSender.createTokenAndSend(user, request.getLocale());
Expand Down
37 changes: 37 additions & 0 deletions src/main/java/org/teapot/backend/filters/CorsFilter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.teapot.backend.filters;

import org.springframework.stereotype.Component;

import javax.servlet.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@Component
public class CorsFilter implements Filter {

@Override
public void doFilter(ServletRequest servletRequest,
ServletResponse servletResponse,
FilterChain filterChain)
throws IOException, ServletException {

HttpServletResponse response = (HttpServletResponse) servletResponse;

response.setHeader("Access-Control-Allow-Origin", "*");
response.setHeader("Access-Control-Allow-Methods",
"POST, GET, PUT, PATCH, DELETE, OPTIONS");
response.setHeader("Access-Control-Max-Age", "3600");
response.setHeader("Access-Control-Allow-Headers",
"x-requested-with, Content-Type, Authorization, Accept");

filterChain.doFilter(servletRequest, servletResponse);
}

@Override
public void init(FilterConfig filterConfig) throws ServletException {
}

@Override
public void destroy() {
}
}

0 comments on commit c336609

Please sign in to comment.