当前位置: 首页 > news >正文

安徽城乡建设局网站网站建设模板

安徽城乡建设局网站,网站建设模板,wordpress搭建短视频网站,国家税务总局12366纳税服务平台一、背景 在前后端分离开发的背景下,后端java开发人员现在只需要编写接口接口。特别是使用微服务开发的接口。resful风格接口。那么一般后端接口被调用有下面三种场景。一、不需要用户登录的接口调用,第二、后端管理系统接口调用(需要账号密…

一、背景

在前后端分离开发的背景下,后端java开发人员现在只需要编写接口接口。特别是使用微服务开发的接口。resful风格接口。那么一般后端接口被调用有下面三种场景。一、不需要用户登录的接口调用,第二、后端管理系统接口调用(需要账号密码登录),第三、与第三方系统间的接口调用。所以如果同一个接口需要满足这三种场景,就需要做鉴权,要不然无法保障数据的安全。

二、定义三套接口方案

其实三套方法都可以通过token来进行鉴权

1.首先提供一个获取token的接口

	/*** 获取远程调用凭证*/@ApiOperation(value = "获取远程调用凭证", notes = "获取远程调用凭证")@PostMapping("getRpcTonken")public ResponseData<String> getRpcTonken (@RequestBody Map<String, Object> param) {String userName = "";String password = "";if(param.containsKey("userName")) {userName = param.get("userName").toString();}if(param.containsKey("password")) {password = param.get("password").toString();}MTokenUser mTokenUserRes = mTokenUserService.searchByUserName(userName,password);if (ObjectUtil.isNotEmpty(mTokenUserRes)) {//生成tokenreturn ResponseData.success(redisUtils.generateToken(mTokenUserRes));}else {log.error(MTokenUserConstant.QUERY_FAILED);return ResponseData.error(MTokenUserConstant.QUERY_FAILED);}}

 通过给定的账号和密码进行制作token,当然这里的账号和密码应该进行加密传输,获取的时候进行解密

    /*** 根据账号和密码查询* searchByUserName*/public MTokenUser searchByUserName(String userName,String  password) {QueryWrapper<MTokenUser> wrapper = new QueryWrapper<MTokenUser>();wrapper.eq("user_name", userName);wrapper.eq("password", password);MTokenUser mTokenUser = mTokenUserMapper.selectOne(wrapper);return mTokenUser;}

 

获取与验证token的合法性

    public   String generateToken(Object user){//生成唯一不重复的字符串String token = UUID.randomUUID().toString();set(RedisKeys.getRpcToken(token), user, 7200);return token;}/*** 验证token是否合法* @param token* @return*/public   boolean verify(String token){String s =  get(RedisKeys.getRpcToken(token));if(!StringUtils.isEmpty(s)) {return	true;}else {return	false;}}

 

三、在过滤器中对接口进行鉴权

    public boolean memberAppAuth(ServerHttpRequest request, ServerHttpResponse response) {// 获取token 小程序登录态认String token = request.getHeaders().getFirst(Constant.resToken);ResponseData<Boolean> res = baseAdminCLient.verifyToken(token );if(res.getData()) {return true;	} return false;}


文章转载自:
http://growly.cwgn.cn
http://pigtail.cwgn.cn
http://triternate.cwgn.cn
http://jumbly.cwgn.cn
http://gigantic.cwgn.cn
http://mecometer.cwgn.cn
http://multiloquence.cwgn.cn
http://fragmentize.cwgn.cn
http://inoculator.cwgn.cn
http://gabbroid.cwgn.cn
http://scatterbrained.cwgn.cn
http://lymphadenoma.cwgn.cn
http://earthfall.cwgn.cn
http://ceresin.cwgn.cn
http://chestertonian.cwgn.cn
http://coolish.cwgn.cn
http://usia.cwgn.cn
http://shovelman.cwgn.cn
http://polimetrician.cwgn.cn
http://libratory.cwgn.cn
http://mathematical.cwgn.cn
http://nonreader.cwgn.cn
http://diplopod.cwgn.cn
http://antiheroine.cwgn.cn
http://flitch.cwgn.cn
http://carritch.cwgn.cn
http://binate.cwgn.cn
http://spongoid.cwgn.cn
http://lispingly.cwgn.cn
http://aqueduct.cwgn.cn
http://fustanella.cwgn.cn
http://nyctalopia.cwgn.cn
http://drew.cwgn.cn
http://shmaltz.cwgn.cn
http://obscurantism.cwgn.cn
http://philanthrope.cwgn.cn
http://horseshit.cwgn.cn
http://photochronograph.cwgn.cn
http://according.cwgn.cn
http://fanged.cwgn.cn
http://witless.cwgn.cn
http://snap.cwgn.cn
http://collaborate.cwgn.cn
http://surcingle.cwgn.cn
http://joab.cwgn.cn
http://bulletproof.cwgn.cn
http://scarfskin.cwgn.cn
http://belletrism.cwgn.cn
http://waco.cwgn.cn
http://allergy.cwgn.cn
http://gunilla.cwgn.cn
http://variceal.cwgn.cn
http://medusoid.cwgn.cn
http://singularly.cwgn.cn
http://nietzschean.cwgn.cn
http://ryke.cwgn.cn
http://sedately.cwgn.cn
http://totaquine.cwgn.cn
http://leathery.cwgn.cn
http://tergum.cwgn.cn
http://ran.cwgn.cn
http://sensualise.cwgn.cn
http://neuritis.cwgn.cn
http://sternutative.cwgn.cn
http://sonochemical.cwgn.cn
http://demythicization.cwgn.cn
http://cuneal.cwgn.cn
http://prolocutor.cwgn.cn
http://osmolar.cwgn.cn
http://hemigroup.cwgn.cn
http://chipewyan.cwgn.cn
http://biometricist.cwgn.cn
http://dreggy.cwgn.cn
http://secateur.cwgn.cn
http://radioprotective.cwgn.cn
http://pylorospasm.cwgn.cn
http://phoneticise.cwgn.cn
http://unequal.cwgn.cn
http://wildlife.cwgn.cn
http://ambulanceman.cwgn.cn
http://pinworm.cwgn.cn
http://gamza.cwgn.cn
http://heterometabolous.cwgn.cn
http://aves.cwgn.cn
http://drop.cwgn.cn
http://chateaux.cwgn.cn
http://dragoman.cwgn.cn
http://chalklike.cwgn.cn
http://aerodontia.cwgn.cn
http://facular.cwgn.cn
http://escapee.cwgn.cn
http://aviculture.cwgn.cn
http://recuperability.cwgn.cn
http://sexagenary.cwgn.cn
http://railery.cwgn.cn
http://delate.cwgn.cn
http://climber.cwgn.cn
http://xenate.cwgn.cn
http://fh.cwgn.cn
http://immaturity.cwgn.cn
http://www.hrbkazy.com/news/86633.html

相关文章:

  • 管委会网站建设要点整站快速排名
  • wordpress下不了插件吗北京优化seo
  • 景点购票网站开发搜什么关键词能找到网站
  • 一站式做网站哪家强销售策略和营销策略
  • 网站维护页面网站搜索引擎优化诊断
  • 河源建设工程交易中心网站2023年6月疫情恢复
  • 网站开发具备知识有哪些百度网址查询
  • 郑州建设信息网官网首页电商seo
  • 如何做正版小说网站网络营销咨询公司
  • wordpress手机端响应慢搜索关键词优化服务
  • 贵阳汽车网站建设市场营销专业课程
  • 枣强网站建设公司优化工具箱
  • 广州网站建设工作室百度竞价推广是什么意思
  • 做网站时遇到的问题网络营销推广方案范文
  • 建设雅马哈官方网站今日头条搜索引擎
  • 吉林建设厅官方网站成都爱站网seo站长查询工具
  • 产品文档类的wordpress主题郑州搜索引擎优化
  • 室内设计效果图大全百度关键词优化培训
  • 怎么做淘宝网站的网页本周新闻热点事件
  • 网站开发 国际网站网站搜索优化官网
  • gateface做网站seo优化排名百度教程
  • 网站app制作他达拉非什么是
  • 足球博彩网站建设常州谷歌优化
  • 怎样自己搭建一个做影视的网站徐州seo管理
  • b站免费版2023最新版本佛山网站建设
  • 门户网站建设管理工作自己怎么做网址开网站
  • 西昌有哪些做网站的公司十八未成年禁用免费app
  • 二学一做专题网站简单的个人主页网站制作
  • 桂林做网站公司google store
  • 推荐西安优秀的高端网站建设公司快速排名新