Erase secrets after view (#1)
Reviewed-on: root/psssecret#1 Co-authored-by: Ivan Golikov <root@ivnglkv.me> Co-committed-by: Ivan Golikov <root@ivnglkv.me>
This commit is contained in:
		
							parent
							
								
									d2babe2567
								
							
						
					
					
						commit
						83e790be74
					
				
					 2 changed files with 14 additions and 2 deletions
				
			
		
							
								
								
									
										1
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							|  | @ -4,3 +4,4 @@ dist/ | ||||||
| rectes.egg-info/ | rectes.egg-info/ | ||||||
| build/ | build/ | ||||||
| conf/rectes.toml | conf/rectes.toml | ||||||
|  | __pycache__/ | ||||||
|  |  | ||||||
|  | @ -1,4 +1,5 @@ | ||||||
| from fastapi import FastAPI | from fastapi import FastAPI | ||||||
|  | from fastapi.exceptions import HTTPException | ||||||
| 
 | 
 | ||||||
| from rectes.models import Secret, SecretSaveResult | from rectes.models import Secret, SecretSaveResult | ||||||
| from rectes.redis_db import redis | from rectes.redis_db import redis | ||||||
|  | @ -18,8 +19,18 @@ async def set_secret(data: Secret): | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @app.get("/secret/{secret_key}", response_model=Secret) | @app.get( | ||||||
|  |     "/secret/{secret_key}", | ||||||
|  |     response_model=Secret, | ||||||
|  |     responses={404: {"description": "The item was not found"}}, | ||||||
|  | ) | ||||||
| async def get_secret(secret_key): | async def get_secret(secret_key): | ||||||
|  |     data = await redis.get(secret_key) | ||||||
|  | 
 | ||||||
|  |     if data is None: | ||||||
|  |         raise HTTPException(404) | ||||||
|  | 
 | ||||||
|  |     await redis.delete(secret_key) | ||||||
|     return { |     return { | ||||||
|         "data": await redis.get(secret_key), |         "data": data, | ||||||
|     } |     } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue