mirror of
				https://github.com/superseriousbusiness/gotosocial.git
				synced 2025-10-31 10:22:25 -05:00 
			
		
		
		
	[chore]: Bump github.com/golang-jwt/jwt/v5 from 5.2.1 to 5.2.2 (#3927)
Bumps [github.com/golang-jwt/jwt/v5](https://github.com/golang-jwt/jwt) from 5.2.1 to 5.2.2. - [Release notes](https://github.com/golang-jwt/jwt/releases) - [Changelog](https://github.com/golang-jwt/jwt/blob/main/VERSION_HISTORY.md) - [Commits](https://github.com/golang-jwt/jwt/compare/v5.2.1...v5.2.2) --- updated-dependencies: - dependency-name: github.com/golang-jwt/jwt/v5 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
		
					parent
					
						
							
								f7e5f31c6b
							
						
					
				
			
			
				commit
				
					
						4af8d1a2cb
					
				
			
		
					 7 changed files with 48 additions and 17 deletions
				
			
		
							
								
								
									
										36
									
								
								vendor/github.com/golang-jwt/jwt/v5/parser.go
									
										
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										36
									
								
								vendor/github.com/golang-jwt/jwt/v5/parser.go
									
										
									
										generated
									
									
										vendored
									
									
								
							|  | @ -8,6 +8,8 @@ import ( | |||
| 	"strings" | ||||
| ) | ||||
| 
 | ||||
| const tokenDelimiter = "." | ||||
| 
 | ||||
| type Parser struct { | ||||
| 	// If populated, only these methods will be considered valid. | ||||
| 	validMethods []string | ||||
|  | @ -136,9 +138,10 @@ func (p *Parser) ParseWithClaims(tokenString string, claims Claims, keyFunc Keyf | |||
| // It's only ever useful in cases where you know the signature is valid (since it has already | ||||
| // been or will be checked elsewhere in the stack) and you want to extract values from it. | ||||
| func (p *Parser) ParseUnverified(tokenString string, claims Claims) (token *Token, parts []string, err error) { | ||||
| 	parts = strings.Split(tokenString, ".") | ||||
| 	if len(parts) != 3 { | ||||
| 		return nil, parts, newError("token contains an invalid number of segments", ErrTokenMalformed) | ||||
| 	var ok bool | ||||
| 	parts, ok = splitToken(tokenString) | ||||
| 	if !ok { | ||||
| 		return nil, nil, newError("token contains an invalid number of segments", ErrTokenMalformed) | ||||
| 	} | ||||
| 
 | ||||
| 	token = &Token{Raw: tokenString} | ||||
|  | @ -196,6 +199,33 @@ func (p *Parser) ParseUnverified(tokenString string, claims Claims) (token *Toke | |||
| 	return token, parts, nil | ||||
| } | ||||
| 
 | ||||
| // splitToken splits a token string into three parts: header, claims, and signature. It will only | ||||
| // return true if the token contains exactly two delimiters and three parts. In all other cases, it | ||||
| // will return nil parts and false. | ||||
| func splitToken(token string) ([]string, bool) { | ||||
| 	parts := make([]string, 3) | ||||
| 	header, remain, ok := strings.Cut(token, tokenDelimiter) | ||||
| 	if !ok { | ||||
| 		return nil, false | ||||
| 	} | ||||
| 	parts[0] = header | ||||
| 	claims, remain, ok := strings.Cut(remain, tokenDelimiter) | ||||
| 	if !ok { | ||||
| 		return nil, false | ||||
| 	} | ||||
| 	parts[1] = claims | ||||
| 	// One more cut to ensure the signature is the last part of the token and there are no more | ||||
| 	// delimiters. This avoids an issue where malicious input could contain additional delimiters | ||||
| 	// causing unecessary overhead parsing tokens. | ||||
| 	signature, _, unexpected := strings.Cut(remain, tokenDelimiter) | ||||
| 	if unexpected { | ||||
| 		return nil, false | ||||
| 	} | ||||
| 	parts[2] = signature | ||||
| 
 | ||||
| 	return parts, true | ||||
| } | ||||
| 
 | ||||
| // DecodeSegment decodes a JWT specific base64url encoding. This function will | ||||
| // take into account whether the [Parser] is configured with additional options, | ||||
| // such as [WithStrictDecoding] or [WithPaddingAllowed]. | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue