Rest API
WebAPI Adapter is a component that expose the functionality of the TopSecret application through a web API. It allows external systems to interact with the application using standard HTTP methods.
DecryptRequest
¶
Bases: BaseModel
Request model for decryption.
Source code in topsecret/adapters/webapi.py
55 56 57 58 |
|
DecryptResponse
¶
Bases: BaseModel
Response model for decryption.
Source code in topsecret/adapters/webapi.py
61 62 63 64 |
|
EncryptRequest
¶
Bases: BaseModel
Request model for encryption.
Source code in topsecret/adapters/webapi.py
41 42 43 44 45 |
|
EncryptResponse
¶
Bases: BaseModel
Response model for encryption.
Source code in topsecret/adapters/webapi.py
48 49 50 51 52 |
|
api_info()
async
¶
Return API information.
Source code in topsecret/adapters/webapi.py
160 161 162 163 164 165 166 167 |
|
decrypt_secret(hash_value, request=Body(default=None))
async
¶
Decrypt a secret given its hash value.
This endpoint attempts to decrypt a secret identified by its hash.
An optional passphrase can be provided in the request body.
Args:
hash_value: The hash identifier of the secret to be decrypted.
request: An optional request body containing the passphrase.
If not provided or if passphrase
is None, decryption
will be attempted without a passphrase.
Returns:
A DecryptResponse object containing the decrypted secret text.
Raises:
HTTPException: If decryption fails (e.g., due to an incorrect
passphrase or invalid hash), an HTTP 401 Unauthorized
error is raised with details of the decryption error.
Source code in topsecret/adapters/webapi.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
|
encrypt_secret(request, base_url=Depends(get_base_url))
async
¶
Encrypts a secret provided in the request.
This endpoint takes a secret string and a passphrase, encrypts the secret, and returns a hash representing the encrypted data along with a URL that can be used to decrypt it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
request
|
EncryptRequest
|
An |
required |
base_url
|
str
|
The base URL of the application, injected as a dependency. Used to construct the decryption URL. |
Depends(get_base_url)
|
Returns:
Type | Description |
---|---|
EncryptResponse
|
An |
EncryptResponse
|
and the full URL for decryption. |
Raises:
Type | Description |
---|---|
HTTPException
|
If the |
Source code in topsecret/adapters/webapi.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
|
get_base_url(request)
¶
Extract base URL from request.
Source code in topsecret/adapters/webapi.py
67 68 69 |
|
get_theme_path(name)
¶
Get path to the HTML skin/theme.
Source code in topsecret/adapters/webapi.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
|
root(theme=None)
async
¶
Serve the HTML frontend.
Source code in topsecret/adapters/webapi.py
151 152 153 154 155 156 157 |
|