Skip to content

Commit

Permalink
added authorization flag to external link validation response
Browse files Browse the repository at this point in the history
  • Loading branch information
MaksimChegulov committed Nov 29, 2024
1 parent 8087a85 commit cff1333
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,7 @@ public class ExternalShareDto : IMapFrom<ValidationInfo>
/// Link ID
/// </summary>
public Guid LinkId { get; set; }

/// <summary>Specifies whether the user is authenticated or not</summary>
public bool IsAuthenticated { get; set; }
}
4 changes: 4 additions & 0 deletions products/ASC.Files/Core/Core/Security/ExternalShare.cs
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,10 @@ public class ValidationInfo
/// <summary>Link ID</summary>
/// <type>System.Guid, System</type>
public Guid LinkId { get; set; }

/// <summary>Specifies whether the user is authenticated or not</summary>
/// <type>System.Boolean, System</type>
public bool IsAuthenticated { get; set; }
}

public record DownloadSession
Expand Down
5 changes: 3 additions & 2 deletions products/ASC.Files/Core/Helpers/ExternalLinkHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public async Task<ValidationInfo> ValidateAsync(string key, string password = nu
Status = Status.Invalid,
Access = FileShare.Restrict
};

var isAuth = securityContext.IsAuthenticated;
result.IsAuthenticated = isAuth;

var data = await externalShare.ParseShareKeyAsync(key);
var securityDao = daoFactory.GetSecurityDao<string>();
Expand All @@ -55,8 +58,6 @@ public async Task<ValidationInfo> ValidateAsync(string key, string password = nu
{
return result;
}

var isAuth = securityContext.IsAuthenticated;

var status = await externalShare.ValidateRecordAsync(record, password, isAuth);
result.Status = status;
Expand Down

0 comments on commit cff1333

Please sign in to comment.