JWT max size limit(2kb)
We ran into an issue where IdentityServer returning invalid_scope when JWT hit max size limit of 2kb? is this an in-built validation in IDS which does this? and can we control/override this behavior?
When? What endpoint? What workflow?
Grant: client_credentials Endpoint:connect/token
Throwed when requesting more scopes in JWT
Also, Is this in place to limit token size?
/// <summary>
/// Max length for scope
/// </summary>
public int Scope { get; set; } = 300;
Throwed when requesting more scopes in JWT
What do you mean here?
Hi @balaji-rajan What is the exact error / exception you're getting? Are you experiencing this issue in web browsers? (An if so which)
When i first start using identity server, i was basically using claims for permissions and things (which claims are not actually we suited to) and was hitting querystring parameter length issues on certain browsers. https://stackoverflow.com/questions/812925/what-is-the-maximum-possible-length-of-a-query-string
This is also an article i found rather useful in terms of how to think about things to reduce the what you put in claims: https://leastprivilege.com/2016/12/16/identity-vs-permissions
hope this helps....
@brockallen sorry about missing more context.
would like to know whats the thought/influence factor to restrict input length to 300? Is it overcome restriction on browsers like IE(2kb) ? yes, its configurable but what would be the ideal length?
and why IDS is returning a very generic message as 'scope_invalid' instead of being specific message like exceeds the maximum scope length
namespace IdentityServer4.Configuration
{
public class InputLengthRestrictions
{
/// <summary>
/// Max length for scope
/// </summary>
public int Scope { get; set; } = 300
........
We limit (by default) the length of the scopes request parameter to 300 characters.
@brockallen agree its default, but i'm curious to know the reason behind 300? also why IDS is just responding as scope_invalid?
We do simple input length restrictions for security, overflow concerns. You can always change it.
I don't know if that's related to your scope error. What did you logs say when you got that error?
Error log is perfect IdentityServer4.Validation.TokenRequestValidator: Error: Scope parameter exceeds max allowed length. but token endpoint returns Bad Request with message scope_invalid

Could you also suggest what could be the ideal length for scope?
So all of those messages explain what's happening perfectly, yes. Why is your incoming scope larger than 300 characters?
we've a long list of scopes to support to growing microservices/ apis /microfrontends
It's simple -- change that config value to accommodate your long list of scopes.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.