<version>2.7.3</version> | <version>2.7.3</version> | ||||
<relativePath/> <!-- lookup parent from repository --> | <relativePath/> <!-- lookup parent from repository --> | ||||
</parent> | </parent> | ||||
<modules> | |||||
<module>tuoheng_oidc_server</module> | |||||
</modules> | |||||
<groupId>com.tuoheng</groupId> | <groupId>com.tuoheng</groupId> | ||||
<artifactId>tuoheng_oidc</artifactId> | <artifactId>tuoheng_oidc</artifactId> | ||||
<version>0.0.1-SNAPSHOT</version> | |||||
<version>1.0.0</version> | |||||
<name>tuoheng_oidc</name> | <name>tuoheng_oidc</name> | ||||
<description>tuoheng_oidc</description> | <description>tuoheng_oidc</description> | ||||
<properties> | <properties> | ||||
<java.version>1.8</java.version> | <java.version>1.8</java.version> | ||||
<tuoheng.version>1.0.0</tuoheng.version> | |||||
</properties> | </properties> | ||||
<dependencies> | <dependencies> | ||||
<dependency> | <dependency> | ||||
<artifactId>spring-boot-starter-test</artifactId> | <artifactId>spring-boot-starter-test</artifactId> | ||||
<scope>test</scope> | <scope>test</scope> | ||||
</dependency> | </dependency> | ||||
<dependency> | |||||
<groupId>com.tuoheng</groupId> | |||||
<artifactId>tuoheng_oidc_server</artifactId> | |||||
<version>${tuoheng.version}</version> | |||||
</dependency> | |||||
</dependencies> | </dependencies> | ||||
<build> | <build> | ||||
<plugins> | <plugins> | ||||
<plugin> | <plugin> | ||||
<groupId>org.springframework.boot</groupId> | |||||
<artifactId>spring-boot-maven-plugin</artifactId> | |||||
<groupId>org.apache.maven.plugins</groupId> | |||||
<artifactId>maven-resources-plugin</artifactId> | |||||
<version>3.1.0</version> | |||||
</plugin> | </plugin> | ||||
</plugins> | </plugins> | ||||
</build> | </build> |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||||
<modelVersion>4.0.0</modelVersion> | <modelVersion>4.0.0</modelVersion> | ||||
<parent> | <parent> | ||||
<groupId>org.springframework.boot</groupId> | |||||
<artifactId>spring-boot-starter-parent</artifactId> | |||||
<version>2.7.3</version> | |||||
<relativePath/> <!-- lookup parent from repository --> | |||||
<artifactId>tuoheng_oidc</artifactId> | |||||
<groupId>com.tuoheng</groupId> | |||||
<version>1.0.0</version> | |||||
</parent> | </parent> | ||||
<groupId>com.tuoheng</groupId> | <groupId>com.tuoheng</groupId> | ||||
<artifactId>tuoheng_oidc_server</artifactId> | <artifactId>tuoheng_oidc_server</artifactId> | ||||
</profile> | </profile> | ||||
</profiles> | </profiles> | ||||
<!-- 环境变量构建 --> | |||||
<build> | <build> | ||||
<finalName>tuoheng_dsp_system</finalName> | |||||
<resources> | <resources> | ||||
<resource> | <resource> | ||||
<directory>src/main/resources</directory> | <directory>src/main/resources</directory> | ||||
</includes> | </includes> | ||||
</resource> | </resource> | ||||
</resources> | </resources> | ||||
<pluginManagement> | |||||
<plugins> | |||||
<plugin> | |||||
<groupId>org.springframework.boot</groupId> | |||||
<artifactId>spring-boot-maven-plugin</artifactId> | |||||
<version>2.1.11.RELEASE</version> | |||||
<configuration> | |||||
<finalName>${project.build.finalName}</finalName> | |||||
</configuration> | |||||
<executions> | |||||
<execution> | |||||
<goals> | |||||
<goal>repackage</goal> | |||||
</goals> | |||||
</execution> | |||||
</executions> | |||||
</plugin> | |||||
</plugins> | |||||
</pluginManagement> | |||||
<plugins> | <plugins> | ||||
<plugin> | <plugin> | ||||
<groupId>org.springframework.boot</groupId> | |||||
<artifactId>spring-boot-maven-plugin</artifactId> | |||||
<groupId>org.apache.maven.plugins</groupId> | |||||
<artifactId>maven-resources-plugin</artifactId> | |||||
<version>3.1.0</version> | |||||
</plugin> | </plugin> | ||||
</plugins> | </plugins> | ||||
</build> | </build> |
import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer; | import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer; | ||||
import org.springframework.security.config.annotation.web.configurers.oauth2.server.authorization.OAuth2AuthorizationServerConfigurer; | import org.springframework.security.config.annotation.web.configurers.oauth2.server.authorization.OAuth2AuthorizationServerConfigurer; | ||||
import org.springframework.security.config.annotation.web.configurers.oauth2.server.resource.OAuth2ResourceServerConfigurer; | import org.springframework.security.config.annotation.web.configurers.oauth2.server.resource.OAuth2ResourceServerConfigurer; | ||||
import org.springframework.security.core.userdetails.User; | |||||
import org.springframework.security.core.userdetails.UserDetails; | |||||
import org.springframework.security.core.userdetails.UserDetailsService; | import org.springframework.security.core.userdetails.UserDetailsService; | ||||
import org.springframework.security.oauth2.core.oidc.OidcUserInfo; | import org.springframework.security.oauth2.core.oidc.OidcUserInfo; | ||||
import org.springframework.security.oauth2.server.authorization.config.ProviderSettings; | import org.springframework.security.oauth2.server.authorization.config.ProviderSettings; | ||||
import org.springframework.security.oauth2.server.authorization.oidc.authentication.OidcUserInfoAuthenticationContext; | import org.springframework.security.oauth2.server.authorization.oidc.authentication.OidcUserInfoAuthenticationContext; | ||||
import org.springframework.security.oauth2.server.authorization.oidc.authentication.OidcUserInfoAuthenticationToken; | import org.springframework.security.oauth2.server.authorization.oidc.authentication.OidcUserInfoAuthenticationToken; | ||||
import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken; | import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken; | ||||
import org.springframework.security.provisioning.InMemoryUserDetailsManager; | |||||
import org.springframework.security.provisioning.JdbcUserDetailsManager; | import org.springframework.security.provisioning.JdbcUserDetailsManager; | ||||
import org.springframework.security.web.SecurityFilterChain; | import org.springframework.security.web.SecurityFilterChain; | ||||
import org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint; | import org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint; | ||||
@Bean | @Bean | ||||
public UserDetailsService userDetailsService() { | public UserDetailsService userDetailsService() { | ||||
// UserDetails userDetails = User.withDefaultPasswordEncoder() | |||||
// .username("admin") | |||||
// .password("123456") | |||||
// .roles("USER") | |||||
// .build(); | |||||
// | |||||
// return new InMemoryUserDetailsManager(userDetails); | |||||
return new JdbcUserDetailsManager(dataSource); | |||||
UserDetails userDetails = User.withDefaultPasswordEncoder() | |||||
.username("admin") | |||||
.password("123456") | |||||
.roles("ADMIN") | |||||
.build(); | |||||
return new InMemoryUserDetailsManager(userDetails); | |||||
//return new JdbcUserDetailsManager(dataSource); | |||||
} | } | ||||
@Bean | @Bean |