Giter VIP home page Giter VIP logo

adam-sas-on / yubikey_exercise Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 1.0 171 KB

`U2F` authentication by hardware keys :closed_lock_with_key: also called "FIDO security keys". An exercise to learn about implementation and application of simpler and stronger authentication by USB/NFC keys.

License: MIT License

CSS 1.98% PHP 49.83% JavaScript 33.60% Makefile 0.23% C 14.20% Shell 0.16%
u2f authentication fido fido-u2f fido2 security yubikey solokeys

yubikey_exercise's Introduction

yubiKey exercise

An U2F authentication by hardware keys exercise

Hardware keys ๐Ÿ” also called FIDO security keys are yet another solution to verify the user who is trying to log-in.
An example of a key ๐Ÿ”‘ is this one manufactured by Yubico
YubiKey 5 NFC

Training U2F authentication by hardware keys is the main purpose of this repo
and because of this, SOLID, "magic numbers" etc. are not the most important concern.
Obsolete in normal circumstances (in production) logs like console.log's, print's etc. will be used also.

It will include more independent sub-projects or tasks related to yubiKey U2F development.

Dependency & Resources

Codes in this exercise are based on Yubico php-u2flib-server repo.
Some parts are copy-pased from their repo with slight modification (I do not own copyright on the original codes).

To learn more about U2F development, yubiKeys and things around FIDO, visit developers.yubico.com/U2F or FIDO Alliance website.

Requirements

Apache, mySQL, PHP are required.

To run U2F authentication locally (localhost) SSL keys are required (https://).
Solution to create keys (or one of solutions) which met requirements on Linux with Apache2 (2.4.x) is like this:

  1. Enable SSL a2enmod ssl
  2. Go to /etc/apache2/
  3. Create folder to keep keys, e.g. ssl_keys and go to this folder
  4. Create key for one year with RSA 2048 (it's localhost so security is not cause for concern)
    openssl genrsa -out localhost.key 2048
    openssl req -new -out localhost.csr -sha256 -key localhost.key
    openssl x509 -req -in localhost.csr -days 365 -signkey localhost.key -out localhost.crt -outform PEM
  5. localhost.crt has to be public (private key localhost.key should remain private ๐Ÿ˜‰)
    chmod 644 localhost.crt
  6. Go to /etc/apache2/sites-available, edit default-ssl.conf and change lines with SSLCertificateFile and SSLCertificateKeyFile into
    SSLCertificateFile    /etc/apache2/ssl_keys/localhost.crt
    SSLCertificateKeyFile  /etc/apache2/ssl_keys/localhost.key
    
  7. It might be required to add an alias into default-ssl.conf like:
    Alias /alias/ "/home/path-to-account-directory/public_html/"
    <Directory "/home/path-to-account-directory/public_html/">
        # your settings, e.g.:
        Options Indexes FollowSymlinks MultiViews
        AllowOverride all
        Order allow,deny
        allow from all
    </Directory>
    

Another requirement is a local_settings.php file with database settings like e.g.:

<?php
$db = array(
	'hostname' => 'localhost',
	'username' => 'admin',
	'password' => 'password1',
	'database' => 'db',
);

To prepare mySQL database, mysql_scheme.sql has to be imported. To do this on Linux:

  1. Create database, e.g. database_name
  2. Type in Linux console: mysql -u root database_name < mysql_scheme.sql
  3. Grant privileges for the user of database: GRANT ALL PRIVILEGES ON database_name.* TO 'username'@'hostname';

Quick start

To run php version just type https://localhost/<path-to-Apache-server>/yubiKey_exercise/ in a browser.

yubikey_exercise's People

Contributors

adam-sas-on avatar

Watchers

 avatar

Forkers

icyperior

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.