Переглянути джерело

Merge branch '2.0' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into 2.0

wangzhinan 2 роки тому
батько
коміт
ba3ddf7bff

+ 22 - 16
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/WlyyTokenGranter.java

@ -5,6 +5,7 @@ import com.yihu.jw.entity.util.AesEncryptUtils;
import com.yihu.jw.security.core.userdetails.SaltUser;
import com.yihu.jw.security.oauth2.core.redis.WlyyRedisVerifyCodeService;
import com.yihu.jw.security.utils.AES;
import com.yihu.utils.security.MD5;
import org.springframework.security.authentication.*;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.authority.mapping.GrantedAuthoritiesMapper;
@ -58,7 +59,8 @@ public class WlyyTokenGranter implements TokenGranter {
                        authenticationManager,
                        tokenServices,
                        clientDetailsService,
                        requestFactory
                        requestFactory,
                        userDetailsService
                ));
        tokenGranters.put(WlyyRefreshTokenGranter.GRANT_TYPE,
@ -223,16 +225,19 @@ public class WlyyTokenGranter implements TokenGranter {
        private static final String GRANT_TYPE = "password";
        private final AuthenticationManager authenticationManager;
        private final UserDetailsService userDetailsService;
        private GrantedAuthoritiesMapper authoritiesMapper = new NullAuthoritiesMapper();
        public WlyyResourceOwnerPasswordTokenGranter(AuthenticationManager authenticationManager,
                                                 AuthorizationServerTokenServices tokenServices, ClientDetailsService clientDetailsService, OAuth2RequestFactory requestFactory) {
            this(authenticationManager, tokenServices, clientDetailsService, requestFactory, GRANT_TYPE);
                                                 AuthorizationServerTokenServices tokenServices, ClientDetailsService clientDetailsService, OAuth2RequestFactory requestFactory,UserDetailsService userDetailsService) {
            this(authenticationManager, tokenServices, clientDetailsService, requestFactory,userDetailsService, GRANT_TYPE);
        }
        protected WlyyResourceOwnerPasswordTokenGranter(AuthenticationManager authenticationManager, AuthorizationServerTokenServices tokenServices,
                                                    ClientDetailsService clientDetailsService, OAuth2RequestFactory requestFactory, String grantType) {
                                                    ClientDetailsService clientDetailsService, OAuth2RequestFactory requestFactory,UserDetailsService userDetailsService, String grantType) {
            super(tokenServices, clientDetailsService, requestFactory, grantType);
            this.authenticationManager = authenticationManager;
            this.userDetailsService = userDetailsService;
        }
        @Override
@ -244,23 +249,24 @@ public class WlyyTokenGranter implements TokenGranter {
            // Protect from downstream leaks of password
            parameters.remove("password");
            Authentication userAuth = new UsernamePasswordAuthenticationToken(username, password);
            ((AbstractAuthenticationToken) userAuth).setDetails(parameters);
            try {
                userAuth = authenticationManager.authenticate(userAuth);
            SaltUser userDetails = (SaltUser)userDetailsService.loadUserByUsername(username);
            if(userDetails==null){
                throw new InvalidGrantException("Could not authenticate user: " + username);
            }
            catch (AccountStatusException ase) {
                //covers expired, locked, disabled cases (mentioned in section 5.2, draft 31)
                throw new InvalidGrantException(ase.getMessage());
            String pwd = MD5.md5Hex(password+ "{" + userDetails.getSalt() + "}");
            if(!pwd.equals(userDetails.getPassword())){
                throw new InvalidRequestException("Bad credentials");
            }
            catch (BadCredentialsException e) {
                // If the username/password are wrong the spec says we should send 400/invalid grant
                throw new InvalidGrantException(e.getMessage());
            if (!userDetails.isEnabled()) {
                throw new InvalidGrantException("User is disabled");
            }
            if (userAuth == null || !userAuth.isAuthenticated()) {
                throw new InvalidGrantException("Could not authenticate user: " + username);
            if (!userDetails.isAccountNonLocked()) {
                throw new InvalidGrantException("User account is locked");
            }
            Authentication userAuth = new UsernamePasswordAuthenticationToken(username,userDetails.getPassword(),  this.authoritiesMapper.mapAuthorities(userDetails.getAuthorities()));
            ((AbstractAuthenticationToken) userAuth).setDetails(parameters);
            OAuth2Request storedOAuth2Request = getRequestFactory().createOAuth2Request(client, tokenRequest);
            return new OAuth2Authentication(storedOAuth2Request, userAuth);
        }

+ 2 - 0
server/svr-authentication/src/main/resources/application.yml

@ -3,6 +3,8 @@ server:
spring:
  jpa:
    open-in-view: false
  datasource:
  hikari:
    registerMbeans: true

+ 12 - 5
svr/svr-base/pom.xml

@ -65,7 +65,7 @@
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>im-service</artifactId>
            <version>2.4.0</version>
            <version>${version.wlyy-common}</version>
            <scope>compile</scope>
        </dependency>
@ -189,7 +189,7 @@
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>base-service</artifactId>
            <version>2.4.0</version>
            <version>${version.wlyy-common}</version>
            <exclusions>
                <exclusion>
                    <groupId>xalan</groupId>
@ -201,7 +201,7 @@
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>sms-service</artifactId>
            <version>2.4.0</version>
            <version>${version.wlyy-common}</version>
            <scope>compile</scope>
        </dependency>
        <!--   poi xml导入导出工具 end -->
@ -209,9 +209,13 @@
        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc6</artifactId>
            <version>11.2.0.3</version>
            <version>${version.oracle}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-pool2</artifactId>
            <version>2.4.2</version>
        </dependency>
    </dependencies>
    <build>
@ -220,6 +224,7 @@
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.2.0</version>
                <configuration>
                    <archive>
                        <!-- 生成的jar中,不要包含pom.xml和pom.properties这两个文件 -->
@ -238,6 +243,7 @@
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>3.2.0</version>
                <executions>
                    <execution>
                        <id>copy-lib</id>
@ -259,6 +265,7 @@
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.2.0</version>
                <configuration>
                    <archive>
                        <!-- 指定配置文件目录,这样jar运行时会去找到同目录下的resources文件夹下查找 -->

+ 1 - 1
svr/svr-base/src/main/resources/application.yml

@ -993,7 +993,7 @@ testPattern:
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
im:
  im_list_get: http://172.26.0.105:3000/
  data_base_name: 1
---
spring:

+ 1 - 1
svr/svr-internet-hospital/pom.xml

@ -268,7 +268,7 @@
    </dependencies>
    <build>
        <finalName>svr-internet-hospital-test</finalName>
        <finalName>svr-internet-hospital</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>

+ 1 - 0
svr/svr-internet-hospital/src/main/resources/application.yml

@ -6,6 +6,7 @@ spring:
  aop:
    proxy-target-class: true
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    max-active: 200
    max-idle: 200 #最大空闲连接
    min-idle: 10 #最小空闲连接

+ 1 - 1
svr/svr-internet-hospital/src/main/resources/bootstrap.yml

@ -1,6 +1,6 @@
spring:
  application:
    name:  svr-internet-hospital-test
    name:  svr-internet-hospital
  cloud:
    config:
      failFast: true