diff --git a/src/SimpleAuthentication.Swashbuckle/SimpleAuthentication.Swashbuckle.csproj b/src/SimpleAuthentication.Swashbuckle/SimpleAuthentication.Swashbuckle.csproj
index 2d801a9..3210d6f 100644
--- a/src/SimpleAuthentication.Swashbuckle/SimpleAuthentication.Swashbuckle.csproj
+++ b/src/SimpleAuthentication.Swashbuckle/SimpleAuthentication.Swashbuckle.csproj
@@ -32,7 +32,7 @@
-
+
diff --git a/src/SimpleAuthentication/ApiKey/ApiKeyAuthenticationHandler.cs b/src/SimpleAuthentication/ApiKey/ApiKeyAuthenticationHandler.cs
index 8f764c9..a3acb67 100644
--- a/src/SimpleAuthentication/ApiKey/ApiKeyAuthenticationHandler.cs
+++ b/src/SimpleAuthentication/ApiKey/ApiKeyAuthenticationHandler.cs
@@ -45,9 +45,12 @@ protected override async Task HandleAuthenticateAsync()
if (apiKey is not null)
{
var claims = new List();
- foreach (var role in apiKey.Roles)
+ if (apiKey.Roles is not null)
{
- claims.Add(new(Options.RoleClaimType, role));
+ foreach (var role in apiKey.Roles)
+ {
+ claims.Add(new(Options.RoleClaimType, role));
+ }
}
return CreateAuthenticationSuccessResult(apiKey.UserName, claims);
diff --git a/src/SimpleAuthentication/BasicAuthentication/BasicAuthenticationHandler.cs b/src/SimpleAuthentication/BasicAuthentication/BasicAuthenticationHandler.cs
index 21bd814..f8e54c0 100644
--- a/src/SimpleAuthentication/BasicAuthentication/BasicAuthenticationHandler.cs
+++ b/src/SimpleAuthentication/BasicAuthentication/BasicAuthenticationHandler.cs
@@ -59,9 +59,12 @@ protected override async Task HandleAuthenticateAsync()
if (credential is not null)
{
var claims = new List();
- foreach (var role in credential.Roles)
+ if (credential.Roles is not null)
{
- claims.Add(new(Options.RoleClaimType, role));
+ foreach (var role in credential.Roles)
+ {
+ claims.Add(new(Options.RoleClaimType, role));
+ }
}
return CreateAuthenticationSuccessResult(credential.UserName, claims);
diff --git a/src/SimpleAuthentication/SimpleAuthentication.csproj b/src/SimpleAuthentication/SimpleAuthentication.csproj
index 1234ed7..14d2622 100644
--- a/src/SimpleAuthentication/SimpleAuthentication.csproj
+++ b/src/SimpleAuthentication/SimpleAuthentication.csproj
@@ -35,7 +35,7 @@
-
+