Skip to content

Instantly share code, notes, and snippets.

adisreyaj.sonarqube-status
alexcvzz.vscode-sqlite
amiralizadeh9480.laravel-extra-intellisense
andys8.jest-snippets
angular.ng-template
apility.beautify-blade
bmewburn.vscode-intelephense-client
bradgashler.htmltagwrap
bradlc.vscode-tailwindcss
christian-kohler.npm-intellisense
@yacinthos
yacinthos / jwt-expiration.md
Created February 22, 2019 15:16 — forked from soulmachine/jwt-expiration.md
How to deal with JWT expiration?

First of all, please note that token expiration and revoking are two different things.

  1. Expiration only happens for web apps, not for native mobile apps, because native apps never expire.
  2. Revoking only happens when (1) uses click the logout button on the website or native Apps;(2) users reset their passwords; (3) users revoke their tokens explicitly in the administration panel.

1. How to hadle JWT expiration

A JWT token that never expires is dangerous if the token is stolen then someone can always access the user's data.

Quoted from JWT RFC:

@yacinthos
yacinthos / backends.js
Created February 19, 2019 07:07 — forked from kevinswiber/backends.js
Express Gateway Example with Multiple Services
const express = require('express');
const forum = express();
forum
.get('/healthz', (req, res, next) => {
res.send({ name: 'forum', status: 'healthy' });
next();
})
.get('/d/:id', (req, res, next) => {
@yacinthos
yacinthos / deep-search-javascript-object.js
Created September 14, 2018 18:09 — forked from YagoLopez/deep-search-javascript-object.js
Deep search javascript object
/* Attribution: http://techslides.com/how-to-parse-and-search-json-in-javascript */
//return an array of objects according to key, value, or key and value matching
function getObjects(obj, key, val) {
var objects = [];
for (var i in obj) {
if (!obj.hasOwnProperty(i)) continue;
if (typeof obj[i] == 'object') {
objects = objects.concat(getObjects(obj[i], key, val));
} else
[
{
"id" : 1,
"iso" : "AF",
"iso3" : "AFG",
"fips" : "AF",
"country" : "Afghanistan",
"continent" : "AS",
"currency_code" : "AFN",
"currency_name" : "Afghani",
@yacinthos
yacinthos / mysql_iso_country.sql
Created September 5, 2018 10:41 — forked from mizterp/mysql_iso_country.sql
MySQL Country table (data source: iso.org)
CREATE TABLE IF NOT EXISTS `country` (
`iso2` char(2) NOT NULL,
`name` varchar(45) NOT NULL,
`iso3` char(3) NOT NULL,
`numeric` smallint(3) UNSIGNED NOT NULL,
PRIMARY KEY (`iso2`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `country` (`iso2`, `name`, `iso3`, `numeric`) VALUES
('AF', 'Afghanistan', 'AFG', 4),
@yacinthos
yacinthos / countries.sql
Created September 5, 2018 09:47 — forked from adhipg/countries.sql
Sql dump of all the Countries, Country Codes, Phone codes.
CREATE TABLE IF NOT EXISTS `country` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`iso` char(2) NOT NULL,
`name` varchar(80) NOT NULL,
`nicename` varchar(80) NOT NULL,
`iso3` char(3) DEFAULT NULL,
`numcode` smallint(6) DEFAULT NULL,
`phonecode` int(5) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;