token

JWT基础知识

为君一笑 提交于 2019-12-20 20:44:37
1> JWT定义 JSON Web Token (JWT) 是一种开放的行业标准( RFC 7519 ),用于安全传送认证信息. 是目前流行的跨域认证的解决方案。 2> JWT数据结构 由三部分组成: Header(头部) . Payload(负载) . Signature(签名) 2.1> Header部分: 由Token类型 ("JWT") 和 算法名称 ("HS256"等)组成 ,再用Base 64对JSON编码。 2.2>Payload部分: 由声明部分组成。声明有三种类型:Registered,Public,Private Registered Claims: 预定义的声明,建议不是强制。   例如:   iss ( Issuer ) 签发者 exp ( Expiration Time) 过期时间 sub ( Subject ) 所面向的用户 aud ( Audience ) 接收者 Public Claims: 可自定义任何信息,一般添加用户相关信息或业务需要信息 Private Claims: 提供者和消费者所共同定义的声明 注意:不要在JWT的payload或header中放置敏感信息 2.3> Signature 签名是用于验证消息在传递过程中有没有被更改,并且,对于使用私钥签名的token,它还可以验证JWT的发送方是否为它所称的发送方。

微信——获取用户基本信息及openid 、access_token、code

最后都变了- 提交于 2019-12-20 19:48:32
获取用户信息,需要获取 access_token 、 openid 然后调用接口 https://api.weixin.qq.com/cgi-bin/user/info?access_token=ACCESS_TOKEN&openid=OPENID&lang=zh_CN access_token :公众号的全局唯一票据, 获取 access_token ,需要调用 https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET 参数 是否必须 说明 grant_type 是 获取access_token填写client_credential appid 是 第三方用户唯一凭证 secret 是 第三方用户唯一凭证密钥,即appsecret openid:普通用户的标识,对当前公众号唯一 获取openid需要先获取 code , 获取code需要调用接口 https://open.weixin.qq.com/connect/oauth2/authorize?appid=appid&redirect_uri=现在访问的方法的url&response_type=code&scope=snsapi_userinfo&state=STATE 获取code后,

Node.js 应用:Koa2 使用 JWT 进行鉴权

删除回忆录丶 提交于 2019-12-20 18:08:48
前言 在前后端分离的开发中,通过 Restful API 进行数据交互时,如果没有对 API 进行保护,那么别人就可以很容易地获取并调用这些 API 进行操作。那么服务器端要如何进行鉴权呢? Json Web Token 简称为 JWT,它定义了一种用于简洁、自包含的用于通信双方之间以 JSON 对象的形式安全传递信息的方法。JWT 可以使用 HMAC 算法或者是 RSA 的公钥密钥对进行签名。 说得好像跟真的一样,那么到底要怎么进行认证呢? 首先用户登录时,输入用户名和密码后请求服务器登录接口,服务器验证用户名密码正确后,生成token并返回给前端,前端存储token,并在后面的请求中把token带在请求头中传给服务器,服务器验证token有效,返回正确数据。 既然服务器端使用 Koa2 框架进行开发,除了要使用到 jsonwebtoken 库之外,还要使用一个 koa-jwt 中间件,该中间件针对 Koa 对 jsonwebtoken 进行了封装,使用起来更加方便。下面就来看看是如何使用的。 生成token 这里注册了个 /login 的路由,用于用户登录时获取token。 const router = require('koa-router')(); const jwt = require('jsonwebtoken'); const userModel = require(

【百度大脑新品体验】车牌识别

怎甘沉沦 提交于 2019-12-20 16:49:45
车牌识别现在已经有了许多应用,例如停车场闸机识别,高速公路收费站车牌识别等。在本文中,将介绍如何使用百度AI的接口来实现车牌识别。 车牌识别接口介绍 本段将简单介绍一下车牌识别接口,具体的内容可以参见 文档( https://ai.baidu.com/docs#/OCR-API/5116ac95 )。 接口描述 对机动车蓝牌、绿牌、单/双行黄牌的地域编号和车牌号进行识别,并能同时识别图像中的多张车牌。 请求说明 请求url:https://aip.baidubce.com/rest/2.0/ocr/v1/license_plate 请求参数:image, multi_detect 返回说明 返回参数:log_id, Color,number,probability, vertexes_location 返回实例 {‘log_id’: 6317054685683389581, ‘words_result’: [{‘color’: ‘blue’, ‘number’: ‘晋A2B222’, ‘probability’: [0.9048133492469788, 0.9014081954956055, 0.9013367891311646, 0.901279628276825, 0.9011501669883728, 0.9012312889099121, 0

【tp5】表单验证之token

点点圈 提交于 2019-12-20 16:39:49
1、本场景仅介绍复杂一点的ajax请求带上token验证,普通的form提交不讲 2、原理仅个人理解,如有偏差 欢迎各路大神指点:框架tp5.0.18 目前将token放置于 ajax的header头部,发现在后台验证时候,一直报错【验证令牌不存在】。 故将token放置于 ajax的data参数中。 后台每进行一次ajax提交,均需要进行token重新生成、替换,不管成功与否。(强烈建议阅读token生成源码:request.php的token()方法) 3、jquery代码:【每次ajax接受到的新token,先赋值给隐藏域变量__token__,然后再从该变量取值】 <script type="text/javascript"> $(document).on("click",".more",function(){ var jm_product_code = $(this).attr("data-id"); var token = $("input[name='__token__']").val(); $.ajax({ url:"{:url('admin/DingReport/ajax')}", dataType:'JSON', type:'POST', data:{'jm_product_code':jm_product_code,'__token__':token},

How to keep client JSON web token secure in a React Native app?

依然范特西╮ 提交于 2019-12-20 12:27:27
问题 We are building a React Native app for iOS and we are using an internal API built on node + express + jsonwebtoken. When the user logs in with username/password, the server validates those credentials and sends the client back a JSON web token that they must then send along with every API request. So the React native app must store this token. How do I securely store this client token in the React native app? Is it necessary to take any additional steps besides just storing the token in a

How to keep client JSON web token secure in a React Native app?

烂漫一生 提交于 2019-12-20 12:27:10
问题 We are building a React Native app for iOS and we are using an internal API built on node + express + jsonwebtoken. When the user logs in with username/password, the server validates those credentials and sends the client back a JSON web token that they must then send along with every API request. So the React native app must store this token. How do I securely store this client token in the React native app? Is it necessary to take any additional steps besides just storing the token in a

微信模板消息推送

非 Y 不嫁゛ 提交于 2019-12-20 11:40:37
微信公众号消息推送 前提 环境: python 3 框架: django 1.11.9 需要有自己的服务器来响应微信发送的Token验证~~ 当然, 下面的代码用上了博主的服务器, 直接复制博主的也能用, 如果没有响应, 说明博主没启服务 测试环境 这里先介绍测试号的开发; 测试接口链接: https://mp.weixin.qq.com/debug/cgi-bin/sandbox?t=sandbox/login 点击链接进入页面,会看到一个二维码,用微信扫描后就会分配给你一个微信公众测试账号; 如下 当然也可以多人测试; 然后找到如下这个位置,点击“新增测试模板”按钮,填写 注意要修改的地方 : 下面是相关代码:  urlpatterns = [ url(r'^bind/$', views.bind), url(r'^bind_qcode/$', views.bind_qcode), url(r'^callback/$', views.callback), url(r'^sendmsg/$', views.sendmsg), ] urls.py # ############# 微信 ############## WECHAT_CONFIG = { 'app_id': '自己的测试号appID', 'appsecret': '自己的测试号appsecret', 'redirect

Angular 2/4 where to store token

三世轮回 提交于 2019-12-20 11:38:11
问题 I have a rest api for generating token, which i'm using in angular 4 client side, but the question is where to store this token. In the internet i found that i can store in local storage or in the cookie. So my question is, if store token is the local storage for example, and i have just copied the valid token from another browser, then i will have a valid token, so there is any security of storing token like that, and basically the same with cookies, or maybe i missed some important

Facebook PHP SDK 4.0 : Getting Long Term Access Token

无人久伴 提交于 2019-12-20 10:52:00
问题 I'm trying to use the PHP sdk v4.0 to get a long term access token for PAGE management. I'm grabbing the access token from the user's login (Yes, I'm grabbing the Page-specific access token). Then sending it to the endpoint as specified in documentation, but I'm not getting any results and I'm not getting any errors. Could I know what is the correct code snippet to use? This is the code I'm using so far $endpoint = '/oauth/access_token?'; $endpoint .= 'grant_type=fb_exchange_token&';