Hi
Can you check this? https://support.abp.io/QA/Questions/1386/Can't-log-in-as-new-tenant#answer-a265843f-df4c-4f23-9128-39fcdeeec049
Hi,
I have tried, but can not reproduce the problem, can you provide a project? thanks. shiwei.liang@volosoft.com
Hi,
you can't use proxy file to download files, It only works for json objects.
This is the download method code of the file management module, you can refer it:
downloadFile(file: FileInfo) {
return this.fileDescriptorService.getDownloadToken(file.id).pipe(
tap((res) => {
window.open(
`${this.apiUrl}/api/file-management/file-descriptor/download/${file.id}?token=${res.token}`,
'_self'
);
})
);
}
Hi,
Try:
[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(IMethodInvocationAuthorizationService))]
public class MyMethodInvocationAuthorizationService : IMethodInvocationAuthorizationService, ITransientDependency
{
private readonly IAbpAuthorizationPolicyProvider _abpAuthorizationPolicyProvider;
private readonly IAbpAuthorizationService _abpAuthorizationService;
public MyMethodInvocationAuthorizationService(IAbpAuthorizationPolicyProvider abpAuthorizationPolicyProvider, IAbpAuthorizationService abpAuthorizationService)
{
_abpAuthorizationPolicyProvider = abpAuthorizationPolicyProvider;
_abpAuthorizationService = abpAuthorizationService;
}
public async Task CheckAsync(MethodInvocationAuthorizationContext context)
{
if (AllowAnonymous(context))
{
return;
}
var authorizationPolicy = await AuthorizationPolicy.CombineAsync(
_abpAuthorizationPolicyProvider,
GetAuthorizationDataAttributes(context.Method)
);
if (authorizationPolicy == null)
{
return;
}
var result = await _abpAuthorizationService.AuthorizeAsync(authorizationPolicy);
if (!result.Succeeded)
{
var requirements = result.Failure.FailedRequirements;
var missingPermissionBuilder = new StringBuilder();
foreach (var requirement in requirements)
{
if (requirement is PermissionRequirement abpRequirement)
{
missingPermissionBuilder.AppendLine(abpRequirement.PermissionName);
}
}
throw new AuthorizationException(
$"The next permissions are required:\r\n\r\n{missingPermissionBuilder}");
}
}
protected virtual bool AllowAnonymous(MethodInvocationAuthorizationContext context)
{
return context.Method.GetCustomAttributes(true).OfType<IAllowAnonymous>().Any();
}
protected virtual IEnumerable<IAuthorizeData> GetAuthorizationDataAttributes(MethodInfo methodInfo)
{
var attributes = methodInfo
.GetCustomAttributes(true)
.OfType<IAuthorizeData>();
if (methodInfo.IsPublic && methodInfo.DeclaringType != null)
{
attributes = attributes
.Union(
methodInfo.DeclaringType
.GetCustomAttributes(true)
.OfType<IAuthorizeData>()
);
}
return attributes;
}
}
Is this what you want?
Hi,
I will check it.
You will notice that I deleted the file link, because your license is included in the source code, I don't think you want to disclose it :)
Hi,
Please share the project to me again. thanks.