Using php/mysql to store-retrieve fcm tokens and send notifications.
This code was part of a school assignment for the BACHELOR study System & Network Engineering at the University of Applied Sciences Amsterdam (HVA-SNE-Implementation). The assignment was to create a two-factor authentication system for a VPN. Officially we had to use a NPS (Windows) and write our own DLL for it, we never got the DLL to work so we made a work around.
You will need a database with 1 table:
CREATE TABLE IF NOT EXISTS phone ( id int(9) PRIMARY KEY AUTO_INCREMENT, username varchar(254) NOT NULL, fcmtoken TEXT, code int(6));
This is the 'front-end' code, it does not generate any HTML to display. It takes a json request and handles depending on the
Generates a 6 digit code for two factor authentication use. Depending on the size of the organisation you implement this is there is a change people get the same code so you will need the username+code in order to make out if it is a valid code.
It also saves the newly generated code.
A very simple test script in which you set a static username.
The project made use of Google Firebase to send notifications to the android app. It builds the json you send to firebase, the $token parameter is the device unique firebase token an android app creates, the $code is the 6 digit authentication code.
used for the first step of an authentication. You will need to set the server information parameters: line 7,8,9