token

RxJava 操作符flatmap

删除回忆录丶 提交于 2019-12-07 19:10:52
有如下场景: 在前段调用后端的API时,经常会出现回调嵌套的情况。假设我们有两个API,queryA 和 queryB. 并且queryB的运行依赖于queryA的结果。那么我们的程序在一般的情况下可能是这个样子。 想象有如下的代码: 是不是感觉非常不舒服?假如嵌套的API再多几层,那么这将是个灾难。一个人开发的时候可能不觉得有什么问题,但是可以想象做code review或者新入项目组的同事看到你这复杂的嵌套时的表情。 是时候让flatmap出现啦!让我们把程序稍微改造一下,在Server类里面把makeRequest的方式变成RxJava的Observable的形式(我会在例子之后解释为什么要用flatmap()): 看上去好像没觉得有都简洁是么?你等着我给你看看假如嵌套多几层之后: 看到了么?在RxJava的链式调用下,所有之前需要嵌套的地方都被flatMap()隔开了。代码可读性大大增加!假如你的IDE支持java 8的话,你可以体验更美妙的事情:lambda! 在抛弃了可恶的匿名类之后,代码更加简洁了! 看来很多同学都不太理解为何要用flatmap来解决嵌套回调。那咱们就深入点。 flatMap()究竟是用来干嘛的?简单的说,flatmap把一个Observable变成多个Observable,然后把得到的多个Obervable的元素一个个的发射出去。 假设你有一个API

java加token实现单点登录

青春壹個敷衍的年華 提交于 2019-12-07 18:48:38
之前看过一些文章,直接说不清楚,因为我也是第一次研究单点登录,所有自己想写一篇希望能有所帮助 dome地址: 0.准备工作 1、tomcat8本地的安装 2、maven3本地的安装 3、使用maven发布项目到本地 1.简介 json web token(JWT)是一种新的用户认证方式,不同与以前的Session. JWT不需要服务器端存储用户信息,当用户登录后,服务器将用户信息放入加密放入token(token会被客户端保存),需要时再通过对token解密获取(客户请求时携带token) 2.代码 下面提供一种JWT的简单实现.这个例子实现的功能是: 1) 用户访问login.jsp进行登录操作. 则发放给用户本地浏览器的token为:eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiIxIiwiaWF0IjoxNTIyMjUzMTIwLCJzdWIiOiLmtYvor5XnlKjmiLcxIiwiZXhwIjoxNTIyMjUzNzIwfQ.5jWbc4yP11Qfz1T5HHAjFpgNWCtYyTwOmMB8rTZAY4s 2) 用户访问myServlet时,若用户已登录则跳转至info.jsp显示用户名,未登录则跳转至login.jsp. 地址后面一定要有参数,不然是post请求 在token有效期间,再次访问http://localhost:8080/jwt

axios新手实践实现登陆

荒凉一梦 提交于 2019-12-07 17:54:25
其实像这类的文章网上已经有很多很好的,写这篇文章,相当于是做个笔记,以防以后忘记 用到的:1、 vuex 2、axios 3、vue-route 登陆流程为:1、提交登陆表单,拿到后台返回的数据 2、将数据存入vuex 1、vuex配置 这里直接跳过安装之类的,百度一大堆,我直接上代码 // store index.js import Vue from 'vue' import Vuex from 'vuex' Vue.use(Vuex) // 初始化时用sessionStore.getItem('token'),这样子刷新页面就无需重新登录 const state = { user: window.sessionStorage.getItem('user'), token: window.sessionStorage.getItem('token') } const mutations = { //将token保存到sessionStorage里,token表示登陆状态 SET_TOKEN: (state, data) => { state.token = data window.sessionStorage.setItem('token', data) }, //获取用户名 GET_USER: (state, data) => { // 把用户名存起来 state.user =

springboot中的过滤器Filter和FilterRegistrationBean以及把request改造成HttpServletRequestWrapper

拈花ヽ惹草 提交于 2019-12-07 16:17:43
Filter:过滤器 FilterRegistrationBean:过滤器注册类 HttpServletRequestWrapper:在过滤器中把request转化为HttpServletRequestWrapper,方便做一些处理,比如把请求头加入到request ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @SpringBootConfiguration public FilterRegistrationBean<ParameterFilter> tokenFilter(){ FilterRegistrationBean<ParameterFilter> registration = new FilterRegistrationBean<ParameterFilter>();//新建过滤器注册类 ParameterFilter filter = new ParameterFilter();//添加我们的过滤器 registration.setFilter(filter);

How to generate Vimeo unauthenticated access token?

天大地大妈咪最大 提交于 2019-12-07 14:47:49
问题 I am new to Vimeo's api, i am looking for a way to make unauthenticated requests. I find out that i will need to generate unauthenticated access token, but i don't see any option to do that in the Vimeo's apps console. Can anybody help? 回答1: The app page does not yet support manual construction of unauthenticated access tokens (it's coming!). For now you have to request them programmatically. Luckily, they don't expire, so you only have to generate it once. Here's a quick walk-through on how

基于golang从头开始构建基于docker的微服务实战笔记

廉价感情. 提交于 2019-12-07 14:07:39
参考博文 part 1 利用gRPC protobuf定义服务 part 2 - Docker and go-micro Go-micro part 3 - docker-compose and datastores Part 4 - Authentication with JWT JWT User-service consignment-cli consignment-server Part 5 - Event brokering with Go Micro NATS配置 user-service nats连接失败 参考博文 https://ewanvalentine.io/microservices-in-golang-part-1/ 这个博文是作者微服务系统的第一篇,本学习笔记基于目前的5篇而成 part 1 利用gRPC ,protobuf定义服务 本人在学习过程中没有严格按照博文中放在github目录,而是在主目录中创建一个wdyshippy的目录,目录中文件结构如下 . ├── consignment- cli │ ├── cli .go │ ├── consignment- cli │ ├── consignment .json │ ├── Dockerfile │ └── Makefile └── consignment-service ├──

Best way to save authentication token?

风流意气都作罢 提交于 2019-12-07 12:45:03
问题 I've been working on implementing an api in c#. The implementation is going well, but I did come across a concern. When my library has authorized against the api I have a auth_token which I use for consequent queries to the webservice. The token needs to be kept between program runs as it stays the same for the user (although I do check if it is still valid when the application starts). For testing purposes I basically just save the token into a text file which is kept in the root directory

Why solr RemoveDuplicatesTokenFilterFactory dont work?

China☆狼群 提交于 2019-12-07 11:56:41
问题 My schema.xml is splitting product name and then uses RemoveDuplicate to remove duplicated words after split. <fieldType name="type_name" class="solr.TextField"> <analyzer type="index"> <tokenizer class="solr.PatternTokenizerFactory" pattern="\|| " /> <filter class="solr.LowerCaseFilterFactory"/> <filter class="solr.RemoveDuplicatesTokenFilterFactory"/> And in query analyzer I see that RemoveDuplicatesTokenFilterFactory did absolutely nothing to duplicated words. Why? 回答1: If you read Wiki

开发微信公众平台时需要注意的安全问题

梦想的初衷 提交于 2019-12-07 10:30:06
申请公众平台开发者模式需要填写一个URL和一个Token, 见下图: 如果这个URL和Token被别人猜中了, 并且你不判断消息中的ToUserName属性是否跟你微信号相配, 那么别人的公众帐号申请开发者时填写你的URL和你的Token, 别人的公众帐号就能把你公众帐号的功能盗用了. URL 你的微信号有时会要求用户绑定一些信息, 一般都是一个HTML5的网页, 这条微信内容其实就是一段HTML. 问题是复制这条消息到其它文本框中, HTML是暴露的, 你的<a href=”XXX”>XXX</a>会暴露出来, 所以别人可以轻而易举的拿到链接地址. 关键是不要让别人根据你的链接猜到你申请开发者时填写的URL, 在我看来, 以下格式的URL都相对不安全的: http://www.XX.com/ http://www.XX.com/ 微信号 http://www.XX.com/ 微信号/weixin.aspx http://www.XX.com/ 微信号/weixin.ashx http://www.XX.com/ 微信号/weixin.php http://www.XX.com/ 微信号/微信号.aspx http://www.XX.com/ 微信号/微信号.ashx http://www.XX.com/ 微信号/微信号.php 等等… Signature 在群里经常听别人说图省事

When its Necessary to Protect Forms with Token (CSRF attacks)?

∥☆過路亽.° 提交于 2019-12-07 10:15:38
问题 As much as I understand, web developer should create token and put it in hidden field of form to prevent CSRF attacks. Also, he should save the same token in a session and then, when form is submitted - check that tokens are equal. I came to question... is it necessary to do this technique for all forms? I mean, imagine form that is created to sign-in. I can't see any harm done to site and/or user if there is no CSRF protection, because user have no privileges (like he would have if he would