Skip to content

Commit

Permalink
Merge branch 'main' into fix/brokenthing
Browse files Browse the repository at this point in the history
  • Loading branch information
jaybeeelsdon committed Dec 13, 2024
2 parents e9ee639 + c6131b1 commit 2d1ee31
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Data-Egress-API/Controllers/TreCredentialsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,19 @@ public class TreCredentialsController : Controller
private readonly IEncDecHelper _encDecHelper;

public KeycloakTokenHelper _keycloakTokenHelper { get; set; }
public KeycloakTokenHelper _egressKeycloakTokenHelper { get; set; }


public TreCredentialsController(ApplicationDbContext applicationDbContext, IEncDecHelper encDec, TreKeyCloakSettings keycloakSettings)
public TreCredentialsController(ApplicationDbContext applicationDbContext, IEncDecHelper encDec, TreKeyCloakSettings keycloakSettings, DataEgressKeyCloakSettings egressKeyCloakSettings)
{
_encDecHelper = encDec;
_DbContext = applicationDbContext;
_keycloakTokenHelper = new KeycloakTokenHelper(keycloakSettings.BaseUrl, keycloakSettings.ClientId,
keycloakSettings.ClientSecret, keycloakSettings.Proxy, keycloakSettings.ProxyAddresURL, keycloakSettings.DemoMode);

_egressKeycloakTokenHelper = new KeycloakTokenHelper(egressKeyCloakSettings.BaseUrl, egressKeyCloakSettings.ClientId,
egressKeyCloakSettings.ClientSecret, egressKeyCloakSettings.Proxy, egressKeyCloakSettings.ProxyAddresURL, egressKeyCloakSettings.DemoMode);

}


Expand Down Expand Up @@ -68,7 +72,7 @@ public async Task<BoolReturn> EgressCheckCredentialsAreValidAsync()
var creds = _DbContext.KeycloakCredentials.FirstOrDefault(x => x.CredentialType == CredentialType.Egress);
if (creds != null)
{
var token = await _keycloakTokenHelper.GetTokenForUser(creds.UserName,
var token = await _egressKeycloakTokenHelper.GetTokenForUser(creds.UserName,
_encDecHelper.Decrypt(creds.PasswordEnc), "data-egress-admin");
result.Result = !string.IsNullOrWhiteSpace(token);

Expand All @@ -90,7 +94,7 @@ public async Task<KeycloakCredentials> EgressUpdateCredentials(KeycloakCredentia
try
{
creds.Valid = true;
var token = await _keycloakTokenHelper.GetTokenForUser(creds.UserName,
var token = await _egressKeycloakTokenHelper.GetTokenForUser(creds.UserName,
creds.PasswordEnc, "data-egress-admin");
if (string.IsNullOrWhiteSpace(token))
{
Expand Down

0 comments on commit 2d1ee31

Please sign in to comment.