Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ async function autoFillSecrets(message, sender) {
const vaultToken = await storage.local.get('vaultToken');
const vaultAddress = await storage.sync.get('vaultAddress');
const secretList = await storage.sync.get('secrets', []);
const storePath = await storage.sync.get('storePath');
const storeComponents = storePathComponents(storePath);

if (!vaultToken || !vaultAddress) return;

Expand All @@ -119,23 +117,35 @@ async function autoFillSecrets(message, sender) {

const matches = [];

for (const secret of secretList) {
const delimiter = '##';

for (const combined of secretList) {
const parts = combined.split(delimiter);
if (parts.length !== 2) {
console.error('Unexpected secret format:', combined);
continue;
}

const [secretStorePath, secretName] = parts;
const storeComponents = storePathComponents(secretStorePath);

const secretKeys = await vault.list(
`/${storeComponents.root}/metadata/${storeComponents.subPath}/${secret}`
`/${storeComponents.root}/metadata/${storeComponents.subPath}/${secretName}`
);

for (const key of secretKeys.data.keys) {
const pattern = new RegExp(key);
const patternMatches = pattern.test(hostname);

// Add entries to array if the hostname is a match
if (hostname === clearHostname(key)) {
const credentials = await vault.get(
`/${storeComponents.root}/data/${storeComponents.subPath}/${secret}${key}`
`/${storeComponents.root}/data/${storeComponents.subPath}/${secretName}${key}`
);

matches.push({
organization: secret,
secret: key,
organization: secretStorePath,
secret: secretName,
username: credentials.data.data.username,
password: credentials.data.data.password,
comment: credentials.data.data.comment,
Expand Down Expand Up @@ -275,13 +285,3 @@ chrome.runtime.onMessage.addListener(function (message, sender) {
}
});

// Listener to catch the fill_creds message and then forward it to the active tab
chrome.runtime.onMessage.addListener((request) => {
if (request.message === 'fill_creds') {
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
if (tabs.length) {
chrome.tabs.sendMessage(tabs[0].id, request);
}
});
}
});
23 changes: 17 additions & 6 deletions options.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,22 @@ <h1 class="h1 title">VaultPass</h1>
<input type="password" class="input" name="pass" id="passBox" />
</label>

<label class="label">
KV Stores:
<div id="storePathsContainer" class="kv-list">
<input
type="text"
class="input store-path"
name="storePath"
placeholder="Path to the KV store within Vault"
value="secret/vaultPass"
/>
</div>
<button id="addStorePathButton" class="button button--secondary button--small" type="button">
+ Add KV Store
</button>
</label>

<label class="label">
Auth Method:
<input type="text" list="mounts" name="authMount" id="authMount" class="input" />
Expand All @@ -51,11 +67,6 @@ <h1 class="h1 title">VaultPass</h1>
</datalist>
</label>

<label class="label">
KV Store:
<input type="text" class="input" name="store" id="storeBox" placeholder="Path to the KV store within Vault"
value="secret/vaultPass" />
</label>

<input type="submit" class="button button--primary" value="Login to Vault" id="authButton" />
<input type="submit" class="button button--primary" value="Get Token from Vault" id="tokenGrabber" />
Expand All @@ -75,4 +86,4 @@ <h1 class="h1 title">VaultPass</h1>
<script src="options.js"></script>
</body>

</html>
</html>
Loading