IdentityServer4 icon indicating copy to clipboard operation
IdentityServer4 copied to clipboard

JWT max size limit(2kb)

Open balaji-rajan opened this issue 7 years ago • 13 comments

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?

balaji-rajan avatar Feb 12 '19 14:02 balaji-rajan

When? What endpoint? What workflow?

brockallen avatar Feb 12 '19 16:02 brockallen

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;

balaji-rajan avatar Feb 13 '19 03:02 balaji-rajan

Throwed when requesting more scopes in JWT

What do you mean here?

brockallen avatar Feb 13 '19 12:02 brockallen

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....

primalfear avatar Feb 13 '19 12:02 primalfear

@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

........

balaji-rajan avatar Feb 13 '19 15:02 balaji-rajan

We limit (by default) the length of the scopes request parameter to 300 characters.

brockallen avatar Feb 13 '19 20:02 brockallen

@brockallen agree its default, but i'm curious to know the reason behind 300? also why IDS is just responding as scope_invalid?

balaji-rajan avatar Feb 13 '19 20:02 balaji-rajan

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?

brockallen avatar Feb 13 '19 20:02 brockallen

Error log is perfect IdentityServer4.Validation.TokenRequestValidator: Error: Scope parameter exceeds max allowed length. but token endpoint returns Bad Request with message scope_invalid

image

Could you also suggest what could be the ideal length for scope?

balaji-rajan avatar Feb 13 '19 20:02 balaji-rajan

So all of those messages explain what's happening perfectly, yes. Why is your incoming scope larger than 300 characters?

brockallen avatar Feb 13 '19 21:02 brockallen

we've a long list of scopes to support to growing microservices/ apis /microfrontends

balaji-rajan avatar Feb 14 '19 06:02 balaji-rajan

It's simple -- change that config value to accommodate your long list of scopes.

brockallen avatar Feb 14 '19 13:02 brockallen

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.

lock[bot] avatar Jan 11 '20 20:01 lock[bot]