Using ASP.NET Identity, WebAPI, and UseOAuthBearerTokens
public void Configuration(IAppBuilder app)
{
app.UseOAuthBearerTokens(new OAuthAuthorizationServerOptions
{
AllowInsecureHttp = true,
TokenEndpointPath = new PathString("/token"),
AccessTokenExpireTimeSpan = TimeSpan.FromDays(1),
Provider = new CustomProvider(...))
});
}
The API returns a token string upon a valid login request. The token works correctly and gives the end user access to authorized portions of the API, however, if the final character of the token string is altered it sometimes still works. It appears that this is only the case for the final character of the string and only some values/alterations still allow the token to be valid. Why is this the case? Is this a problem with the code or just part of Identity?
For Example: The token returned from the server is
mdC0XvL4VBucyMPD-OvQ0KA5vW1Q8OHdF4OtqET5hEFI20uaOXbX4JlzTwkLRmWUr-4cIzQf1adXx5DbnXltuwcSjiX1NEY5DqhS3c9GyU1c2VqLAOUYj4-BraaheNsCPvReZqvT__NsObpziKX98SY4gSUGDBVigVONdvlpRunzPZlIeJh99jBqzavuo4qSEElAlBNvNFts95aN7otO5-bNiDNl1t_CP9PQWcTIipMNe_No2J8wGbmIvEWCBAhN3Ts6lvmFpHSA02up1YykZoDZa0TZY7QOt187aP9-7kN
You could change the N (at the end of the token string) to an O or a P and it would still allow the user to access the API