Categories
Apache Hacker

Stopping “connect” attacks in apache (solution)

Then add the following right after it and restart apache to activate.

# Second, we configure the "default" Location to restrict the methods
allowed
# to stop CONNECT method attacks.
#
Order allow,deny Deny from all

I don’t like the idea of my server responding to requests for random hostnames, even if it serves local content. How can I deny these requests?

<VirtualHost *:80>
  ServerName default.only
  <Location />
    Order allow,deny
    Deny from all
  </Location>
</VirtualHost>


Categories
Technical

untar linux compressed file

tar -zxvf yourfile.tar.gz
Categories
Queues REDIS

Redis Practical commands

Redis Command Line

redis-cli -h 127.0.0.1 -p 6379

List keys

keys *

Show Value Key

mget "nameOfYourKey"
Categories
REDIS

Show all Redis keys

$ redis-cli KEYS '*'


Categories
Queues REDIS

Flush keys in Redis

redis-cli FLUSHALL
Categories
Laravel

Laravel Socialite

Laravel Socialite makes the experience painless and fast to implement. I highly recommend this package for quick development ! Here

laravel socialite raleche
laravel socialite raleche
Categories
Git

Tutorial – Submit large files in GIT

INSTALL LFS ON RHEL/CentOS

  1. Install git >= 1.8.2
    • Recommended method for RHEL/CentOS 5 and 7 (not 6!)
      1. Install the epel repo link (For CentOS it’s just sudo yum install epel-release)
      2. sudo yum install git
    • Recommended method for RHEL/CentOS 6
      1. Install the IUS Community repo. curl -s https://setup.ius.io/ | sudo bash or here
      2. sudo yum install git2u
    • You can also build git from source and install it. If you do that, you will need to either manually download the git-lfs rpm and install it with rpm -i --nodeps git-lfs*.rpm, or just use the Other instructions. The only other advanced way to fool yum is to create and install a fake/real git rpm to satisfy the git >= 1.8.2 requirement.
  2. To install the git-lfs repo, run curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.rpm.sh | sudo bash from here
  3. sudo yum install git-lfs
  4. git lfs install

Install software on your Macbook MAC

brew install git-lfs

List type files to be tracked

git lfs track "*.psd"

git add .gitattributes

Example

git add file.psd 

git commit -m "Add design file" 

git push origin master
Categories
Laravel

Tutorial – How to do a search form with laravel pagination bootstrap ?

Define routes at routes/web.php

//All certificates
Route::post('/search-certificates', '[email protected]' );
Route::get('/search-certificates', '[email protected]' );
or
Route::any('/search-certificates', '[email protected]' );

Define Controller function Search

public function search(Request $request){
    $searchString = $request->input('searchString');
    $searchCertificates = DB::table('NAMEOFYOURBABLE')
        ->where('BOROUGH', 'like', "%$searchString%" )
        ->orwhere('STREET', 'like', "%$searchString%" )
        ->orwhere('POSTCODE', 'like', "%$searchString%" )
        ->orderBy('POSTCODE', 'asc')
        ->orderBy('NUMBER', 'asc')
        ->orderBy('JOB_NUMBER', 'asc')
        ->paginate(20);

    $searchCertificates->appends(['searchString' => $searchString]);

    return view('search-certificates', ['searchCertificates' => $searchCertificates]);
}

Most important line on the code above is the one below because it will allow search pagination

    $searchCertificates->appends(['searchString' => $searchString]);

Define View Laravel Blade Page

Form

<form action="/search-certificates" method="POST" role="search">
    {{ csrf_field() }}
    <div class="input-group">
        <input type="text" class="form-control" name="searchString"
               placeholder="Search by Street or Postal Code " />
         <button type="submit" class="btn btn-primary">Submit</button>
    </div>
</form>

Grid/Table

<div class="row justify-content-center">
<table class="table table-striped">
<thead>
<tr>
<th>POSTCODE</th>
<th>ISSUE_TYPE</th>
<th>C_O_ISSUE_DATE</th>
<th>BOROUGH</th>
<th>NUMBER</th>
<th>STREET</th>
<th>Number of Units</th>
<th>NTA</th>
</tr>
</thead>
<tbody>
@foreach ($searchCertificates as $oneCertificate)
<tr>
<td>{{ $oneCertificate->POSTCODE }}</td>
<td>{{ $oneCertificate->ISSUE_TYPE }}</td>
<td>{{ $oneCertificate->C_O_ISSUE_DATE }}</td>
<td> {{ $oneCertificate->BOROUGH }}</td>
<td>{{ $oneCertificate->NUMBER }}</td>
<td>{{ $oneCertificate->STREET }}</td>
<td>{{ $oneCertificate->PR_DWELLING_UNIT }}</td>
<td>{{ $oneCertificate->NTA }}</td>
</tr>
@endforeach
</tbody>

Blade Pagination Link

{{ $searchCertificates->links( "pagination::bootstrap-4") }}
Categories
Laravel

Tutorial Install Oauth2 Server

Find below the steps to install an Oauth2 server with laravel Passport

Install the package

composer require laravel/passport
php artisan migrate
php artisan passport:install

Retrieve the keys from laravel passport

Personal access client created successfully.
 Client ID: 7
 Client secret: JfTAiRtvsdX2pZI1cBUShCrd2BU5pYYrX0lzHwRhBq
 Password grant client created successfully.
 Client ID: 8
 Client secret: Y3nUHg1xcaOPCsdsdsqbIjA3Ghj5CJnTf0pD1p3t2U5wN

Modify App\User.php file

<?php namespace App;
 use Laravel\Passport\HasApiTokens; 
use Illuminate\Notifications\Notifiable; 
use Illuminate\Foundation\Auth\User as Authenticatable; 

class User extends Authenticatable {    
 use HasApiTokens, Notifiable; 
}

Register the routes necessary to issue access tokens and revoke access tokens, clients, and personal access tokens:

<?php namespace App\Providers; 
use Laravel\Passport\Passport;
 use Illuminate\Support\Facades\Gate;
 use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; 

class AuthServiceProvider extends ServiceProvider {  
   /**      
    * The policy mappings for the application.      
    *     
    * @var array      
    */     
     protected $policies = [  
       'App\Model' => 'App\Policies\ModelPolicy',   
      ];    
 /**      
   * Register any authentication / authorization services.      
   *
   * @return void     
   */  
   public function boot()     
   {
      $this->registerPolicies();   
      Passport::routes();    
   } 
}

Configure config/auth.php

'guards' => [     
         'web' => [         
                   'driver' => 'session',
                   'provider' => 'users',
           ],
         'api' => [         
                   'driver' => 'passport',
                   'provider' => 'users',    
                ],
 ],

SET TO GO, now get access token to proceed

Use the generated key in initial step called Password grant client

Categories
Server Token Web Server

Rest Client

Insomnia

Postman