TokenService
https://github.com/ng-alain/delon/blob/master/packages/auth/src/token/token.service.ts
set(data: ITokenModel): boolean {
const res = this.store.set(this._options.store_key!, data);
this.change$.next(data);
return res;
}
ITokenModel: https://github.com/ng-alain/delon/blob/master/packages/auth/src/token/interface.ts
export interface ITokenModel {
[key: string]: any;
token: string | null | undefined;
/**
* 过期时间,单位:ms
* - 不管Simple、JWT模式都必须指定
*/
expired?: number;
}
SimpleGuard:
https://github.com/ng-alain/delon/blob/master/packages/auth/src/token/simple/simple.guard.ts
注入了 TokenService
@Injectable({ providedIn: 'root' })
export class SimpleGuard implements CanActivate, CanActivateChild, CanLoad {
private url?: string;
private get cog(): AlainAuthConfig {
return this.srv.options;
}
constructor(@Inject(DA_SERVICE_TOKEN) private srv: ITokenService, private injector: Injector) {}
private process(): boolean {
const res = CheckSimple(this.srv.get() as SimpleTokenModel);
if (!res) {
ToLogin(this.cog, this.injector, this.url);
}
return res;
}
// lazy loading
canLoad(route: Route, _segments: UrlSegment[]): boolean {
this.url = route.path;
return this.process();
}
// all children route
canActivateChild(_childRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
this.url = state.url;
return this.process();
}
// route
canActivate(_route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
this.url = state.url;
return this.process();
}
}
在默认的 src\app\routes\routes-routing.module.ts 中使用了 SimpleGuard 来检查用户是否已经登录。
const routes: Routes = [
{
path: '',
component: LayoutBasicComponent,
canActivate: [startPageGuard, SimpleGuard],
canActivateChild: [SimpleGuard],
JWTGuard
https://github.com/ng-alain/delon/blob/master/packages/auth/src/token/jwt/jwt.guard.ts
TokenService的更多相关文章
- atitit.TokenService v3 qb1 token服务模块的设计 新特性.docx
atitit.TokenService v3 qb1 token服务模块的设计 新特性.docx 1.1. V3 新特性1 1.2. V2 新特性1 2. Token的归类1 3. Token的用途 ...
- atitit.TokenService token服务模块的设计
atitit.TokenService token服务模块的设计 1. Token的归类1 2. Token的用途2 2.1. 访问控制2 2.2. 编译原理术语)编辑2 2.3. 数据处理2 1. ...
- Spring Security OAuth2 开发指南
官方原文:http://projects.spring.io/spring-security-oauth/docs/oauth2.html 翻译及修改补充:Alex Liao. 转载请注明来源:htt ...
- Atitit. 项目文档目录大纲 总集合 v2
Atitit. 项目文档目录大纲 总集合 v2 -----Atitti.原有项目源码的架构,框架,配置与环境说明 v3 q511 -----Atitit.开发环境 与 工具 以及技术框架 以及 注意 ...
- Web APi之认证(Authentication)两种实现方式后续【三】(十五)
前言 之前一直在找工作中,过程也是令人着实的心塞,最后还是稳定了下来,博客也停止更新快一个月了,学如逆水行舟,不进则退,之前学的东西没怎么用,也忘记了一点,不过至少由于是切身研究,本质以及原理上的脉络 ...
- Atitit 修改密码的功能流程设计 attilax总结
Atitit 修改密码的功能流程设计 attilax总结 1.1. 注意点1 1.2. 设计修改用户密码功能时把用户ID保存在哪里?1 1.3. Ui设计1 1.4. 功能设计源码1 1.5. Agt ...
- [BTS] BizTalk With EF
System.TypeInitializationException: The type initializer for 'System.Data.Entity.Internal.AppConfig' ...
- asp.net单点登录(SSO)解决方案
前些天一位朋友要我帮忙做一单点登录,其实这个概念早已耳熟能详,但实际应用很少,难得最近轻闲,于是决定通过本文来详细描述一个SSO解决方案,希望对大家有所帮助.SSO的解决方案很多,但搜索结果令人大失所 ...
- ArcGIS API for Silverlight开发入门
你用上3G手机了吗?你可能会说,我就是喜欢用nokia1100,ABCDEFG跟我 都没关系.但你不能否认3G是一种趋势,最终我们每个人都会被包裹在3G网络中.1100也不是一成不变,没准哪天为了打击 ...
- 基于.Net的单点登录(SSO)解决方案
前些天一位朋友要我帮忙做一单点登录,其实这个概念早已耳熟能详,但实际应用很少,难得最近轻闲,于是决定通过本文来详细描述一个SSO解决方案,希望对大家有所帮助.SSO的解决方案很多,但搜索结果令人大失所 ...
随机推荐
- WeiXin.Export.20220726
用 QuestPDF操作生成PDF更快更高效! Blazor Server 应用程序中进行 HTTP 请求 开源WPF控件库-AdonisUI FastTunnel-开源内网穿透框架 AI 之 Ope ...
- golang中使用多线程和channel通道
package controller import ( "context" "github.com/gogf/gf/v2/os/grpool" "sy ...
- 集成InfluxDb, telegraf, Grafana, App Metrics以记录性能指标
前情概要 刚好有半天得闲功夫, 从项目里面找个功能来水一篇文章. 上线的项目通常都是需要做性能数据收集工作的, 它好处就不想打字了. 业界有很多套方案, 工具[收费的, 免费的], 收集采用[拉取的, ...
- vue3实现多层级的动态表单增减
.markdown-body { line-height: 1.75; font-weight: 400; font-size: 16px; overflow-x: hidden; color: rg ...
- 在 Azure CNI 中启用 Calico WireGuard
作者:Peter Kelly 译者:Wendi Wang 注:本文已取得作者本人的翻译授权! 去年6月,Tigera 宣布首次在 K8s 上支持用于集群内加密传输的开源 VPN - WireGuard ...
- 某制造企业基于 KubeSphere 的云原生实践
背景介绍 随着业务升级改造与软件产品专案的增多,常规的物理机和虚拟机方式逐渐暴露出一些问题: 大量服务部署在虚拟机上,资源预估和硬件浪费较大: 大量服务部署在虚拟机上,部署时间和难度较大,自动化程度较 ...
- 听说过Paas、Saas和Iaas,那你听说过Apaas吗?
互联网行业就喜欢搞一些单词的缩写,在云计算行业,前者有SaaS.PaaS.IaaS,最近两三年APaaS的概念又开始被关注.APaaS到底是什么意思,有什么用,与前三者的区别是什么?本文将对这些问题进 ...
- AI年代,谁还用难用的Keil?快快换CLion!!! 破解+环境替换 [上]
安装Clion 由于这个地方碰壁比较多,所以大家严格按照我下面的安装节奏就可以了! 记得CLion的版本等,和我所说的不匹配也会导致破解失败. 包能破解安装上的. 1.下载 链接:https://pa ...
- Trie树练习题
Trie树练习题 T1 「一本通 2.3 例 2」The XOR Largest Pair 在给定的 \(N\) 个整数\(A_1,A_2,...A_N\)中选出两个进行异或运算,得到的结果最大是多少 ...
- 经典C语言题目——打印罗汉塔图形
打印如下图形: ++++1 +++22 ++333 +4444 55555 点击查看代码 #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> ...