mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-11 12:07:42 +00:00
(improvement)(auth) Support token key allocation based on the integration application. (#1119)
This commit is contained in:
@@ -6,6 +6,7 @@ import com.tencent.supersonic.auth.api.authentication.request.UserReq;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* UserAdaptor defines some interfaces for obtaining user and organization information
|
||||
@@ -20,7 +21,7 @@ public interface UserAdaptor {
|
||||
|
||||
void register(UserReq userReq);
|
||||
|
||||
String login(UserReq userReq);
|
||||
String login(UserReq userReq, HttpServletRequest request);
|
||||
|
||||
List<User> getUserByOrg(String key);
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package com.tencent.supersonic.auth.api.authentication.config;
|
||||
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.Data;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -18,12 +21,18 @@ public class AuthenticationConfig {
|
||||
@Value("${authentication.enable:false}")
|
||||
private boolean enabled;
|
||||
|
||||
@Value("${authentication.token.secret:secret}")
|
||||
private String tokenSecret;
|
||||
@Value("${authentication.token.default.appKey:supersonic}")
|
||||
private String tokenDefaultAppKey;
|
||||
|
||||
@Value("${authentication.token.appSecret:supersonic:secret}")
|
||||
private String tokenAppSecret;
|
||||
|
||||
@Value("${authentication.token.http.header.key:Authorization}")
|
||||
private String tokenHttpHeaderKey;
|
||||
|
||||
@Value("${authentication.token.http.app.key:App-Key}")
|
||||
private String tokenHttpHeaderAppKey;
|
||||
|
||||
@Value("${authentication.app.appId:appId}")
|
||||
private String appId;
|
||||
|
||||
@@ -35,4 +44,10 @@ public class AuthenticationConfig {
|
||||
|
||||
@Value("${authentication.token.timeout:7200000}")
|
||||
private Long tokenTimeout;
|
||||
|
||||
public Map<String, String> getAppKeyToSecretMap() {
|
||||
return Arrays.stream(this.tokenAppSecret.split(","))
|
||||
.map(s -> s.split(":"))
|
||||
.collect(Collectors.toMap(e -> e[0].trim(), e -> e[1].trim()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public interface UserService {
|
||||
|
||||
void register(UserReq userCmd);
|
||||
|
||||
String login(UserReq userCmd);
|
||||
String login(UserReq userCmd, HttpServletRequest request);
|
||||
|
||||
Set<String> getUserAllOrgId(String userName);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user