Skip to content

Commit 1cdc91e

Browse files
authored
Merge pull request #11 from fossapps/10-verify-secret-more-info
feat(secretVerification): add more info
2 parents 578a239 + 614e7b2 commit 1cdc91e

3 files changed

Lines changed: 16 additions & 7 deletions

File tree

Micro.AppRegistration.Api/VerifySecret/VerifySecretController.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,7 @@ public async Task<IActionResult> Verify([FromHeader(Name = "Authorization")] [Re
3030
{
3131
var (appId, secret) = GetBasicAuthData(authorization);
3232
var result = await _verifySecretService.Verify(appId, secret);
33-
return Ok(new VerifySecretResponse
34-
{
35-
Success = result
36-
});
33+
return Ok(result);
3734
}
3835
catch (BadBasicAuthorizationDataException e)
3936
{

Micro.AppRegistration.Api/VerifySecret/VerifySecretResponse.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,9 @@ namespace Micro.AppRegistration.Api.VerifySecret
33
public class VerifySecretResponse
44
{
55
public bool Success { set; get; }
6+
public string Owner { set; get; }
7+
public string ShortCode { set; get; }
8+
public bool Approved { set; get; }
9+
public bool UseDefaultShortCode { set; get; }
610
}
711
}

Micro.AppRegistration.Api/VerifySecret/VerifySecretService.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace Micro.AppRegistration.Api.VerifySecret
77
{
88
public interface IVerifySecretService
99
{
10-
Task<bool> Verify(string appId, string secret);
10+
Task<VerifySecretResponse> Verify(string appId, string secret);
1111
}
1212
public class VerifySecretService : IVerifySecretService
1313
{
@@ -20,13 +20,21 @@ public VerifySecretService(IPasswordHasher<Application> secretHasher, IListAppli
2020
_applicationRepository = applicationRepository;
2121
}
2222

23-
public async Task<bool> Verify(string appId, string secret)
23+
public async Task<VerifySecretResponse> Verify(string appId, string secret)
2424
{
2525
var application = await _applicationRepository.FindById(appId);
2626
var result = _secretHasher.VerifyHashedPassword(null, application.Secret, secret);
2727
// todo: if result returns a rehash needed, we need re-hash password and save it in database.
2828
// to be done after MVP
29-
return result == PasswordVerificationResult.Success || result == PasswordVerificationResult.SuccessRehashNeeded;
29+
var success = result == PasswordVerificationResult.Success || result == PasswordVerificationResult.SuccessRehashNeeded;
30+
return new VerifySecretResponse
31+
{
32+
Success = success,
33+
Approved = application.Approved,
34+
Owner = application.User,
35+
ShortCode = application.ShortCode,
36+
UseDefaultShortCode = application.UseDefaultCode
37+
};
3038
}
3139
}
3240
}

0 commit comments

Comments
 (0)