more work on establishing credentials
This commit is contained in:
parent
67705aa2d1
commit
10fd1d6028
@ -17,23 +17,18 @@ use crate::errors::*;
|
||||
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[serde(rename_all = "PascalCase")]
|
||||
#[serde(untagged)]
|
||||
pub enum Credentials {
|
||||
#[serde(rename_all = "PascalCase")]
|
||||
LongLived {
|
||||
#[serde(rename = "AccessKeyId")]
|
||||
access_key_id: String,
|
||||
#[serde(rename = "SecretAccessKey")]
|
||||
secret_access_key: String,
|
||||
},
|
||||
#[serde(rename_all = "PascalCase")]
|
||||
ShortLived {
|
||||
#[serde(rename = "AccessKeyId")]
|
||||
access_key_id: String,
|
||||
#[serde(rename = "SecretAccessKey")]
|
||||
secret_access_key: String,
|
||||
#[serde(rename = "Token")]
|
||||
token: String,
|
||||
#[serde(rename = "Expiration")]
|
||||
expiration: String,
|
||||
},
|
||||
}
|
||||
@ -130,7 +125,16 @@ impl AppState {
|
||||
// fresh salt every time we encrypt, but better safe than sorry
|
||||
let nonce = secretbox::gen_nonce();
|
||||
let key_enc = secretbox::seal(secret_key.as_bytes(), &nonce, &key);
|
||||
|
||||
// insert into database
|
||||
|
||||
// eventually replace this with a temporary session
|
||||
let mut session = self.session.write().unwrap();
|
||||
*session = Session::Unlocked(Credentials::LongLived {
|
||||
access_key_id: key_id,
|
||||
secret_access_key: secret_key,
|
||||
});
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@ function navigate(svelteEvent) {
|
||||
const moduleName = `./views/${svelteEvent.detail.target}.svelte`;
|
||||
currentView = VIEWS[moduleName].default;
|
||||
}
|
||||
window.navigate = navigate;
|
||||
|
||||
listen('credentials-request', (tauriEvent) => {
|
||||
appState.pendingRequests.put(tauriEvent.payload);
|
||||
|
@ -11,8 +11,8 @@ export default function() {
|
||||
|
||||
put(item) {
|
||||
this.items.push(item);
|
||||
if (this.resolvers.length > 0) {
|
||||
let resolver = this.resolvers.shift();
|
||||
let resolver = this.resolvers.shift();
|
||||
if (resolver) {
|
||||
resolver();
|
||||
}
|
||||
},
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
export let appState;
|
||||
|
||||
const dispatch = createEventDispatcher;
|
||||
const dispatch = createEventDispatcher();
|
||||
let AccessKeyId, SecretAccessKey, passphrase
|
||||
|
||||
async function save() {
|
||||
@ -14,10 +14,10 @@
|
||||
console.log(credentials);
|
||||
await invoke('save_credentials', {credentials, passphrase});
|
||||
if (appState.currentRequest) {
|
||||
dispatch('navigate', {target: 'Approve'})
|
||||
dispatch('navigate', {target: 'ShowApproved'})
|
||||
}
|
||||
else {
|
||||
dispatch('navigate', {target: Home})
|
||||
dispatch('navigate', {target: 'Home'})
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user