Add server.address property and update issuer field in LoginController to use dynamic server address. Modify SQL query in PrivilegedUserMapper to simplify permissions retrieval.
This commit is contained in:
parent
1ce2088cae
commit
343964eda8
|
|
@ -36,6 +36,9 @@ public class LoginController implements LoginApi {
|
||||||
@Value("${login.secret:#{null}}")
|
@Value("${login.secret:#{null}}")
|
||||||
private String loginSecret;
|
private String loginSecret;
|
||||||
|
|
||||||
|
@Value("${server.address:#{null}}")
|
||||||
|
private String serverAddress;
|
||||||
|
|
||||||
private record CacheEntry(UUID uuid, Instant expiry) {}
|
private record CacheEntry(UUID uuid, Instant expiry) {}
|
||||||
|
|
||||||
private static final ConcurrentMap<String, CacheEntry> cache = new ConcurrentHashMap<>();
|
private static final ConcurrentMap<String, CacheEntry> cache = new ConcurrentHashMap<>();
|
||||||
|
|
@ -160,7 +163,7 @@ public class LoginController implements LoginApi {
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
JwtClaimsSet claims = JwtClaimsSet.builder()
|
JwtClaimsSet claims = JwtClaimsSet.builder()
|
||||||
.issuer("altitudeweb")
|
.issuer(serverAddress)
|
||||||
.claim("authorities", claimList.stream().map(PermissionClaimDto::getValue).toList())
|
.claim("authorities", claimList.stream().map(PermissionClaimDto::getValue).toList())
|
||||||
.issuedAt(now)
|
.issuedAt(now)
|
||||||
.expiresAt(expiryTime)
|
.expiresAt(expiryTime)
|
||||||
|
|
|
||||||
|
|
@ -5,4 +5,5 @@ database.host=${DB_HOST:localhost}
|
||||||
database.user=${DB_USER:root}
|
database.user=${DB_USER:root}
|
||||||
database.password=${DB_PASSWORD:root}
|
database.password=${DB_PASSWORD:root}
|
||||||
cors.allowed-origins=${CORS:https://beta.alttd.com}
|
cors.allowed-origins=${CORS:https://beta.alttd.com}
|
||||||
|
server.address=${SERVER_ADDRESS:https://beta.alttd.com}
|
||||||
logging.level.com.alttd.altitudeweb=DEBUG
|
logging.level.com.alttd.altitudeweb=DEBUG
|
||||||
|
|
|
||||||
|
|
@ -5,4 +5,5 @@ database.host=${DB_HOST:localhost}
|
||||||
database.user=${DB_USER:root}
|
database.user=${DB_USER:root}
|
||||||
database.password=${DB_PASSWORD:root}
|
database.password=${DB_PASSWORD:root}
|
||||||
cors.allowed-origins=${CORS:http://localhost:4200}
|
cors.allowed-origins=${CORS:http://localhost:4200}
|
||||||
|
server.address=${SERVER_ADDRESS:http://localhost}
|
||||||
logging.level.com.alttd.altitudeweb=DEBUG
|
logging.level.com.alttd.altitudeweb=DEBUG
|
||||||
|
|
|
||||||
|
|
@ -8,4 +8,5 @@ cors.allowed-origins=${CORS:https://alttd.com}
|
||||||
login.secret=${LOGIN_SECRET:SET_TOKEN}
|
login.secret=${LOGIN_SECRET:SET_TOKEN}
|
||||||
particles.file_path=${user.home}/.altitudeweb/particles
|
particles.file_path=${user.home}/.altitudeweb/particles
|
||||||
notification.server.url=${SERVER_IP:10.0.0.107}:${SERVER_PORT:8080}
|
notification.server.url=${SERVER_IP:10.0.0.107}:${SERVER_PORT:8080}
|
||||||
|
server.address=${SERVER_ADDRESS:https://alttd.com}
|
||||||
logging.level.com.alttd.altitudeweb=INFO
|
logging.level.com.alttd.altitudeweb=INFO
|
||||||
|
|
|
||||||
|
|
@ -11,13 +11,12 @@ public interface PrivilegedUserMapper {
|
||||||
/**
|
/**
|
||||||
* Retrieves a user by their UUID along with their permissions
|
* Retrieves a user by their UUID along with their permissions
|
||||||
* @param uuid The UUID of the user to retrieve
|
* @param uuid The UUID of the user to retrieve
|
||||||
* @return The PrivilegedUser with their permissions, or null if not found
|
* @return The optional PrivilegedUser with their permissions
|
||||||
*/
|
*/
|
||||||
@Select("""
|
@Select("""
|
||||||
SELECT privileged_users.id, privileged_users.uuid, privileges.privileges as permission
|
SELECT id, uuid
|
||||||
FROM privileged_users
|
FROM privileged_users
|
||||||
LEFT JOIN privileges ON privileged_users.id = privileges.user_id
|
WHERE uuid = #{uuid}
|
||||||
WHERE privileged_users.uuid = #{uuid}
|
|
||||||
""")
|
""")
|
||||||
@Results({
|
@Results({
|
||||||
@Result(property = "id", column = "id"),
|
@Result(property = "id", column = "id"),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user