diff options
author | vnugent <public@vaughnnugent.com> | 2024-04-15 16:22:38 -0400 |
---|---|---|
committer | vnugent <public@vaughnnugent.com> | 2024-04-15 16:22:38 -0400 |
commit | 2a2078b8cc3dd216c46419bce7577ae572317955 (patch) | |
tree | a9518e5da814af4d5faaaab83941c806ccb4dabf /libs | |
parent | 9c8da6ea8fabe1d752bb28fd5eaeeb0b1d06d94d (diff) |
fix: fixed bearer token header requirments from crashing
Diffstat (limited to 'libs')
-rw-r--r-- | libs/VNLib.Plugins.Sessions.OAuth/src/OAuth2TokenFactory.cs | 10 |
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; |