yonge 5 years ago
parent
commit
53daa93957

+ 3 - 2
mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/core/provider/service/DefaultUserDetailsService.java

@@ -9,7 +9,6 @@ import org.springframework.security.authentication.LockedException;
 import org.springframework.security.core.GrantedAuthority;
 import org.springframework.security.core.authority.AuthorityUtils;
 import org.springframework.security.core.authority.SimpleGrantedAuthority;
-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.UsernameNotFoundException;
@@ -21,6 +20,7 @@ import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.auth.api.enums.SysUserType;
 import com.ym.mec.auth.config.constant.SecurityConstants;
 import com.ym.mec.auth.service.SysUserService;
+import com.ym.mec.common.security.AuthUser;
 
 @Service
 public class DefaultUserDetailsService implements UserDetailsService {
@@ -67,7 +67,8 @@ public class DefaultUserDetailsService implements UserDetailsService {
 
 		SysUser sysUser = userInfo.getSysUser();
 
-		return new User(username, BCRYPT + sysUser.getPassword(), StringUtils.equals(sysUser.getLockFlag(), "0"), true, true, true, authorities);
+		return new AuthUser(sysUser.getId(), username, BCRYPT + sysUser.getPassword(), StringUtils.equals(sysUser.getLockFlag(), "0"), true, true, true,
+				authorities);
 	}
 
 }

+ 5 - 0
mec-task/pom.xml

@@ -28,6 +28,11 @@
 			<groupId>org.quartz-scheduler</groupId>
 			<artifactId>quartz</artifactId>
 		</dependency>
+		
+		<dependency>
+			<groupId>org.springframework.cloud</groupId>
+			<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
+		</dependency>
 
 		<dependency>
 			<groupId>org.springframework.boot</groupId>

+ 7 - 3
mec-task/src/main/resources/application.yml

@@ -4,7 +4,7 @@ server:
 eureka:
   client:
     serviceUrl:
-      defaultZone: http://localhost:8761/eureka/
+      defaultZone: http://admin:admin123@localhost:8761/eureka/eureka/
 
 spring:
   application:
@@ -40,8 +40,12 @@ task:
   autoStartup: true
   startupDelay: 30
   
+      
 security:
   oauth2:
+    client:
+      client-id: app
+      client-secret: app
     resource:
-      id: task-service
-      access-token-uri: http://auth-server/oauth/token
+      token-info-uri: http://localhost:8001/oauth/check_token
+      

+ 1 - 1
mec-task/src/main/resources/logback-spring.xml

@@ -175,7 +175,7 @@
         <logger name="com.ym.mec" level="debug"/>
     </springProfile>
 
-    <root level="debug">
+    <root level="info">
         <appender-ref ref="CONSOLE" />
         <!-- <appender-ref ref="DEBUG_FILE" />
         <appender-ref ref="INFO_FILE" />