Blog

小醋说:我是吃不饱的^_^

Node.js 模块之【passport】第三方【Github】鉴权(二)

1. 安装模块 npm i connect-mongo –save-dev npm i passport –save-dev npm i passport-github –save 1 2 3 2. 引入模块及其他依赖模块 var session = require(‘express-session’); var MongoStore = require(‘connect-mongo’)(session); var passport = require(‘passport’); var GithubStrategy = require(‘passport-github’).Strategy; 1 2 3 4 3. 添加序列化与反序列化回调 passport.serializeUser(function(user, done) { done(null, user.id); }); passport.deserializeUser(function(id, done) { UserModel.findById(id, function(err, user) { done(err,…
Read more


January 21, 2019 0

Node.js 模块之【passport】进行本地【用户名+密码】鉴权(一)

1. 安装 passport npm i passport npm i passport-local 1 2 2. 添加模块(上面几个为依赖模块) var cookieParser = require(‘cookie-parser’); var bodyParser = require(‘body-parser’); var session = require(‘express-session’); var MongoStore = require(‘connect-mongo’)(session); var passport = require(‘passport’); var LocalStrategy = require(‘passport-local’).Strategy; 1 2 3 4 5 6 3. 实现一些基本回调 passport.serializeUser(function(user, done) { done(null, user.id); }); passport.deserializeUser(function(id, done) { UserModel.findById(id,…
Read more


January 21, 2019 0

HTML head 头标签

http://fex.baidu.com/blog/2014/10/html-head-tags/


November 20, 2018 0

SSI


November 19, 2018 0

vue+axios实现拦截器(登陆拦截、路由拦截、http拦截)

项目中通常使用token进行用户权限认证,需要在请求的header中添加token信息进行验证,拦截返回的状态码进行跳转或重新登陆,在全局配置这些不妥,所以新建一个axios实例进行项目的配置。


November 2, 2018 0

10 Things You Should Know about Tokens

some of the most common questions around token-based authentication.


October 28, 2018 0

基于Token的WEB后台认证机制

几种常用的认证机制 HTTP Basic Auth HTTP Basic Auth简单点说明就是每次请求API时都提供用户的username和password,简言之,Basic Auth是配合RESTful API 使用的最简单的认证方式,只需提供用户名密码即可,但由于有把用户名密码暴露给第三方客户端的风险,在生产环境下被使用的越来越少。因此,在开发对外开放的RESTful API时,尽量避免采用HTTP Basic Auth


October 28, 2018 0

RESTful API 设计指南

网络应用程序,分为前端和后端两个部分。当前的发展趋势,就是前端设备层出不穷(手机、平板、桌面电脑、其他专用设备……)。 因此,必须有一种统一的机制,方便不同的前端设备与后端进行通信。这导致API构架的流行,甚至出现“API First”的设计思想。RESTful API是目前比较成熟的一套互联网应用程序的API设计理论。我以前写过一篇《理解RESTful架构》,探讨如何理解这个概念。


May 8, 2018 0

Unix / Linux – Useful Commands

This quick guide lists commands, including a syntax and a brief description. For more detail, use − $man command Files and Directories These commands allow you to create directories and handle files. Given below is the list of commands in Files and Directories. S.No. Command & Description 1 cat Displays File Contents 2 cd Changes…
Read more


May 8, 2018 0

fetch API

One of the worst kept secrets about AJAX on the web is that the underlying API for it, XMLHttpRequest, wasn’t really made for what we’ve been using it for.  We’ve done well to create elegant APIs around XHR but we know we can do better.  Our effort to do better is the fetch API.  Let’s have a basic look at…
Read more


May 7, 2018 0