[backend/middleware] Improve error handling in AuthorizedFetchMiddlewre
This commit is contained in:
parent
9591255220
commit
2756e19399
1 changed files with 8 additions and 3 deletions
|
@ -41,12 +41,17 @@ public class AuthorizedFetchMiddleware(
|
||||||
|
|
||||||
// If we don't, we need to try to fetch it
|
// If we don't, we need to try to fetch it
|
||||||
if (key == null) {
|
if (key == null) {
|
||||||
|
try {
|
||||||
var user = await userResolver.ResolveAsync(sig.KeyId);
|
var user = await userResolver.ResolveAsync(sig.KeyId);
|
||||||
key = await db.UserPublickeys.Include(p => p.User).FirstOrDefaultAsync(p => p.User == user);
|
key = await db.UserPublickeys.Include(p => p.User).FirstOrDefaultAsync(p => p.User == user);
|
||||||
}
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
throw new GracefulException($"Failed to fetch key of signature user ({sig.KeyId}) - {e.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If we still don't have the key, something went wrong and we need to throw an exception
|
// If we still don't have the key, something went wrong and we need to throw an exception
|
||||||
if (key == null) throw new GracefulException("Failed to fetch key of signature user");
|
if (key == null) throw new GracefulException($"Failed to fetch key of signature user ({sig.KeyId})");
|
||||||
|
|
||||||
if (key.User.Host == null)
|
if (key.User.Host == null)
|
||||||
throw new GracefulException("Remote user must have a host");
|
throw new GracefulException("Remote user must have a host");
|
||||||
|
|
Loading…
Add table
Reference in a new issue