Skip to content

Commit a4d7abb

Browse files
committed
Fix CI by deleting check IssuerSigningKey
1 parent c15118e commit a4d7abb

File tree

3 files changed

+20
-68
lines changed

3 files changed

+20
-68
lines changed

.github/workflows/compose-build.yml

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,18 @@ jobs:
2222
- name: Start Docker Compose
2323
run: docker compose up -d
2424

25-
# ToDo
26-
# - name: Health Check AuthService
27-
# run: |
28-
# echo "Checking health..."
29-
# for i in {1..10}; do
30-
# curl --fail http://localhost:8000/auth/health && break || sleep 5
31-
# curl --fail http://gateway:8000/auth/health && break || sleep 5
32-
# done
33-
# curl --fail http://localhost:8000/auth/health || exit 1
34-
#
35-
# - name: Health Check PostService
36-
# run: |
37-
# echo "Checking health..."
38-
# for i in {1..10}; do
39-
# curl --fail http://localhost:8000/post/health && break || sleep 5
40-
# curl --fail http://gateway:8000/post/health && break || sleep 5
41-
# done
42-
# curl --fail http://localhost:8000/post/health || exit 1
25+
- name: Health Check AuthService
26+
run: |
27+
echo "Checking health..."
28+
for i in {1..10}; do
29+
curl --fail http://0.0.0.0:8000/auth/health && break || sleep 5
30+
done
31+
curl --fail http://0.0.0.0:8000/auth/health || exit 1
32+
33+
- name: Health Check PostService
34+
run: |
35+
echo "Checking health..."
36+
for i in {1..10}; do
37+
curl --fail http://0.0.0.0:8000/post/health && break || sleep 5
38+
done
39+
curl --fail http://0.0.0.0:8000/post/health || exit 1

backend/src/AuthService/AuthService.Infrastructure/DependencyInjection.cs

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ public static IServiceCollection AddInfrastructureServices(this IServiceCollecti
2929
keycloakSection[AppSettingsConstants.AdminPassword]
3030
);
3131

32-
var rsaSecurityKey = GetRsaSecurityKeyFromKeycloak(keycloakConfig.Url, keycloakConfig.Realm);
33-
3432
services.AddSingleton(keycloakConfig);
3533

3634
services.AddHttpClient("KeycloakClient", client =>
@@ -63,7 +61,6 @@ public static IServiceCollection AddInfrastructureServices(this IServiceCollecti
6361
ValidAudience = "account",
6462
ValidateLifetime = true,
6563
ValidateIssuerSigningKey = false,
66-
IssuerSigningKey = rsaSecurityKey,
6764
SignatureValidator = (token, parameters) =>
6865
{
6966
var jwt = new JsonWebToken(token);
@@ -80,46 +77,4 @@ public static IServiceCollection AddInfrastructureServices(this IServiceCollecti
8077

8178
return services;
8279
}
83-
84-
private static RsaSecurityKey GetRsaSecurityKeyFromKeycloak(string keycloakUrl, string realm)
85-
{
86-
using var httpClient = new HttpClient();
87-
var certsUrl = $"{keycloakUrl}/realms/{realm}/protocol/openid-connect/certs";
88-
var response = httpClient.GetStringAsync(certsUrl).Result;
89-
90-
var jwks = JsonDocument.Parse(response).RootElement;
91-
var key = jwks.GetProperty("keys")[0];
92-
93-
var modulusBase64 = key.GetProperty("n").GetString()?.Trim();
94-
var exponentBase64 = key.GetProperty("e").GetString()?.Trim();
95-
96-
if (string.IsNullOrEmpty(modulusBase64) || string.IsNullOrEmpty(exponentBase64))
97-
{
98-
throw new FormatException("Invalid modulus or exponent in the public key");
99-
}
100-
101-
try
102-
{
103-
modulusBase64 = ConvertUrlBase64ToStandardBase64(modulusBase64);
104-
exponentBase64 = ConvertUrlBase64ToStandardBase64(exponentBase64);
105-
106-
var modulus = Convert.FromBase64String(modulusBase64);
107-
var exponent = Convert.FromBase64String(exponentBase64);
108-
109-
return new RsaSecurityKey(new RSAParameters
110-
{
111-
Modulus = modulus,
112-
Exponent = exponent
113-
});
114-
}
115-
catch (FormatException ex)
116-
{
117-
throw new FormatException("Base64 decoding failed for modulus or exponent", ex);
118-
}
119-
}
120-
121-
private static string ConvertUrlBase64ToStandardBase64(string urlBase64)
122-
{
123-
return urlBase64.Replace('-', '+').Replace('_', '/') + new string('=', (4 - urlBase64.Length % 4) % 4);
124-
}
12580
}

docker-compose.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ services:
1313
depends_on:
1414
gateway:
1515
condition: service_healthy
16-
networks:
16+
networks:
1717
- microservices
1818

1919
gateway:
@@ -36,7 +36,7 @@ services:
3636
interval: 10s
3737
timeout: 5s
3838
retries: 3
39-
networks:
39+
networks:
4040
- microservices
4141

4242
auth-service:
@@ -113,9 +113,9 @@ services:
113113
- "8080:8080"
114114
command: [ "start-dev" ]
115115
restart: always
116-
networks:
116+
networks:
117117
- microservices
118-
118+
119119
rabittmq:
120120
image: rabbitmq:4-management
121121
container_name: rabbitmq
@@ -134,4 +134,4 @@ services:
134134
- microservices
135135

136136
volumes:
137-
postgres-data:
137+
postgres-data:

0 commit comments

Comments
 (0)