Skip to content

Commit

Permalink
fix: load custom claim provider
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Mar 23, 2022
1 parent 9b5599a commit f8581f0
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,18 @@ protected virtual Task<IEnumerable<Claim>> GetClaimsFromResource(Resource resour

if (provider == null)
{
var path = resource.Properties[ProfileServiceProperties.ClaimProviderAssemblyPathKey];
#pragma warning disable S3885 // "Assembly.Load" should be used
var assembly = Assembly.LoadFrom(path);
#pragma warning restore S3885 // "Assembly.Load" should be used
var type = assembly.GetType(providerTypeName);
provider = Activator.CreateInstance(type) as IProvideClaims;
try
{
var path = resource.Properties[ProfileServiceProperties.ClaimProviderAssemblyPathKey];
var assembly = Assembly.LoadFile(path);
var type = assembly.GetType(providerTypeName, true);
provider = Activator.CreateInstance(type) as IProvideClaims;
}
catch(Exception e)
{
Logger.LogError(e, e.Message);
return Task.FromResult(Array.Empty<Claim>().AsEnumerable());
}
}

return provider.ProvideClaims(subject, client, caller, resource);
Expand Down

0 comments on commit f8581f0

Please sign in to comment.