token

Is there a way to create a token for a normal user in Kubernetes?

余生长醉 提交于 2020-01-13 06:39:34
问题 Question There is a way to create a service account and get token as in How to Add Users to Kubernetes (kubectl)? but is there a way to get or create a token for a normal user? Background Followed Configure RBAC In Your Kubernetes Cluster and created a normal user. Bind a cluster role to the user as below (not sure this is correct, appreciate suggestions). I would like to create a token for the user and use it to access the dashboard but do not know how to do. kind: ClusterRole apiVersion:

token和cookie

我的梦境 提交于 2020-01-13 04:38:23
token和cookie一样都是首次登陆时,由服务器下发,都是当交互时进行验证的功能,作用都是为无状态的HTTP提供的持久机制。 token存在哪儿都行,localstorage或者cookie。 token和cookie举例,token就是说你告诉我你是谁就可以。 cookie 举例:服务员看你的身份证,给你一个编号,以后,进行任何操作,都出示编号后服务员去看查你是谁。 token 举例:直接给服务员看自己身份证。 对于token而言,服务器不需要去查看你是谁,不需要保存你的会话。当用户logout的时候cookie和服务器的session都会注销;但是当logout时候token只是注销浏览器信息,不查库。 token优势在于,token由于服务器端不存储会话,所以可扩展性强,token还可用于APP中。 归总一下 Token 完全由应用管理,所以它可以避开同源策略。 Token 可以避免 CSRF 攻击。 Token 可以是无状态的,可以在多个服务间共享。 来源: CSDN 作者: 小瑜的csdn 链接: https://blog.csdn.net/XYLHxylh/article/details/103862447

0108 luffy登录注册接口

北慕城南 提交于 2020-01-12 21:55:02
目录 昨日回顾 luffy后台 验证手机号是否已注册 使用手机号与验证码注册 luffy前台 登录模态框 注册模态框 用户模块三大认证处理 前后台交互 登录 前台登录手机号校验 前台获取验证码 前台短信验证码登录 前台登录注销 前台密码登录 注册 验证码的一次性处理 昨日回顾 1、git的协同操作 1)拿公钥换源远程仓库源链接 - 成为项目开发者 2)根据源链接克隆远程仓库 - git clone 源地址 3)参与项目的团队开发,永远要遵循 先pull后push,在pull之前要将所有修改的代码提交到本地版本库 2、冲突解决 1)当不同开发者协同开发,导致远程仓库与本地仓库的版本不一致,在pull远程仓库到本地仓库时,会出现版本冲突 2)两个仓库不同版本中,出现了相同文件的修改情况,会出现文件的冲突 3)同一文件的修改,代码有重叠,一定会产生代码冲突,打开冲突的文件,文件中会表示冲突的开始与结束,分割线上下分别是冲突的代码 >>>>>>>>>>header =========== <<<<<<<<<<1321adsa21 4)冲突的解决没有固定的结果,但是要将冲突的标识删除,根据代码实际情况,线下沟通,整合代码即可 3、登录业务 1)多方式登录 2)短信验证码 腾讯短信服务 - 创建短信服务应用(appid、appkey),申请签名与模板 -- 安装对应sdk --

day5-requests的post方法

帅比萌擦擦* 提交于 2020-01-12 14:50:11
1.初步接触post 1.requests的POST请求 ''' # 1.访问login页面获取token信息 Request URL: https://github.com/login Request Method: GET #服务端告诉客户端需要设置的Cookies 响应头(response headers): Set-Cookies 请求头(request headers): Cookie User-Agent ''' headers ={'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.90 Safari/537.36' } import requests import re url1='https://github.com/login' response = requests.get(url1,headers=headers) #把login页返回的cookie信息转换为字典 login_cookies =response.cookies.get_dict() #print(login_cookies) """ 正则:<input type="hidden" name="authenticity

使用JWT实现Token认证

血红的双手。 提交于 2020-01-12 13:43:13
使用JWT实现Token认证 42018.08.15 15:42:39字数 187阅读 105,505 为什么使用JWT? 随着技术的发展,分布式web应用的普及,通过session管理用户登录状态成本越来越高,因此慢慢发展成为token的方式做登录身份校验,然后通过token去取redis中的缓存的用户信息,随着之后jwt的出现,校验方式更加简单便捷化,无需通过redis缓存,而是直接根据token取出保存的用户信息,以及对token可用性校验,单点登录更为简单。 JWT架构图 JWT架构图.png 使用JWT核心代码: maven依赖: <dependency> <groupId>com.auth0</groupId> <artifactId>java-jwt</artifactId> <version>3.2.0</version> </dependency> <dependency> <groupId>io.jsonwebtoken</groupId> <artifactId>jjwt</artifactId> <version>0.7.0</version> </dependency> JWT工具类: 用于生成Token,和Token验证 public class JwtUtils { /** * 签发JWT * @param id * @param subject

Unix cut except last two tokens

Deadly 提交于 2020-01-12 11:47:38
问题 I'm trying to parse file names in specific directory. Filenames are of format: token1_token2_token3_token(N-1)_token(N).sh I need to cut the tokens using delimiter '_' , and need to take string except the last two tokens. In above examlpe output should be token1_token2_token3 . The number of tokens is not fixed. I've tried to do it with -f#- option of cut command, but did not find any solution. Any ideas? 回答1: With cut: $ echo t1_t2_t3_tn1_tn2.sh | rev | cut -d_ -f3- | rev t1_t2_t3 rev

微信分享微信公众账号设置,服务器端代码

对着背影说爱祢 提交于 2020-01-12 04:47:15
微信公众账号 需要一个认证的微信公众号,一定要确定认证 在登录微信公众平台https://mp.weixin.qq.com 在公众号设置–>功能设置,填写设置Js接口安全域名、网页授权域名、业务域名 开始做之前,网上有些文档,只是说要设置js接口安全域名,结果一直报错 40048,invalid url domain 说是域名不合法,最后查到一个文章说 最好把网页授权域名、业务域名跟js接口安全域名保持一致。 设置以后,不报错了。 服务器端php代码 获取签名等信息,必须通过服务器返回,不能在前端js生成 代码是在laravel框架中写的 路由 //获取微信分享config Route::get('getWechatConfig', 'ApiWeChatController@getWechatConfig'); 控制器 <?php namespace App\Http\Controllers\Api; use App\Extend\WeChat\JSSDK; class ApiWeChatController extends ApiCommonController { /** * 获取微信分享配置 */ public function getWechatConfig() { $url = request()->input('url'); $jssdk = new JSSDK(

csrf的中间件

余生长醉 提交于 2020-01-11 18:23:38
csrf的中间件 源码简略分析: def process_request(self, request): # 从cookies中获取csrf_token csrf_token = self._get_token(request) if csrf_token is not None: # Use same token next time. # 将csrf_token添加到request的头部信息中 request.META['CSRF_COOKIE'] = csrf_token def process_view(self, request, callback, callback_args, callback_kwargs): # csrf校验已经完成 if getattr(request, 'csrf_processing_done', False): return None # Wait until request.META["CSRF_COOKIE"] has been manipulated before # bailing out, so that get_token still works # 豁免 if getattr(callback, 'csrf_exempt', False): return None # Assume that anything not

csrf的中间件

谁都会走 提交于 2020-01-11 10:59:57
csrf的中间件 源码简略分析: def process_request(self, request): # 从cookies中获取csrf_token csrf_token = self._get_token(request) if csrf_token is not None: # Use same token next time. # 将csrf_token添加到request的头部信息中 request.META['CSRF_COOKIE'] = csrf_token def process_view(self, request, callback, callback_args, callback_kwargs): # csrf校验已经完成 if getattr(request, 'csrf_processing_done', False): return None # Wait until request.META["CSRF_COOKIE"] has been manipulated before # bailing out, so that get_token still works # 豁免 if getattr(callback, 'csrf_exempt', False): return None # Assume that anything not

单点登陆SSO(一)原理、多客户端登陆

混江龙づ霸主 提交于 2020-01-11 06:49:22
单点登陆 单点登陆项目GitHub 单点登陆的原理 客户端一拦截器 感谢coding老师的课程,让我能很好的学习,掌握单点登陆的相关知识,所有的代码都来自或者修改coding老师的视频,简单总结一下 单点登陆项目GitHub github: https://github.com/Handoking/Single-Sign-on 单点登陆的原理 单点登陆最主要保证的就是一处登陆,处处登陆,也就是我们登陆taobao后,访问账号相通的另一个应用时,只需要刷新页面就登陆了。单点登陆的设计合理性就是认证中心的存在,不可能让taobao的服务器通知其他产品矩阵中的应用。 本博文的单点登陆是一个比较传统的实现方式-CAS原理,使用全局会话,局部会话完成。多客户端实现单点登陆的步骤: 用户第一次访问taobao,认证中心发现用户未登录,先登录 登陆成功后,生成唯一token,并存入认证中心(现在很多自动完成认证,不需要存入),生成全局会话 访问tianmao时,先从全局会话中获得token,携带token访问 认证中心验证token是否存在 验证成功,重定向到tianmao首页。 原理 : 认证中心(授权服务器)保存一份全局的session(一般用cache中间件比如redis等实现),多个客户端保存本地局部session。 用户访问时,客户端先查看本地session是否登陆,如果没有登陆