Skip to content

Commit

Permalink
Release 2.1.0
Browse files Browse the repository at this point in the history
* Works with new CAS system #1
* Add auto push feature
* Add link to github in the extension window
* Update README
  • Loading branch information
mingjun97 committed Oct 2, 2020
1 parent 31ffaf7 commit 5fd3f60
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 40 deletions.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,16 @@ [email protected]

## TODO

- [x] Sync Passcodes with your google account.
- [x] Sync Passcodes with your google account.

## Changelog

- 2.1.0
- Adapt to new CAS system
- Auto push notifications to your DUO account(More secure way but require you to acknowledge it on your phone)

- 2.0.0
- Support sync with google account

- 1.0.0
- First functional version
3 changes: 3 additions & 0 deletions js/daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ chrome.storage.local.get({lastSeen: "1.0.0"}, function(data) {
case "2.0.0":
message = "Sync with google account available!"
break;
case "2.1.0":
message = "Now works on new CAS system!"
break;
}
chrome.notifications.create({
"message" : message,
Expand Down
37 changes: 37 additions & 0 deletions js/duo_inject.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// console.log('injected! duo');


window.addEventListener("message", function(e){
var keys = e.data.keys;
if (keys){
try {
window.requestAnimationFrame(function enter_passcode(){
if (document.getElementsByName('passcode')[0]){
document.getElementsByName('passcode')[0].value = keys;
document.getElementById('passcode').click();
} else {
window.requestAnimationFrame(enter_passcode);
}
});
} catch (err) {
err;
}
}
if (e.data.push) {
window.requestAnimationFrame(function enter_passcode(){
if (document.getElementsByName('passcode')[0]){
var btns = document.getElementsByTagName('button');
var i = 0;
for (i = 0; i < btns.length; i++) {
if (btns[i].innerText === "Send Me a Push") {
btns[i].click();
}
}
} else {
window.requestAnimationFrame(enter_passcode);
}
});
}
}, false);

window.postMessage({"retrieve": "code"}, "*");
14 changes: 9 additions & 5 deletions js/handler.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
function injectCustomJs(jsPath)
{
jsPath = jsPath || 'js/inject.js';
var temp = document.createElement('script');
temp.setAttribute('type', 'text/javascript');
temp.src = chrome.extension.getURL(jsPath);
document.head.appendChild(temp);
}

injectCustomJs();
injectCustomJs('js/duo_inject.js');

window.addEventListener("message", function(e){
var cb = function(items){
if (items.autopush) {
window.postMessage({'push': true});
return;
}
if(items.keys.length < 3 && !items.initial){
chrome.runtime.sendMessage('GetCodes');
}
Expand All @@ -23,10 +27,10 @@ window.addEventListener("message", function(e){
if (e.data.retrieve === 'code'){
chrome.storage.local.get({synced: false}, function(data){
if (data.synced){
chrome.storage.sync.get({keys: [], initial: false, isCurrentSynced: true}, cb);
chrome.storage.sync.get({keys: [], initial: false, isCurrentSynced: true, autopush: false}, cb);
}else{
chrome.storage.local.get({keys: [], initial: false, isCurrentSynced: false}, cb);
chrome.storage.local.get({keys: [], initial: false, isCurrentSynced: false, autopush: false}, cb);
}
})
}
})
})
23 changes: 0 additions & 23 deletions js/inject.js

This file was deleted.

2 changes: 1 addition & 1 deletion js/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ setTimeout( function(){
}
}
})
}, 100);
}, 1000);
2 changes: 1 addition & 1 deletion js/login_inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ window.addEventListener(
if(e.data.username){
document.getElementById('username').value = e.data.username;
document.getElementById('password').value = e.data.password;
document.getElementById('fm1').submit();
document.getElementsByName('submit')[0].click();
}
}
catch(err){
Expand Down
26 changes: 23 additions & 3 deletions js/popup/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ function initialize(){
var elems = document.querySelectorAll('.tooltipped');
M.Tooltip.init(elems);
document.getElementById('autologin').addEventListener('click', update_autologin);
document.getElementById('autopush').addEventListener('click', update_autopush);
document.getElementById('githublink').onclick = PopOutGithub;

}

function update_autologin(){
Expand All @@ -100,6 +103,16 @@ function update_autologin(){
})
}

function update_autopush(){
chrome.storage.local.get({synced: false}, function(data){
if(data.synced){
chrome.storage.sync.set({autopush:document.getElementById('autopush').checked});
}else{
chrome.storage.local.set({autopush:document.getElementById('autopush').checked});
}
})
}

function update_me(){
var status = document.getElementById('status');
var update_handler = function(data){
Expand All @@ -108,6 +121,9 @@ function update_me(){
if (data.autologin){
document.getElementById('autologin').checked = true;
}
if (data.autopush){
document.getElementById('autopush').checked = true;
}
if (data.keys.length) {
status.checked = true;
status.disabled = false;
Expand All @@ -125,9 +141,9 @@ function update_me(){
chrome.storage.local.get({synced: false}, function(data){
document.getElementById("sync").checked = data.synced;
if (data.synced){ // synced with google account
chrome.storage.sync.get({keys: [], username: '', autologin: false}, update_handler);
chrome.storage.sync.get({keys: [], username: '', autologin: false, autopush: false}, update_handler);
}else{ // not synced with google account
chrome.storage.local.get({keys: [], username: '', autologin: false}, update_handler);
chrome.storage.local.get({keys: [], username: '', autologin: false, autopush: false}, update_handler);
}
})
}
Expand All @@ -136,4 +152,8 @@ chrome.runtime.onMessage.addListener(function(request, sender, sendResponse){
if (request === 'update_status'){
update_me();
}
});
});

function PopOutGithub(){
chrome.tabs.create({ url: "https://github.com/mingjun97/ucr_mfa_crx" }, null)
}
8 changes: 4 additions & 4 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "UCR MFA Helper",
"version": "2.0.0",
"version": "2.1.0",
"description": "A chrome extension for auto-filling UCR MFA",
"icons":
{
Expand All @@ -22,7 +22,7 @@
"content_scripts":
[
{
"matches": ["https://myaccount.ucr.edu/casDuo?*"],
"matches": ["https://api-24ed243a.duosecurity.com/frame/prompt*"],
"js": ["js/handler.js"],
"run_at": "document_idle",
"all_frames": true
Expand All @@ -44,12 +44,12 @@
[
"webRequest",
"storage",
"https://myaccount.ucr.edu/casDuo?*",
"https://auth.ucr.edu/cas/login?*",
"https://myaccount.ucr.edu/app*",
"https://api-24ed243a.duosecurity.com/frame/web/v1/auth?*",
"notifications"
],
"web_accessible_resources": ["js/inject.js", "js/login_inject.js"],
"web_accessible_resources": ["js/inject.js", "js/login_inject.js", "js/duo_inject.js"],
"homepage_url": "https://github.com/mingjun97/ucr_mfa_crx",
"devtools_page": "devtools.html"
}
18 changes: 16 additions & 2 deletions popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
</div>
</div>
</div>
<div style="margin-top: 10px;" class="switch tooltipped" data-position="top" data-tooltip="Help you fill the login form and click the LOGIN NOW Button automatically">
<div style="margin-top: 10px;" class="switch tooltipped" data-position="top" data-tooltip="Help you fill the login form and click the 'SIGN IN' Button automatically">
<div style="display: flex; justify-content: space-between">
<div style="font-size: 13px">Login Helper: &nbsp;&nbsp; </div>
<div>
Expand All @@ -50,6 +50,19 @@
</div>
</div>
</div>
<div style="margin-top: 10px;" class="switch tooltipped" data-position="top" data-tooltip="Click 'Send Me a Push' automatically instead of filling the passcode">
<div style="display: flex; justify-content: space-between">
<div style="font-size: 13px">Auto Push: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </div>
<div>
<label>
Off
<input type="checkbox" id="autopush">
<span class="lever"></span>
On
</label>
</div>
</div>
</div>
</div>

<br/>
Expand All @@ -66,7 +79,8 @@
<div class="indeterminate"></div>
</div>
<br/>
<h6 style="text-align: center; color: green;">Made with love by mingjun97</div>
<h6 style="text-align: center; color: green;">Made with love by mingjun97</h6>
<div style="display: flex;"><h8 style="margin: auto;"><a id="githublink" href='#'>View on GitHub</a></h8></div>

<!--Build cool stuff ;) by mingjun -->
<!-- Other system with DUO mobile MFA system may also be compatible with this tweak, feel free to modify it :) -->
Expand Down

0 comments on commit 5fd3f60

Please sign in to comment.