Skip to content
This repository has been archived by the owner on Apr 12, 2020. It is now read-only.

Entrega Proyecto 1 #39

Open
wants to merge 89 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
e12cf27
Routes/Controller/View
RamiroFraysse Apr 27, 2019
96e4bd7
ROUTES/CONTROLLERS/VIEW/MIGRATIONS
RamiroFraysse Apr 27, 2019
0bc22ee
ROUTES/CONTROLLERS/VIEW/MIGRATIONS
RamiroFraysse Apr 28, 2019
2f2d110
ROUTES/CONTROLLERS/VIEW/MIGRATIONS/SEEDERS
RamiroFraysse Apr 28, 2019
87da06b
Merge branch 'master' of https://github.com/RamiroFraysse/proyecto-1
RamiroFraysse Apr 28, 2019
de0ff6c
ROUTES/CONTROLLERS/VIEW/MIGRATE/SEEDERS/MODELS
RamiroFraysse Apr 28, 2019
1dcf3b7
ROUTES/CONTROLLERS/VIEW/MIGRATE/SEEDERS/MODELS/ELOQUENTRELACIONES/FAC…
RamiroFraysse Apr 28, 2019
f276463
ROUTES/CONTROLLERS/VIEW/MIGRATE/SEEDERS/MODELS/ERELACIONES/FACTORIES/…
RamiroFraysse Apr 29, 2019
0a7e034
..AGREGAR/EDITAR/BORRAR
RamiroFraysse Apr 30, 2019
3e97982
login
RamiroFraysse Apr 30, 2019
7725ccc
martes 30/4
RamiroFraysse May 1, 2019
e23d4d5
miercoles 1/05
RamiroFraysse May 2, 2019
faa23b7
jueves 00:19
RamiroFraysse May 2, 2019
1d421ee
Jueves 1:35
RamiroFraysse May 2, 2019
0d7744c
Jueves 4:34
RamiroFraysse May 2, 2019
70fb2e0
jueves 2/05
RamiroFraysse May 2, 2019
5edc7fd
Domingo 5/5 13:53
RamiroFraysse May 5, 2019
65d07b6
delete funcionando
RamiroFraysse May 6, 2019
4fd7d8e
domingo 5/5
RamiroFraysse May 6, 2019
59d2cad
Lunes 6/5
RamiroFraysse May 7, 2019
5bff558
Funcionalidad
RamiroFraysse May 7, 2019
482c7f4
Martes 7/5 15:40
RamiroFraysse May 7, 2019
dc4d3ae
Martes 7/5 22:00 Andando
RamiroFraysse May 8, 2019
7d17452
final
RamiroFraysse May 8, 2019
9b9a4e5
Visitar Perfil de usuario
RamiroFraysse May 9, 2019
0848362
entrega
RamiroFraysse May 9, 2019
05dae3b
Procfile for Heroku
RamiroFraysse May 9, 2019
11b953c
..
RamiroFraysse May 9, 2019
2c81686
jueves 9/5
RamiroFraysse May 9, 2019
67e845d
procfile
RamiroFraysse May 9, 2019
709c8da
:bookmark procfile added
RamiroFraysse May 9, 2019
1e41a6f
Second Commit
RamiroFraysse May 9, 2019
f8bc497
Entrega final
RamiroFraysse May 9, 2019
36a7757
update
RamiroFraysse May 9, 2019
8a109e2
update
RamiroFraysse May 9, 2019
21aa35c
update
RamiroFraysse May 9, 2019
7172f96
update
RamiroFraysse May 9, 2019
347458f
update
RamiroFraysse May 9, 2019
24d9367
update
RamiroFraysse May 9, 2019
61dd478
solucion: se ve el logo
RamiroFraysse May 9, 2019
fc82fd9
solucion: se ve el logo update
RamiroFraysse May 9, 2019
02ecbd3
update
RamiroFraysse May 9, 2019
d7d5d4f
update
RamiroFraysse May 9, 2019
59e1a19
update
RamiroFraysse May 9, 2019
c323c6e
update
RamiroFraysse May 9, 2019
99ea93a
update
RamiroFraysse May 9, 2019
5e9b445
update
RamiroFraysse May 9, 2019
54b7bbb
update
RamiroFraysse May 9, 2019
b26b9e4
update
RamiroFraysse May 9, 2019
96418d7
update
RamiroFraysse May 9, 2019
c8259a7
update
RamiroFraysse May 9, 2019
ca8ca5c
update
RamiroFraysse May 9, 2019
74e4bf5
update
RamiroFraysse May 9, 2019
d7702e3
update
RamiroFraysse May 9, 2019
600bf33
update
RamiroFraysse May 9, 2019
65818f9
update
RamiroFraysse May 9, 2019
44a13dd
update
RamiroFraysse May 9, 2019
2f9c28f
update
RamiroFraysse May 9, 2019
6cf35fd
update
RamiroFraysse May 9, 2019
555f71a
update
RamiroFraysse May 9, 2019
c676e11
update
RamiroFraysse May 9, 2019
a2ae93a
"update acceso no autorizado"
RamiroFraysse May 9, 2019
6caad09
update
RamiroFraysse May 9, 2019
c856f63
update
RamiroFraysse May 9, 2019
8b60214
"update"
RamiroFraysse May 9, 2019
5b7b3e6
"update acceso no autorizado listas"
RamiroFraysse May 9, 2019
3164fec
update Acceso no autorizado edicion usuarios
RamiroFraysse May 9, 2019
0425a14
two factor authentication
RamiroFraysse Jul 29, 2020
5e4949e
two factor add
RamiroFraysse Jul 29, 2020
f3a5d7d
two factor update
RamiroFraysse Jul 29, 2020
d5aeae3
two factor update
RamiroFraysse Jul 29, 2020
f7ea2de
two factor update
RamiroFraysse Jul 29, 2020
8b7ef1c
update
RamiroFraysse Jul 29, 2020
dd3e474
update
RamiroFraysse Jul 29, 2020
4a3bcc0
update
RamiroFraysse Jul 29, 2020
53c24dd
.
RamiroFraysse Jul 29, 2020
6916242
update
RamiroFraysse Jul 29, 2020
ea1a9ab
authentication two factor
RamiroFraysse Jul 29, 2020
d45310d
update
RamiroFraysse Jul 29, 2020
e637dd2
update seguridad
RamiroFraysse Jul 29, 2020
8390ee8
cambios
RamiroFraysse Jul 30, 2020
e5407a5
asdasd
RamiroFraysse Jul 30, 2020
c94fb01
dsadas
RamiroFraysse Jul 30, 2020
cec8d12
asdasd
RamiroFraysse Jul 30, 2020
af8c003
sad
RamiroFraysse Jul 30, 2020
3ac8caf
update
RamiroFraysse Jul 30, 2020
5c144bc
update
RamiroFraysse Jul 30, 2020
4416440
Autenticación de segundo factor para proyecto de seguridad
RamiroFraysse Jul 30, 2020
1074d48
heroku update
RamiroFraysse Jul 31, 2020
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
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: vendor/bin/heroku-php-apache2 public
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ TODO

## Herramienta Audit de Chrome

TODO
Para el Home tengo una accesibilidad de 87 y performance 78 tanto para los usuarios registrados como no registrados
Para el login tengo una accesibilidad de 73 y performance 98
En la pagina de mis listas para usuarios autenticados tengo una accesibilidad de 87 y performance de 82

## LINK A LA PÁGINA EN HEROKU
https://futboleroos.herokuapp.com/
177 changes: 177 additions & 0 deletions app/Authenticator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
<?php
namespace App;


class Authenticator
{
protected $length = 6;

public function generateRandomSecret()
{
$secretLength = 16;
$secret = '';
$validChars = array(
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
'Y', 'Z', '2', '3', '4', '5', '6', '7',
'=',
);

// valida que el tamaño de la clave sea entre 80 a 640 bits
if ($secretLength < 16 || $secretLength > 128) {
throw new Exception('Bad secret length');
}
$random = false;
if (function_exists('random_bytes')) {
//genera una cadena de longitud $secretLength.
$random = random_bytes($secretLength);
}
if ($random !== false) {
for ($i = 0; $i < $secretLength; ++$i) {
//ord convierte el primer byte del string a un valor entre 0 y 255.
$secret .= $validChars[ord($random[$i]) & 31];
}
} else {
throw new Exception('Cannot create secure random secret due to source unavailbility');
}
//FIMQ2OOBU5EVRQ5D
return $secret;
}


public function getCode($secret, $timeSlice = null)
{
if ($timeSlice === null) {
$timeSlice = floor(time() / 30);
}

$secretkey = $this->debase32($secret);

$time = chr(0).chr(0).chr(0).chr(0).pack('N*', $timeSlice);
$hm = hash_hmac('SHA1', $time, $secretkey, true);
$offset = ord(substr($hm, -1)) & 0x0F;
$hashpart = substr($hm, $offset, 4);

$value = unpack('N', $hashpart);
$value = $value[1];
$value = $value & 0x7FFFFFFF;

$modulo = pow(10, $this->length);

return str_pad($value % $modulo, $this->length, '0', STR_PAD_LEFT);
}


public function getQR($name, $secret, $title = null, $params = array())
{
$width = !empty($params['width']) && (int) $params['width'] > 0 ? (int) $params['width'] : 200;
$height = !empty($params['height']) && (int) $params['height'] > 0 ? (int) $params['height'] : 200;
$level = !empty($params['level']) && array_search($params['level'], array('L', 'M', 'Q', 'H')) !== false ? $params['level'] : 'M';

$urlencoded = urlencode('otpauth://totp/'.$name.'?secret='.$secret.'');
if (isset($title)) {
$urlencoded .= urlencode('&issuer='.urlencode($title));
}

//api de google para generar QR
return 'https://chart.googleapis.com/chart?chs='.$width.'x'.$height.'&chld='.$level.'|0&cht=qr&chl='.$urlencoded.'';
}

//parametros que espera $llavesemillasecreta y codigoTOTPrequest
public function verifyCode($secret, $code, $discrepancy = 1, $currentTimeSlice = null)
{
if ($currentTimeSlice === null) {
$currentTimeSlice = floor(time() / 30);
}

if (strlen($code) != 6) {
return false;
}

for ($i = -$discrepancy; $i <= $discrepancy; ++$i) {
$calculatedCode = $this->getCode($secret, $currentTimeSlice + $i);
if ($this->timingSafeEquals($calculatedCode, $code)) {
return true;
}
}

return false;
}


public function setCodeLength($length)
{
$this->length = $length;

return $this;
}


protected function debase32($secret)
{
if (empty($secret)) {
return '';
}

$base32chars = array(
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
'Y', 'Z', '2', '3', '4', '5', '6', '7',
'=',
);
$base32charsFlipped = array_flip($base32chars);

$paddingCharCount = substr_count($secret, $base32chars[32]);
$allowedValues = array(6, 4, 3, 1, 0);
if (!in_array($paddingCharCount, $allowedValues)) {
return false;
}
for ($i = 0; $i < 4; ++$i) {
if ($paddingCharCount == $allowedValues[$i] &&
substr($secret, -($allowedValues[$i])) != str_repeat($base32chars[32], $allowedValues[$i])) {
return false;
}
}
$secret = str_replace('=', '', $secret);
$secret = str_split($secret);
$binaryString = '';
for ($i = 0; $i < count($secret); $i = $i + 8) {
$x = '';
if (!in_array($secret[$i], $base32chars)) {
return false;
}
for ($j = 0; $j < 8; ++$j) {
$x .= str_pad(base_convert(@$base32charsFlipped[@$secret[$i + $j]], 10, 2), 5, '0', STR_PAD_LEFT);
}
$eightBits = str_split($x, 8);
for ($z = 0; $z < count($eightBits); ++$z) {
$binaryString .= (($y = chr(base_convert($eightBits[$z], 2, 10))) || ord($y) == 48) ? $y : '';
}
}

return $binaryString;
}


private function timingSafeEquals($safeString, $userString)
{
if (function_exists('hash_equals')) {
return hash_equals($safeString, $userString);
}
$safeLen = strlen($safeString);
$userLen = strlen($userString);

if ($userLen != $safeLen) {
return false;
}

$result = 0;

for ($i = 0; $i < $userLen; ++$i) {
$result |= (ord($safeString[$i]) ^ ord($userString[$i]));
}
return $result === 0;
}
}
29 changes: 28 additions & 1 deletion app/Http/Controllers/Auth/LoginController.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?php

namespace App\Http\Controllers\Auth;

use Illuminate\Http\Request;
use App\User;
use Illuminate\Support\Facades\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;

Expand All @@ -25,15 +27,40 @@ class LoginController extends Controller
*
* @var string
*/

protected $redirectTo = '/home';


/**
* Create a new controller instance.
*
* @return void
*/

public function __construct()
{
$this->middleware('guest')->except('logout');
}

public function twofactor(User $user){
return view('sfactor',[
'users' => $user->get()
]);
}

protected function authenticated(Request $request, User $user)
{
if($user->activar2F == true){
return view('sfactor',[
'user' => $user
]);
}else
return redirect('home');
}

public function logout()
{
Auth::logout();
return view('Auth.login');
}
}
1 change: 1 addition & 0 deletions app/Http/Controllers/Auth/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public function __construct()
$this->middleware('guest');
}


/**
* Get a validator for an incoming registration request.
*
Expand Down
50 changes: 50 additions & 0 deletions app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php


namespace App\Http\Controllers;
use Illuminate\Validation\Rule;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\User;
use App\Lista;
use App\Item;
class HomeController extends Controller
{
// /**Index se va a referir a nuestro modulo de usuario, cuya logica va a estar encapsulada en UserController */
// public function index(){

// //usoEloquentModel para obtener la tabla de usuarios
// $lists = Lista::orderBy('created_at','desc')->get();

// foreach($lists as $list){
// $users = [
// 'user' => User::where('id','=',$list->user_id),
// ];

// }


// //A la vista le paso un arreglo asociativo, donde cada fila va a ser (llave,valor)
// return view('welcome', [
// 'lists' => $lists,
// 'users' => $users,
// ]);
// }

/**Index se va a referir a nuestro modulo de usuario, cuya logica va a estar encapsulada en UserController */
public function index(){

//usoEloquentModel para obtener la tabla de listas
$lists = Lista::orderBy('created_at','desc')->get();

$items = Item::all();

//A la vista le paso un arreglo asociativo, donde cada fila va a ser (llave,valor)
return view('home', [
'lists' => $lists,
'items' => $items,
]);

}

}
Loading