@ -1,20 +1,7 @@
|
||||
import { Map } from 'immutable';
|
||||
import trim from 'lodash/trim';
|
||||
import trimEnd from 'lodash/trimEnd';
|
||||
import uuid from 'uuid/v4';
|
||||
|
||||
function createNonce() {
|
||||
const nonce = uuid();
|
||||
window.sessionStorage.setItem('netlify-cms-auth', JSON.stringify({ nonce }));
|
||||
return nonce;
|
||||
}
|
||||
|
||||
function validateNonce(check) {
|
||||
const auth = window.sessionStorage.getItem('netlify-cms-auth');
|
||||
const valid = auth && JSON.parse(auth).nonce;
|
||||
window.localStorage.removeItem('netlify-cms-auth');
|
||||
return check === valid;
|
||||
}
|
||||
import { createNonce, validateNonce, isInsecureProtocol } from './utils';
|
||||
|
||||
export default class ImplicitAuthenticator {
|
||||
constructor(config = {}) {
|
||||
@ -26,13 +13,7 @@ export default class ImplicitAuthenticator {
|
||||
}
|
||||
|
||||
authenticate(options, cb) {
|
||||
if (
|
||||
document.location.protocol !== 'https:' &&
|
||||
// TODO: Is insecure localhost a bad idea as well? I don't think it is, since you are not actually
|
||||
// sending the token over the internet in this case, assuming the auth URL is secure.
|
||||
document.location.hostname !== 'localhost' &&
|
||||
document.location.hostname !== '127.0.0.1'
|
||||
) {
|
||||
if (isInsecureProtocol()) {
|
||||
return cb(new Error('Cannot authenticate over insecure protocol!'));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user