-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[id] add new modules: 'skean-id-oauth-authsrv','skean-id-oauth-ressrv…
…-spring-boot-starter'
- Loading branch information
Showing
30 changed files
with
382 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
server: | ||
port: 8910 | ||
|
||
skean: | ||
id: | ||
oauth-auth-server: | ||
client-id: c1 | ||
client-secret: '$2a$10$G4OlUys4SJH4KmLtmq8Cqep1.XOlRghB4e47ApJbxviMMyQxbp01W' # a bcrypt output of 123456 | ||
|
||
user-password-style: encrypted #plain or encrypted | ||
#user-password-storingStyle: inMemory | ||
jwt-signing-key: 888 | ||
|
||
#logging.level.org.springframework.security: DEBUG |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
apply plugin: 'java' | ||
dependencies { | ||
compile project(':skean-web') | ||
// compile project(':skean-dict') | ||
|
||
compile group: 'org.springframework.boot', name: 'spring-boot-devtools', version: versions.'spring-boot' | ||
compile group: 'org.springframework.boot', name: 'spring-boot-starter-security', version: versions.'spring-boot' | ||
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: versions.'spring-boot' | ||
//compile group: 'org.springframework.boot', name: 'spring-boot-configuration-processor', vversions.'spring-boot' | ||
|
||
compile group: 'org.springframework.security', name: 'spring-security-jwt', version: '1.0.9.RELEASE' | ||
compile group: 'org.springframework.security.oauth', name: 'spring-security-oauth2', version: '2.2.1.RELEASE' | ||
compile group: 'io.jsonwebtoken', name: 'jjwt', version: '0.9.0' | ||
} | ||
|
||
|
||
|
||
|
||
|
58 changes: 58 additions & 0 deletions
58
.../java/party/threebody/skean/id/oauth/ressrv/autoconfigure/ResServerAutoConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package party.threebody.skean.id.oauth.ressrv.autoconfigure; | ||
|
||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Primary; | ||
import org.springframework.security.config.annotation.web.builders.HttpSecurity; | ||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; | ||
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer; | ||
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter; | ||
import org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer; | ||
import org.springframework.security.oauth2.provider.token.DefaultTokenServices; | ||
import org.springframework.security.oauth2.provider.token.TokenStore; | ||
import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter; | ||
import org.springframework.security.oauth2.provider.token.store.JwtTokenStore; | ||
|
||
@Configuration | ||
@EnableConfigurationProperties(ResServerConfigProperties.class) | ||
@EnableResourceServer | ||
public class ResServerAutoConfiguration extends ResourceServerConfigurerAdapter{ | ||
|
||
private final ResServerConfigProperties resServerConfigProperties; | ||
|
||
public ResServerAutoConfiguration(ResServerConfigProperties resServerConfigProperties) { | ||
this.resServerConfigProperties = resServerConfigProperties; | ||
} | ||
|
||
@Override | ||
public void configure(ResourceServerSecurityConfigurer resources) throws Exception { | ||
resources.tokenServices(tokenServices()); | ||
} | ||
|
||
@Override | ||
public void configure(HttpSecurity http) throws Exception { | ||
super.configure(http); | ||
} | ||
|
||
@Bean | ||
public TokenStore tokenStore() { | ||
return new JwtTokenStore(accessTokenConverter()); | ||
} | ||
|
||
@Bean | ||
public JwtAccessTokenConverter accessTokenConverter() { | ||
JwtAccessTokenConverter converter = new JwtAccessTokenConverter(); | ||
converter.setSigningKey(resServerConfigProperties.getJwtSigningKey()); | ||
return converter; | ||
} | ||
|
||
|
||
@Bean | ||
@Primary | ||
public DefaultTokenServices tokenServices() { | ||
DefaultTokenServices defaultTokenServices = new DefaultTokenServices(); | ||
defaultTokenServices.setTokenStore(tokenStore()); | ||
return defaultTokenServices; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...n/java/party/threebody/skean/id/oauth/ressrv/autoconfigure/ResServerConfigProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package party.threebody.skean.id.oauth.ressrv.autoconfigure; | ||
|
||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
@ConfigurationProperties("skean.id.oauth-res-server") | ||
public class ResServerConfigProperties { | ||
|
||
private String jwtSigningKey; | ||
|
||
|
||
public String getJwtSigningKey() { | ||
return jwtSigningKey; | ||
} | ||
|
||
public void setJwtSigningKey(String jwtSigningKey) { | ||
this.jwtSigningKey = jwtSigningKey; | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
skean-id-oauth-ressrv-spring-boot-starter/src/main/resources/META-INF/spring.factories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=party.threebody.skean.id.oauth.ressrv.autoconfigure.ResServerAutoConfiguration |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 0 additions & 11 deletions
11
...g-boot-starter/src/main/java/party/threebody/skean/id/autoconfigure/SkeanIdCenterApp.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
skean-id-spring-boot-starter/src/main/resources/META-INF/spring.factories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=party.threebody.skean.id.autoconfigure.SkeanWebSecurityConfiguration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...les/navyapp/src/test/java/party/threebody/skean/samples/navyapp/ResourceServerConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package party.threebody.skean.samples.navyapp; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Primary; | ||
import org.springframework.security.config.annotation.web.builders.HttpSecurity; | ||
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer; | ||
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter; | ||
import org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer; | ||
import org.springframework.security.oauth2.provider.token.DefaultTokenServices; | ||
import org.springframework.security.oauth2.provider.token.TokenStore; | ||
import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter; | ||
import org.springframework.security.oauth2.provider.token.store.JwtTokenStore; | ||
|
||
@Deprecated | ||
//@Configuration | ||
//@EnableResourceServer | ||
public class ResourceServerConfig extends ResourceServerConfigurerAdapter { | ||
@Override | ||
public void configure(ResourceServerSecurityConfigurer resources) throws Exception { | ||
resources.tokenServices(tokenServices()); | ||
} | ||
|
||
@Override | ||
public void configure(HttpSecurity http) throws Exception { | ||
super.configure(http); | ||
} | ||
|
||
@Bean | ||
public TokenStore tokenStore() { | ||
return new JwtTokenStore(accessTokenConverter()); | ||
} | ||
|
||
@Bean | ||
public JwtAccessTokenConverter accessTokenConverter() { | ||
JwtAccessTokenConverter converter = new JwtAccessTokenConverter(); | ||
converter.setSigningKey("888"); | ||
return converter; | ||
} | ||
|
||
|
||
@Bean | ||
@Primary | ||
public DefaultTokenServices tokenServices() { | ||
DefaultTokenServices defaultTokenServices = new DefaultTokenServices(); | ||
defaultTokenServices.setTokenStore(tokenStore()); | ||
return defaultTokenServices; | ||
} | ||
|
||
} |
Oops, something went wrong.