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