Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.apache.catalina.filters.RequestDumperFilter;
- import org.springframework.boot.SpringApplication;
- import org.springframework.boot.autoconfigure.SpringBootApplication;
- import org.springframework.context.annotation.Bean;
- import org.springframework.context.annotation.Configuration;
- import org.springframework.context.annotation.Profile;
- import org.springframework.core.annotation.Order;
- import org.springframework.security.config.annotation.web.builders.HttpSecurity;
- import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
- import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;
- import org.springframework.web.bind.annotation.RestController;
- import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
- import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
- @SpringBootApplication
- @EnableAuthorizationServer
- @RestController
- public class AuthorizationApplication {
- public static void main(String[] args) {
- SpringApplication.run(AuthorizationApplication.class, args);
- }
- @Configuration
- static class MvcConfig extends WebMvcConfigurerAdapter {
- @Override
- public void addViewControllers(ViewControllerRegistry registry) {
- registry.addViewController("login").setViewName("login");
- registry.addViewController("/").setViewName("index");
- }
- }
- @Configuration
- @Order(-20)
- static class LoginConfig extends WebSecurityConfigurerAdapter {
- @Override
- protected void configure(HttpSecurity http) throws Exception {
- http
- .formLogin().loginPage("/login").permitAll()
- .and()
- .requestMatchers()
- .antMatchers("/", "/login", "/oauth/authorize", "/oauth/confirm_access")
- .and()
- .authorizeRequests()
- .anyRequest().authenticated();
- }
- }
- @Profile("!cloud")
- @Bean
- RequestDumperFilter requestDumperFilter() {
- return new RequestDumperFilter();
- }
- }
- import React, { Component } from 'react';
- class Login extends React.Component {
- constructor(props) {
- super(props);
- this.state = {
- username: '',
- password: ''
- };
- this.handleChange = this.handleChange.bind(this);
- this.handleSubmit = this.handleSubmit.bind(this);
- }
- handleChange(event) {
- this.setState({ [event.target.name]: event.target.value });
- }
- handleSubmit(event) {
- alert('A name was submitted: ' + this.state.username);
- event.preventDefault();
- }
- render() {
- return (
- <form action='login' method='post' onSubmit={this.handleSubmit}>
- <label>
- Username:
- <input type="text" name="username" value={this.state.username} onChange={this.handleChange} />
- </label><br />
- <label>
- Password:
- <input type="password" name="password" value={this.state.password} onChange={this.handleChange} />
- </label><br />
- <input type="submit" value="Submit" />
- </form>
- );
- }
- }
- export default Login
Add Comment
Please, Sign In to add comment