mirror of
				https://codeberg.org/forgejo/forgejo.git
				synced 2025-10-31 06:21:11 +00:00 
			
		
		
		
	fix: extend forgejo_auth_token table
		
	- Add a `purpose` column, this allows the `forgejo_auth_token` table to be used by other parts of Forgejo, while still enjoying the no-compromise architecture. - Remove the 'roll your own crypto' time limited code functions and migrate them to the `forgejo_auth_token` table. This migration ensures generated codes can only be used for their purpose and ensure they are invalidated after their usage by deleting it from the database, this also should help making auditing of the security code easier, as we're no longer trying to stuff a lot of data into a HMAC construction. -Helper functions are rewritten to ensure a safe-by-design approach to these tokens. - Add the `forgejo_auth_token` to dbconsistency doctor and add it to the `deleteUser` function. - TODO: Add cron job to delete expired authorization tokens. - Unit and integration tests added.
This commit is contained in:
		
					parent
					
						
							
								0fa436c373
							
						
					
				
			
			
				commit
				
					
						1ce33aa38d
					
				
			
		
					 18 changed files with 448 additions and 256 deletions
				
			
		|  | @ -243,6 +243,9 @@ func checkDBConsistency(ctx context.Context, logger log.Logger, autofix bool) er | |||
| 		// find archive download count without existing release | ||||
| 		genericOrphanCheck("Archive download count without existing Release", | ||||
| 			"repo_archive_download_count", "release", "repo_archive_download_count.release_id=release.id"), | ||||
| 		// find authorization tokens without existing user | ||||
| 		genericOrphanCheck("Authorization token without existing User", | ||||
| 			"forgejo_auth_token", "user", "forgejo_auth_token.uid=user.id"), | ||||
| 	) | ||||
| 
 | ||||
| 	for _, c := range consistencyChecks { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue