aboutsummaryrefslogtreecommitdiff
path: root/libs/VNLib.Plugins.Sessions.OAuth
diff options
context:
space:
mode:
authorLibravatar vnugent <public@vaughnnugent.com>2024-04-15 16:22:38 -0400
committerLibravatar vnugent <public@vaughnnugent.com>2024-04-15 16:22:38 -0400
commit2a2078b8cc3dd216c46419bce7577ae572317955 (patch)
treea9518e5da814af4d5faaaab83941c806ccb4dabf /libs/VNLib.Plugins.Sessions.OAuth
parent9c8da6ea8fabe1d752bb28fd5eaeeb0b1d06d94d (diff)
fix: fixed bearer token header requirments from crashing
Diffstat (limited to 'libs/VNLib.Plugins.Sessions.OAuth')
-rw-r--r--libs/VNLib.Plugins.Sessions.OAuth/src/OAuth2TokenFactory.cs10
1 files changed, 7 insertions, 3 deletions
diff --git a/libs/VNLib.Plugins.Sessions.OAuth/src/OAuth2TokenFactory.cs b/libs/VNLib.Plugins.Sessions.OAuth/src/OAuth2TokenFactory.cs
index 6d055df..e3588ab 100644
--- a/libs/VNLib.Plugins.Sessions.OAuth/src/OAuth2TokenFactory.cs
+++ b/libs/VNLib.Plugins.Sessions.OAuth/src/OAuth2TokenFactory.cs
@@ -104,9 +104,13 @@ namespace VNLib.Plugins.Sessions.OAuth
{
int bearerIndex = authorization.IndexOf(_config.TokenType, StringComparison.OrdinalIgnoreCase);
- //Calc token offset, get token, and trim any whitespace
- token = authorization.AsSpan(bearerIndex + _config.TokenType.Length).Trim().ToString();
- return true;
+ //Check if the token type is present
+ if (bearerIndex >= 0)
+ {
+ //Calc token offset, get token, and trim any whitespace
+ token = authorization.AsSpan(bearerIndex + _config.TokenType.Length).Trim().ToString();
+ return true;
+ }
}
token = null;