Pages

Thursday, May 18, 2017

Flask with two way SSL



Flask with two way SSL


For two way SSL :




For Flask in Apache using WSGI


1. Edit WSGI virtual host


Add :
RequestHeader set SSL_CLIENT_S_DN "%{SSL_CLIENT_S_DN}s"


WSGISocketPrefix /var/run/wsgi

<VirtualHost _default_:443>
ServerName st.company.com
WSGIDaemonProcess yourapplication user=apache group=apache threads=5
WSGIScriptAlias /cotton /var/www/flask/cotton/myapp.wgi
RequestHeader set SSL_CLIENT_S_DN "%{SSL_CLIENT_S_DN}s"
 <Directory /var/www/flask/cotton/>
WSGIProcessGroup yourapplication
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
      
this will provide in SSL DN details in request.environ



'HTTP_SSL_CLIENT_S_DN': '/C=IN/L=Bangalore/O=EcmTest Vms/CN=Sterin'




request.headers.get('SSL_CLIENT_S_DN_CN') wont work properly



2. Add login in flask py file





@app.route('/ServerStatus')

def ServerStatus():
     user=""
    s_dn= (request.environ.get('HTTP_SSL_CLIENT_S_DN'))
    if s_dn:
          user = dict([x.split('=') for x in s_dn.split('/')[1:]])['CN']
    if user is not None and user != '':
      return render_template('login.html',user=user)
    else:
      return redirect('/')

Monday, May 15, 2017

Installing gnome extension addon on linux




Installing gnome extension addon on linux

gnome extension is required to new install all 
GNOME 3 extension to control UI of GNOME 

1. Install git



    yum install git


2. Install cmake



    yum install cmake 


3. Install python ,python-requests



    yum install python python-requests




4. Install jq



    yum install jq




5. Clone git jq



    git clone git://git.gnome.org/chrome-gnome-shell






5. build



    cd chrome-gnome-shell/
    mkdir build
    cd build
    cmake -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_EXTENSION=OFF ../
    make install


Final screen :





















This will fix below errors :




1. "Native host has exited."

2. No extension