Backend for new SSH page #47

Merged
esy merged 9 commits from #24_ssh_keys into main 2023-12-31 06:56:30 +00:00
2 changed files with 65 additions and 2 deletions
Showing only changes of commit c72ade8dab - Show all commits

View file

@ -179,13 +179,76 @@ Errors:
```json
{"result": "error", "error": "no valid key"}
```
#### Success
```json
{"result": "success", "success": "key valid"}
```
### POST /ldap/ssh
Returns array of SSH keys associated with the Skynet account
```json
{
"auth" : {
"user": "username",
"pass": "password"
}
}
```
#### Errors
```json
{"result": "error", "error": "Failed to authenticate"}
```
#### Success
```json
{"result": "success", "success": ["key1","key2","key3"]}
```
### DELETE /ldap/ssh
Deletes SSH key from Skynet account
```json
{
"auth" : {
"user": "username",
"pass": "password"
},
"key": "ssh key"
}
```
#### Errors
```json
{"result": "error", "error": "Failed to authenticate"}
```
```json
{"result": "error", "error": "Failed to remove key"}
```
#### Success
```json
{"result": "success"}
```
### POST /ldap/ssh/add
Adds SSH key to Skynet account
```json
{
"auth" : {
"user": "username",
"pass": "password"
},
"key": "ssh key"
}
```
#### Errors
```json
{"result": "error", "error": "Failed to authenticate"}
```
```json
{"result": "error", "error": "Failed to add key"}
```
#### Success
```json
{"result": "success"}
```
## Responses
Generic responses which is used unless otherwise specified above.

View file

@ -64,7 +64,7 @@ pub async fn remove_ssh_key(mut req: Request<State>) -> tide::Result {
Ok(_) => Ok(json!({"result": "success"}).into()),
Err(e) => {
dbg!(e);
Ok(json!({"result": "error", "error": "Failed to add key"}).into())
Ok(json!({"result": "error", "error": "Failed to remove key"}).into())
}
};