Skip to content

Commit 3aae08b

Browse files
committed
supprot extra
1.5.2
1 parent c0b0b6d commit 3aae08b

File tree

8 files changed

+20
-6
lines changed

8 files changed

+20
-6
lines changed

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<groupId>com.codingapi.springboot</groupId>
1414
<artifactId>springboot-parent</artifactId>
15-
<version>1.5.1</version>
15+
<version>1.5.2</version>
1616

1717
<url>https://github.com/codingapi/springboot-framewrok</url>
1818
<name>springboot-parent</name>

springboot-starter-data-fast/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>springboot-parent</artifactId>
77
<groupId>com.codingapi.springboot</groupId>
8-
<version>1.5.1</version>
8+
<version>1.5.2</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

springboot-starter-id-generator/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>springboot-parent</artifactId>
77
<groupId>com.codingapi.springboot</groupId>
8-
<version>1.5.1</version>
8+
<version>1.5.2</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

springboot-starter-security-jwt/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<artifactId>springboot-parent</artifactId>
88
<groupId>com.codingapi.springboot</groupId>
9-
<version>1.5.1</version>
9+
<version>1.5.2</version>
1010
</parent>
1111

1212
<artifactId>springboot-starter-security-jwt</artifactId>

springboot-starter-security-jwt/src/main/java/com/codingapi/springboot/security/filter/MyLoginFilter.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.codingapi.springboot.security.dto.response.LoginResponse;
99
import com.codingapi.springboot.security.jwt.Jwt;
1010
import com.codingapi.springboot.security.jwt.Token;
11+
import com.codingapi.springboot.security.jwt.TokenContext;
1112
import com.codingapi.springboot.security.properties.SecurityJwtProperties;
1213
import lombok.extern.slf4j.Slf4j;
1314
import org.apache.commons.io.IOUtils;
@@ -71,7 +72,9 @@ protected void successfulAuthentication(HttpServletRequest request, HttpServletR
7172
User user = (User) authResult.getPrincipal();
7273
LoginRequest loginRequest = LoginRequestContext.getInstance().get();
7374

74-
Token token = jwt.create(user.getUsername(), loginRequest.getPassword(), user.getAuthorities().stream().map(GrantedAuthority::getAuthority).collect(Collectors.toList()));
75+
Token token = jwt.create(user.getUsername(), loginRequest.getPassword(),
76+
user.getAuthorities().stream().map(GrantedAuthority::getAuthority).collect(Collectors.toList()),
77+
TokenContext.getExtra());
7578

7679
LoginResponse login = new LoginResponse();
7780
login.setUsername(user.getUsername());

springboot-starter-security-jwt/src/main/java/com/codingapi/springboot/security/jwt/Token.java

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public UsernamePasswordAuthenticationToken getAuthenticationToken() {
7979
for (String authority : authorities) {
8080
simpleGrantedAuthorities.add(new SimpleGrantedAuthority(authority));
8181
}
82+
TokenContext.pushExtra(extra);
8283
return new UsernamePasswordAuthenticationToken(this, iv, simpleGrantedAuthorities);
8384
}
8485

springboot-starter-security-jwt/src/main/java/com/codingapi/springboot/security/jwt/TokenContext.java

+10
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,20 @@
44

55
public class TokenContext {
66

7+
private static final ThreadLocal<String> threadLocal = new ThreadLocal<>();
8+
79
private TokenContext() {
810
}
911

1012
public static Token current() {
1113
return (Token) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
1214
}
15+
16+
public static void pushExtra(String extra){
17+
threadLocal.set(extra);
18+
}
19+
20+
public static String getExtra(){
21+
return threadLocal.get();
22+
}
1323
}

springboot-starter/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.codingapi.springboot</groupId>
77
<artifactId>springboot-parent</artifactId>
8-
<version>1.5.1</version>
8+
<version>1.5.2</version>
99
</parent>
1010
<artifactId>springboot-starter</artifactId>
1111

0 commit comments

Comments
 (0)