New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lightweight vue login #9

Merged
merged 2 commits into from Mar 9, 2017
File filter...
Filter file types
Jump to file or symbol
Failed to load files and symbols.
+60 −3
Diff settings

Always

Just for now

Prev

#3 #4 Login via Google added

  • Loading branch information...
mmkay committed Mar 9, 2017
commit 26158bb2e5e416c11eaea0604f644aa71bb999df
Copy path View file
@@ -27,4 +27,3 @@ nbdist/
/src/main/resources/application-dev.properties
/src/main/resources/application-staging.properties
/src/main/resources/application-prod.properties

Copy path View file
@@ -45,6 +45,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
@@ -1,4 +1,4 @@
package pl.mmkay;
package pl.mmkay.matchlogger;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -0,0 +1,25 @@
package pl.mmkay.matchlogger.config;

import org.springframework.boot.autoconfigure.security.oauth2.client.EnableOAuth2Sso;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

@EnableOAuth2Sso
@Configuration
public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {

@Override
protected void configure(HttpSecurity http) throws Exception {
http
.csrf()
.disable()
.antMatcher("/**")
.authorizeRequests()
.antMatchers("/", "/index.html")
.permitAll()
.anyRequest()
.authenticated();
}

}
@@ -0,0 +1,14 @@
package pl.mmkay.matchlogger.user;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.security.Principal;

@RestController
public class UserController {
@RequestMapping("/user")
public Principal user(Principal principal) {
return principal;
}
}
@@ -1,3 +1,17 @@
# Use this file as template to your profile file.

spring.datasource.url=jdbc:mysql://localhost/testdb
spring.datasource.username=user
spring.datasource.password=pass
spring.datasource.password=pass

security.oauth2.client.clientId=SAMPLE_CLIENT_ID
security.oauth2.client.clientSecret=SAMPLE_CLIENT_SECRET
security.oauth2.client.accessTokenUri=https://www.googleapis.com/oauth2/v3/token
security.oauth2.client.userAuthorizationUri=https://accounts.google.com/o/oauth2/auth
security.oauth2.client.tokenName=oauth_token
security.oauth2.client.authenticationScheme=query
security.oauth2.client.clientAuthenticationScheme=form
security.oauth2.client.scope=profile email

security.oauth2.resource.userInfoUri=https://www.googleapis.com/userinfo/v2/me
security.oauth2.resource.preferTokenInfo=false
@@ -27,6 +27,7 @@
<ul class="nav navbar-nav">
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="user">Login with Google</a></li>
<li><a href="https://github.com/mmkay/matchlogger">Github</a></li>
</ul>
</div>
ProTip! Use n and p to navigate between commits in a pull request.