diff --git a/spring-security-oauth/pom.xml b/spring-security-oauth/pom.xml
index 0531270ea4..9570e886d3 100644
--- a/spring-security-oauth/pom.xml
+++ b/spring-security-oauth/pom.xml
@@ -16,7 +16,8 @@
spring-security-oauth-server
spring-security-oauth-resource
- spring-security-oauth-ui
+ spring-security-oauth-ui-implicit
+ spring-security-oauth-ui-password
diff --git a/spring-security-oauth/spring-security-oauth-resource/pom.xml b/spring-security-oauth/spring-security-oauth-resource/pom.xml
index 88cc87c491..84a5027cb5 100644
--- a/spring-security-oauth/spring-security-oauth-resource/pom.xml
+++ b/spring-security-oauth/spring-security-oauth-resource/pom.xml
@@ -11,38 +11,45 @@
1.0.0-SNAPSHOT
-
-
- org.springframework.boot
- spring-boot-starter-web
-
-
-
- org.springframework
- spring-jdbc
-
-
-
- mysql
- mysql-connector-java
- runtime
-
-
-
- org.springframework.security.oauth
- spring-security-oauth2
- ${oauth.version}
-
-
-
- org.apache.commons
- commons-lang3
- ${commons-lang3.version}
-
-
-
-
-
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ org.springframework
+ spring-jdbc
+
+
+
+ mysql
+ mysql-connector-java
+ runtime
+
+
+
+ org.springframework.security.oauth
+ spring-security-oauth2
+ ${oauth.version}
+
+
+
+ org.apache.commons
+ commons-lang3
+ ${commons-lang3.version}
+
+
+
+
+ spring-security-oauth-resource
+
+
+ src/main/resources
+ true
+
+
+
\ No newline at end of file
diff --git a/spring-security-oauth/spring-security-oauth-server/pom.xml b/spring-security-oauth/spring-security-oauth-server/pom.xml
index 211b9a240c..ebbaa993f1 100644
--- a/spring-security-oauth/spring-security-oauth-server/pom.xml
+++ b/spring-security-oauth/spring-security-oauth-server/pom.xml
@@ -44,6 +44,13 @@
+ spring-security-oauth-server
+
+
+ src/main/resources
+ true
+
+
org.springframework.boot
diff --git a/spring-security-oauth/spring-security-oauth-server/src/main/java/org/baeldung/config/AuthServerOAuth2Config.java b/spring-security-oauth/spring-security-oauth-server/src/main/java/org/baeldung/config/AuthServerOAuth2Config.java
index 572fcc5efa..0db2c4032c 100644
--- a/spring-security-oauth/spring-security-oauth-server/src/main/java/org/baeldung/config/AuthServerOAuth2Config.java
+++ b/spring-security-oauth/spring-security-oauth-server/src/main/java/org/baeldung/config/AuthServerOAuth2Config.java
@@ -3,6 +3,7 @@ package org.baeldung.config;
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -31,6 +32,7 @@ public class AuthServerOAuth2Config extends AuthorizationServerConfigurerAdapter
private Environment env;
@Autowired
+ @Qualifier("authenticationManagerBean")
private AuthenticationManager authenticationManager;
@Value("classpath:schema.sql")
@@ -47,8 +49,14 @@ public class AuthServerOAuth2Config extends AuthorizationServerConfigurerAdapter
clients.jdbc(dataSource())
.withClient("clientId")
.authorizedGrantTypes("implicit")
- .scopes("read","write")
- .autoApprove(true);
+ .scopes("read")
+ .autoApprove(true)
+ .and()
+ .withClient("clientIdPassword")
+ .secret("secret")
+ .authorizedGrantTypes("password","authorization_code", "refresh_token")
+ .scopes("read");
+
// @formatter:on
}
diff --git a/spring-security-oauth/spring-security-oauth-server/src/main/java/org/baeldung/config/ServerSecurityConfig.java b/spring-security-oauth/spring-security-oauth-server/src/main/java/org/baeldung/config/ServerSecurityConfig.java
index ec9bdfe0ce..929e1997d2 100644
--- a/spring-security-oauth/spring-security-oauth-server/src/main/java/org/baeldung/config/ServerSecurityConfig.java
+++ b/spring-security-oauth/spring-security-oauth-server/src/main/java/org/baeldung/config/ServerSecurityConfig.java
@@ -1,6 +1,8 @@
package org.baeldung.config;
+import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
+import org.springframework.security.authentication.AuthenticationManager;
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;
@@ -11,17 +13,24 @@ public class ServerSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(final AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication().withUser("john").password("123").roles("USER");
+
+ }
+
+ @Override
+ @Bean
+ public AuthenticationManager authenticationManagerBean() throws Exception {
+ return super.authenticationManagerBean();
}
@Override
protected void configure(HttpSecurity http) throws Exception {
// @formatter:off
- http
- .authorizeRequests()
+ http.authorizeRequests()
.antMatchers("/login").permitAll()
.anyRequest().authenticated()
.and()
.formLogin().permitAll();
// @formatter:on
}
+
}
diff --git a/spring-security-oauth/spring-security-oauth-ui/.classpath b/spring-security-oauth/spring-security-oauth-ui-implicit/.classpath
similarity index 100%
rename from spring-security-oauth/spring-security-oauth-ui/.classpath
rename to spring-security-oauth/spring-security-oauth-ui-implicit/.classpath
diff --git a/spring-security-oauth/spring-security-oauth-ui/.project b/spring-security-oauth/spring-security-oauth-ui-implicit/.project
similarity index 96%
rename from spring-security-oauth/spring-security-oauth-ui/.project
rename to spring-security-oauth/spring-security-oauth-ui-implicit/.project
index 7ff5398a88..3b594eaba3 100644
--- a/spring-security-oauth/spring-security-oauth-ui/.project
+++ b/spring-security-oauth/spring-security-oauth-ui-implicit/.project
@@ -1,6 +1,6 @@
- spring-security-oauth-ui
+ spring-security-oauth-ui-implicit
@@ -20,6 +20,11 @@
+
+ org.eclipse.m2e.core.maven2Builder
+
+
+
org.springframework.ide.eclipse.core.springbuilder
@@ -30,11 +35,6 @@
-
- org.eclipse.m2e.core.maven2Builder
-
-
-
org.eclipse.jem.workbench.JavaEMFNature
diff --git a/spring-security-oauth/spring-security-oauth-ui/pom.xml b/spring-security-oauth/spring-security-oauth-ui-implicit/pom.xml
similarity index 55%
rename from spring-security-oauth/spring-security-oauth-ui/pom.xml
rename to spring-security-oauth/spring-security-oauth-ui-implicit/pom.xml
index a9b25f75c8..aaa2900d48 100644
--- a/spring-security-oauth/spring-security-oauth-ui/pom.xml
+++ b/spring-security-oauth/spring-security-oauth-ui-implicit/pom.xml
@@ -1,8 +1,8 @@
4.0.0
- spring-security-oauth-ui
+ spring-security-oauth-ui-implicit
- spring-security-oauth-ui
+ spring-security-oauth-ui-implicit
war
@@ -19,11 +19,18 @@
- org.springframework.boot
- spring-boot-starter-thymeleaf
-
-
-
-
+ org.springframework.boot
+ spring-boot-starter-thymeleaf
+
+
+
+ spring-security-oauth-ui-implicit
+
+
+ src/main/resources
+ true
+
+
+
\ No newline at end of file
diff --git a/spring-security-oauth/spring-security-oauth-ui/src/main/java/org/baeldung/config/UiApplication.java b/spring-security-oauth/spring-security-oauth-ui-implicit/src/main/java/org/baeldung/config/UiApplication.java
similarity index 100%
rename from spring-security-oauth/spring-security-oauth-ui/src/main/java/org/baeldung/config/UiApplication.java
rename to spring-security-oauth/spring-security-oauth-ui-implicit/src/main/java/org/baeldung/config/UiApplication.java
diff --git a/spring-security-oauth/spring-security-oauth-ui/src/main/java/org/baeldung/config/UiWebConfig.java b/spring-security-oauth/spring-security-oauth-ui-implicit/src/main/java/org/baeldung/config/UiWebConfig.java
similarity index 100%
rename from spring-security-oauth/spring-security-oauth-ui/src/main/java/org/baeldung/config/UiWebConfig.java
rename to spring-security-oauth/spring-security-oauth-ui-implicit/src/main/java/org/baeldung/config/UiWebConfig.java
diff --git a/spring-security-oauth/spring-security-oauth-ui/src/main/resources/application.properties b/spring-security-oauth/spring-security-oauth-ui-implicit/src/main/resources/application.properties
similarity index 100%
rename from spring-security-oauth/spring-security-oauth-ui/src/main/resources/application.properties
rename to spring-security-oauth/spring-security-oauth-ui-implicit/src/main/resources/application.properties
diff --git a/spring-security-oauth/spring-security-oauth-ui/src/main/resources/oauth-ng.js b/spring-security-oauth/spring-security-oauth-ui-implicit/src/main/resources/oauth-ng.js
similarity index 100%
rename from spring-security-oauth/spring-security-oauth-ui/src/main/resources/oauth-ng.js
rename to spring-security-oauth/spring-security-oauth-ui-implicit/src/main/resources/oauth-ng.js
diff --git a/spring-security-oauth/spring-security-oauth-ui/src/main/resources/templates/header.html b/spring-security-oauth/spring-security-oauth-ui-implicit/src/main/resources/templates/header.html
similarity index 95%
rename from spring-security-oauth/spring-security-oauth-ui/src/main/resources/templates/header.html
rename to spring-security-oauth/spring-security-oauth-ui-implicit/src/main/resources/templates/header.html
index db0cb5b6d3..7705f43403 100644
--- a/spring-security-oauth/spring-security-oauth-ui/src/main/resources/templates/header.html
+++ b/spring-security-oauth/spring-security-oauth-ui-implicit/src/main/resources/templates/header.html
@@ -12,7 +12,7 @@
diff --git a/spring-security-oauth/spring-security-oauth-ui-implicit/src/main/resources/templates/index.html b/spring-security-oauth/spring-security-oauth-ui-implicit/src/main/resources/templates/index.html
new file mode 100755
index 0000000000..c98ed493bd
--- /dev/null
+++ b/spring-security-oauth/spring-security-oauth-ui-implicit/src/main/resources/templates/index.html
@@ -0,0 +1,29 @@
+
+
+
+
+Spring Security OAuth
+
+
+
+
+
+
+
+
Foo Details
+
+ ID
+ {{foo.id}}
+
+
+
+Name
+{{foo.name}}
+
+
+
+
+
+
\ No newline at end of file
diff --git a/spring-security-oauth/spring-security-oauth-ui/src/main/resources/templates/oauthTemp.html b/spring-security-oauth/spring-security-oauth-ui-implicit/src/main/resources/templates/oauthTemp.html
similarity index 100%
rename from spring-security-oauth/spring-security-oauth-ui/src/main/resources/templates/oauthTemp.html
rename to spring-security-oauth/spring-security-oauth-ui-implicit/src/main/resources/templates/oauthTemp.html
diff --git a/spring-security-oauth/spring-security-oauth-ui/src/main/webapp/resources/oauth-ng.js b/spring-security-oauth/spring-security-oauth-ui-implicit/src/main/webapp/resources/oauth-ng.js
similarity index 100%
rename from spring-security-oauth/spring-security-oauth-ui/src/main/webapp/resources/oauth-ng.js
rename to spring-security-oauth/spring-security-oauth-ui-implicit/src/main/webapp/resources/oauth-ng.js
diff --git a/spring-security-oauth/spring-security-oauth-ui-password/.classpath b/spring-security-oauth/spring-security-oauth-ui-password/.classpath
new file mode 100644
index 0000000000..0cad5db2d0
--- /dev/null
+++ b/spring-security-oauth/spring-security-oauth-ui-password/.classpath
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/spring-security-oauth/spring-security-oauth-ui-password/.project b/spring-security-oauth/spring-security-oauth-ui-password/.project
new file mode 100644
index 0000000000..d2309b6207
--- /dev/null
+++ b/spring-security-oauth/spring-security-oauth-ui-password/.project
@@ -0,0 +1,48 @@
+
+
+ spring-security-oauth-ui-password
+
+
+
+
+
+ org.eclipse.wst.jsdt.core.javascriptValidator
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.wst.common.project.facet.core.builder
+
+
+
+
+ org.eclipse.m2e.core.maven2Builder
+
+
+
+
+ org.springframework.ide.eclipse.core.springbuilder
+
+
+
+
+ org.eclipse.wst.validation.validationbuilder
+
+
+
+
+
+ org.eclipse.jem.workbench.JavaEMFNature
+ org.eclipse.wst.common.modulecore.ModuleCoreNature
+ org.springframework.ide.eclipse.core.springnature
+ org.eclipse.jdt.core.javanature
+ org.eclipse.m2e.core.maven2Nature
+ org.eclipse.wst.common.project.facet.core.nature
+ org.eclipse.wst.jsdt.core.jsNature
+
+
diff --git a/spring-security-oauth/spring-security-oauth-ui-password/pom.xml b/spring-security-oauth/spring-security-oauth-ui-password/pom.xml
new file mode 100644
index 0000000000..a2bf3d07bb
--- /dev/null
+++ b/spring-security-oauth/spring-security-oauth-ui-password/pom.xml
@@ -0,0 +1,36 @@
+
+ 4.0.0
+ spring-security-oauth-ui-password
+
+ spring-security-oauth-ui-password
+ war
+
+
+ org.baeldung
+ spring-security-oauth
+ 1.0.0-SNAPSHOT
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ org.springframework.boot
+ spring-boot-starter-thymeleaf
+
+
+
+
+ spring-security-oauth-ui-password
+
+
+ src/main/resources
+ true
+
+
+
+
\ No newline at end of file
diff --git a/spring-security-oauth/spring-security-oauth-ui-password/src/main/java/org/baeldung/config/UiApplication.java b/spring-security-oauth/spring-security-oauth-ui-password/src/main/java/org/baeldung/config/UiApplication.java
new file mode 100644
index 0000000000..8f491516aa
--- /dev/null
+++ b/spring-security-oauth/spring-security-oauth-ui-password/src/main/java/org/baeldung/config/UiApplication.java
@@ -0,0 +1,13 @@
+package org.baeldung.config;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.context.web.SpringBootServletInitializer;
+
+@SpringBootApplication
+public class UiApplication extends SpringBootServletInitializer {
+
+ public static void main(String[] args) {
+ SpringApplication.run(UiApplication.class, args);
+ }
+}
\ No newline at end of file
diff --git a/spring-security-oauth/spring-security-oauth-ui-password/src/main/java/org/baeldung/config/UiWebConfig.java b/spring-security-oauth/spring-security-oauth-ui-password/src/main/java/org/baeldung/config/UiWebConfig.java
new file mode 100644
index 0000000000..46e7f6db42
--- /dev/null
+++ b/spring-security-oauth/spring-security-oauth-ui-password/src/main/java/org/baeldung/config/UiWebConfig.java
@@ -0,0 +1,38 @@
+package org.baeldung.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
+import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
+import org.springframework.web.servlet.config.annotation.EnableWebMvc;
+import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
+import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
+
+@Configuration
+@EnableWebMvc
+public class UiWebConfig extends WebMvcConfigurerAdapter {
+
+ @Bean
+ public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
+ return new PropertySourcesPlaceholderConfigurer();
+ }
+
+ @Override
+ public void configureDefaultServletHandling(final DefaultServletHandlerConfigurer configurer) {
+ configurer.enable();
+ }
+
+ @Override
+ public void addViewControllers(final ViewControllerRegistry registry) {
+ super.addViewControllers(registry);
+ registry.addViewController("/index");
+ registry.addViewController("/login");
+ }
+
+ @Override
+ public void addResourceHandlers(final ResourceHandlerRegistry registry) {
+ registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
+ }
+
+}
\ No newline at end of file
diff --git a/spring-security-oauth/spring-security-oauth-ui-password/src/main/resources/application.properties b/spring-security-oauth/spring-security-oauth-ui-password/src/main/resources/application.properties
new file mode 100644
index 0000000000..84ffdbb9ad
--- /dev/null
+++ b/spring-security-oauth/spring-security-oauth-ui-password/src/main/resources/application.properties
@@ -0,0 +1,2 @@
+#server.context-path=/ui
+#server.port=8080
\ No newline at end of file
diff --git a/spring-security-oauth/spring-security-oauth-ui-password/src/main/resources/templates/header.html b/spring-security-oauth/spring-security-oauth-ui-password/src/main/resources/templates/header.html
new file mode 100644
index 0000000000..2a276e5d63
--- /dev/null
+++ b/spring-security-oauth/spring-security-oauth-ui-password/src/main/resources/templates/header.html
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/spring-security-oauth/spring-security-oauth-ui/src/main/resources/templates/index.html b/spring-security-oauth/spring-security-oauth-ui-password/src/main/resources/templates/index.html
similarity index 100%
rename from spring-security-oauth/spring-security-oauth-ui/src/main/resources/templates/index.html
rename to spring-security-oauth/spring-security-oauth-ui-password/src/main/resources/templates/index.html
diff --git a/spring-security-oauth/spring-security-oauth-ui-password/src/main/resources/templates/login.html b/spring-security-oauth/spring-security-oauth-ui-password/src/main/resources/templates/login.html
new file mode 100755
index 0000000000..4d105cec6c
--- /dev/null
+++ b/spring-security-oauth/spring-security-oauth-ui-password/src/main/resources/templates/login.html
@@ -0,0 +1,34 @@
+
+
+
+
+Spring Security OAuth
+
+
+
+
+
+
+
+
+
Login
+
+
+ Username
+
+
+
+
+Password
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/spring-security-oauth/spring-security-oauth-ui-password/src/main/webapp/resources/angular-utf8-base64.min.js b/spring-security-oauth/spring-security-oauth-ui-password/src/main/webapp/resources/angular-utf8-base64.min.js
new file mode 100644
index 0000000000..24af57d020
--- /dev/null
+++ b/spring-security-oauth/spring-security-oauth-ui-password/src/main/webapp/resources/angular-utf8-base64.min.js
@@ -0,0 +1 @@
+"use strict";angular.module("ab-base64",[]).constant("base64",function(){var a={alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",lookup:null,ie:/MSIE /.test(navigator.userAgent),ieo:/MSIE [67]/.test(navigator.userAgent),encode:function(b){var c,d,e,f,g=a.toUtf8(b),h=-1,i=g.length,j=[,,,];if(a.ie){for(c=[];++h>2,j[1]=(3&d)<<4|e>>4,isNaN(e)?j[2]=j[3]=64:(f=g[++h],j[2]=(15&e)<<2|f>>6,j[3]=isNaN(f)?64:63&f),c.push(a.alphabet.charAt(j[0]),a.alphabet.charAt(j[1]),a.alphabet.charAt(j[2]),a.alphabet.charAt(j[3]));return c.join("")}for(c="";++h>2,j[1]=(3&d)<<4|e>>4,isNaN(e)?j[2]=j[3]=64:(f=g[++h],j[2]=(15&e)<<2|f>>6,j[3]=isNaN(f)?64:63&f),c+=a.alphabet[j[0]]+a.alphabet[j[1]]+a.alphabet[j[2]]+a.alphabet[j[3]];return c},decode:function(b){if(b=b.replace(/\s/g,""),b.length%4)throw new Error("InvalidLengthError: decode failed: The string to be decoded is not the correct length for a base64 encoded string.");if(/[^A-Za-z0-9+\/=\s]/g.test(b))throw new Error("InvalidCharacterError: decode failed: The string contains characters invalid in a base64 encoded string.");var c,d=a.fromUtf8(b),e=0,f=d.length;if(a.ieo){for(c=[];f>e;)c.push(d[e]<128?String.fromCharCode(d[e++]):d[e]>191&&d[e]<224?String.fromCharCode((31&d[e++])<<6|63&d[e++]):String.fromCharCode((15&d[e++])<<12|(63&d[e++])<<6|63&d[e++]));return c.join("")}for(c="";f>e;)c+=String.fromCharCode(d[e]<128?d[e++]:d[e]>191&&d[e]<224?(31&d[e++])<<6|63&d[e++]:(15&d[e++])<<12|(63&d[e++])<<6|63&d[e++]);return c},toUtf8:function(a){var b,c=-1,d=a.length,e=[];if(/^[\x00-\x7f]*$/.test(a))for(;++cb?e.push(b):2048>b?e.push(b>>6|192,63&b|128):e.push(b>>12|224,b>>6&63|128,63&b|128);return e},fromUtf8:function(b){var c,d=-1,e=[],f=[,,,];if(!a.lookup){for(c=a.alphabet.length,a.lookup={};++d>4),f[2]=a.lookup[b.charAt(++d)],64!==f[2])&&(e.push((15&f[1])<<4|f[2]>>2),f[3]=a.lookup[b.charAt(++d)],64!==f[3]);)e.push((3&f[2])<<6|f[3]);return e}},b={decode:function(b){b=b.replace(/-/g,"+").replace(/_/g,"/");var c=b.length%4;if(c){if(1===c)throw new Error("InvalidLengthError: Input base64url string is the wrong length to determine padding");b+=new Array(5-c).join("=")}return a.decode(b)},encode:function(b){var c=a.encode(b);return c.replace(/\+/g,"-").replace(/\//g,"_").split("=",1)[0]}};return{decode:a.decode,encode:a.encode,urldecode:b.decode,urlencode:b.encode}}());
\ No newline at end of file