CAS5.3X 之配置默认Service实现

CAS单点登录Service参数安全漏洞剖析与防御实战 单点登录(SSO)是现代企业身份认证的核心技术,其核心原理是通过中央认证服务器统一验证用户身份,并安全地将用户重定向回业务系统。CAS(Central Authentication Service)作为广泛应用的SSO解决方案,其安全性直接关系到整个业务体系的门户安全。在CAS协议流程中,Service参数决定了认证成功后的用户重定向目标,若服务端对此参数校验不严,攻击者便可利用此漏洞实施钓鱼攻击。这种攻击手法利用了用户对正规登录流程的信任,在真实的认证页面窃取凭据后,将用户诱导至伪装成内部系统的钓鱼网站, 阅读详情

前言

今儿老A问我 :“怎么在没有service的情况下,给CAS配置默认的service,跳转到固定的url啊?”
我:“额,文档不是写了嘛?在springboot的配置文件application.properties里有个配置属性,就下边这个”

官网文档链接:
https://apereo.github.io/cas/5.0.x/installation/Configuration-Properties.html

# Defines a default URL to which CAS may redirect if there is no service
# provided in the authentication request.
cas.view.defaultRedirectUrl=https://www.github.com

过了一会儿…
老A:“哎,不对呀,你过来看看,这怎么还提示我CAS无法使用
呢,页面也没跳转呀”
错误提示:

Error: Exception thrown executing org.apereo.cas.web.flow.login.GenericSuccessViewAction@50118e2e in state ‘viewGenericLoginSuccess’ of flow ‘login’ – action execution attributes were ‘map[[empty]]’

截图:在这里插入图片描述
我:“哟,中奖了!来来来,分析分析…”

CAS配置默认service

经过前面的对话,咱都了解了老A的问题,也去看了CAS的文档,知道了有个配置是用来定义一个默认URL,如果没有服务的情况下,CAS可以重定向到该URL。
当然,还要注意一句话:“provided in the authentication request. ”,意思是说你这个URL也不能乱写,必须要通过serviceid的正则验证才行
通过入门文档,咱都知道,在resources/services下新建的主题json文件,基本都长下面这样:

静态Service配置

{
  "@class": "org.apereo.cas.services.RegexRegisteredService",
  "serviceId": "^(http)://localhost.*",
  "name": "本地服务",
  "id": 100001,
  "description": "这是一个本地允许的服务,通过localhost访问都允许通过",
  "evaluationOrder": 1
}

注意:
json文件名字规则为 n a m e − {name}- name−{id}.json, id必须为json文件内容id一致
json文件解释:

  • @class:必须为org.apereo.cas.services.RegisteredService的实现类,对其他属性进行一个json反射对象,常用的有RegexRegisteredService,匹配策略为id的正则表达式
  • serviceId:唯一的服务id
  • name: 服务名称,会显示在默认登录页
  • id:全局唯一标志
  • description:服务描述,会显示在默认登录页
  • evaluationOrder:确定已注册服务的相对评估顺序。当两个服务URL表达式覆盖相同的服务时,此标志尤其重要;评估顺序决定首先评估哪个注册,并作为内部排序因素。 (越小越优先)
    除了以上说的还有很多配置策略以及节点,具体还要看官方文档,配置不同的RegisteredService也会有稍微不一样,当然咱也可以写自己的,这是后话,没啥不行的。
    按老A的描述,他这里也做了修改,长下面这样,确实把啥url都给放过了,没话说。
{
  "@class" : "org.apereo.cas.services.RegexRegisteredService",
  "serviceId" : "^(https|imaps|http)://.*",
  "name" : "Landing One",
  "id" : 1000,
  "description" : "landingone 项目访问过来,跳转到demo主题",
  "evaluationOrder" : 10,
  "theme": "landingone"
}

Spring Web Flow

咱们都知道CAS目前是集成了Spring Web Flow,在CAS中Spring Web Flow的配置文件最初始的就有login-webflow.xml面主要配置了登录的流程。这个如果用图来表示的话那应该是一个状态图,一些节点会有一些判断然后会有不同的分支。
不知道大伙有没有看过历史版本哈,那玩意真的是,节点挺多的,一眼望不到底,还得翻两页。
哎,咱们用的这个CAS 5.3.1 版本,贼简单,就长下面这样:

<?xml version="1.0" encoding="UTF-8"?>
<flow xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns="http://www.springframework.org/schema/webflow"
      xsi:schemaLocation="http://www.springframework.org/schema/webflow
                          http://www.springframework.org/schema/webflow/spring-webflow.xsd">

    <action-state id="initializeLoginForm">
        <evaluate expression="initializeLoginAction" />
        <transition on="success" to="viewLoginForm"/>
    </action-state>

    <view-state id="viewLoginForm" view="casLoginView" model="credential">
        <binder>
            <binding property="username" required="true"/>
            <binding property="password" required="true"/>
        </binder>
        <transition on="submit" bind="true" validate="true" to="realSubmit" history="invalidate"/>
    </view-state>

    <action-state id="realSubmit">
        <evaluate expression="authenticationViaFormAction"/>
        <transition on="warn" to="warn"/>
        <transition on="success" to="createTicketGrantingTicket"/>
        <transition on="successWithWarnings" to="showAuthenticationWarningMessages"/>
        <transition on="authenticationFailure" to="handleAuthenticationFailure"/>
        <transition on="error" to="initializeLoginForm"/>
    </action-state>
</flow>

疑问来了,哎:

  1. 为啥老版本流程节点分支那么多,这里就这些呢?
  2. 为啥在初始化流程对象的时候,看到的节点数量比这个xml要多?

这就问到点子上了,大兄弟们请看好:
我们在开发过程中啊,不会只有上面这个viewLoginForm中username和password俩字段,有些复杂的场景呢,比如多加个验证码字段,多加个注册流程,再来个第三方登录(微信、支付宝、WhatsApp)等等要求,所以上面这个登录流程,咱们真的就当他是个流程就行了,扯远了。咱们下面说下CAS 5.3.1 是怎么用Springboot实现的web flow吧

Springboot 流程实现(解读源码)

1.首先来看CAS的流程管理器 org.apereo.cas.web.flow.CasWebflowConfigurer
这是一个接口,它定义了CAS的核心流程,登录和登出。后面还有一堆的节点创建定义,咱们就先不说了,自个儿去琢磨吧。

public interface CasWebflowConfigurer extends Ordered {
    String FLOW_ID_LOGIN = "login";
    String FLOW_ID_LOGOUT = "logout";

    void initialize();

    Flow getLoginFlow();

    Flow getLogoutFlow();
    ...

此接口的实现类 org.apereo.cas.web.flow.configurer.AbstractCasWebflowConfigurer
看名字就知道,这家伙是抽象的,肯定还有抽象方法等着小弟去实现。那咱们重点关注下它的抽象方法,再看看CAS给它有了哪些实现:
在这里插入图片描述
实现类:
在这里插入图片描述

  • DefaultLoginWebflowConfigurer:登录流程初始化
  • DefaultLogoutWebflowConfigurer:登出流程初始化
  • DelegatedAuthenticationWebflowConfigurer:为pac4j集成调整初始化webflow上下文
  • GroovyWebflowConfigurer :执行Groovy脚本来自动配置webflow上下文,不多做阐述

后面两个咱们就不先不讨论了,另外因为登出贼简单,这次问题也在登录,所以咱这次就先关注登录流程。
在这里插入图片描述
我们可以看到,当获取到的flow对象不为null时,给flow初始化了以下这些配置,
(干了啥呢?你们自己点进去看,请允许我在这儿偷个懒,下面给你们解释)

keyValue
createInitialFlowActions(flow);创建初始流程,点进去看就知道,这里给flow对象的startActionList添加了initialFlowSetupAction的实现
createDefaultGlobalExceptionHandlers(flow);创建默认的全局异常处理器
createDefaultEndStates(flow);这个有意思,开发的大兄弟把注解写错了。这里就是定义流程的各类结束节点
createDefaultDecisionStates(flow);创建默认的决策节点
createDefaultActionStates(flow);创建默认的Action节点
createDefaultViewStates(flow);创建默认的视图节点
createRememberMeAuthnWebflowConfig(flow);创建记住我流程节点

最后设置开始节点:
setStartState(flow,CasWebflowConstants.STATE_ID_INITIAL_AUTHN_REQUEST_VALIDATION_CHECK);| Column 2

哎,看到这里,相信大家一定都知道怎么去找老A问题的原因了,话不多说,咱们继续分析:
老A的问题是登录成功后未重定向到配置的url:cas.view.defaultRedirectUrl=https://www.baidu.com

那经过前面的分析,我们了解到登录流程的初始化过程,那么到底哪段代码的问题呢?不卖关子了,那就是创建默认的决策节点的问题呗。
下面是createDefaultDecisionStates(flow); 的代码:
在这里插入图片描述
哎?发现没有,有这么一句 createHasServiceCheckDecisionState(flow);
明显就是创建判断是否有Service服务的节点嘛,继续看:
在这里插入图片描述在这里插入图片描述

String STATE_ID_HAS_SERVICE_CHECK = "hasServiceCheck";

String STATE_ID_VIEW_GENERIC_LOGIN_SUCCESS = "viewGenericLoginSuccess";

看到这里,大家都很明白了,当节点hasServiceCheck判断没有Service 服务时,将会跳到下个节点viewGenericLoginSuccess。
那么viewGenericLoginSuccess从命名上来看,我们就知道查看登录是否成功,若成功则继续下个节点,那我们来看:viewGenericLoginSuccess的下个节点是

    String VIEW_ID_GENERIC_SUCCESS = "casGenericSuccessView";

在这里插入图片描述
哎,我们知道了casGenericSuccessView 是个登录成功视图节点,我们都知道,视图节点的特点是会有对应的视图页面,那我们来找找看:
在这里插入图片描述
那我们登录完成后,会跳转到一个CAS登录成功的视图页面,不就是这个html嘛。

分析总结

CAS通过springboot集成Spring Web Flow,从而定义流程管理器CasWebflowConfigurer实现了各类流程节点的初始化。

原因分析

使用 cas.view.defaultRedirectUrl=https://www.baidu.com 配置默认的service,在默认不调整流程情况下,会出现重复重定向的错误。
导致了上述老A的问题发生。

解决方案:

在流程初始化时,将 createGenericLoginSuccessEndState(flow);的节点移除,
在application.properties中配置属性cas.view.defaultRedirectUrl=https://www.baidu.com
即可实现默认service的跳转,以下为方法重写:

public class BaseConfigurer extends DefaultLoginWebflowConfigurer {
	public BaseConfigurer(FlowBuilderServices flowBuilderServices, FlowDefinitionRegistry flowDefinitionRegistry, ApplicationContext applicationContext, CasConfigurationProperties casProperties) {
		super(flowBuilderServices, flowDefinitionRegistry, applicationContext, casProperties);
	}
	
	/**
	 * 绑定输入信息
	 *
	 * @param flow
	 */
	protected void bindCredential(final Flow flow, String stateid) {
		this.createFlowVariable(flow, "credential", UsernamePasswordExtensionCredential.class);
		ViewState state = (ViewState) this.getState(flow, stateid, ViewState.class);
		BinderConfiguration cfg = this.getViewStateBinderConfiguration(state);
		cfg.addBinding(new BinderConfiguration.Binding("verifycode", (String) null, false));
		cfg.addBinding(new BinderConfiguration.Binding("verifytype", (String) null, false));
		cfg.addBinding(new BinderConfiguration.Binding("submittype", (String) null, false));
		cfg.addBinding(new BinderConfiguration.Binding("twicepassword", (String) null, false));
	}
	
	protected void createDefaultGlobalExceptionHandlers(final Flow flow, String stateId) {
		TransitionExecutingFlowExecutionExceptionHandler h = new TransitionExecutingFlowExecutionExceptionHandler();
		h.add(UnauthorizedSsoServiceException.class, stateId);
		h.add(NoSuchFlowExecutionException.class, "viewServiceErrorView");
		h.add(UnauthorizedServiceException.class, "serviceUnauthorizedCheck");
		h.add(UnauthorizedServiceForPrincipalException.class, "serviceUnauthorizedCheck");
		flow.getExceptionHandlerSet().add(h);
	}
	
	
	protected void createRememberMeAuthnWebflowConfig(final Flow flow, String stateId) {
		if (this.casProperties.getTicket().getTgt().getRememberMe().isEnabled()) {
			this.createFlowVariable(flow, "credential", RememberMeUsernamePasswordCredential.class);
			ViewState state = (ViewState) this.getState(flow, stateId, ViewState.class);
			BinderConfiguration cfg = this.getViewStateBinderConfiguration(state);
			cfg.addBinding(new BinderConfiguration.Binding("rememberMe", (String) null, false));
		} else {
			this.createFlowVariable(flow, "credential", UsernamePasswordCredential.class);
		}
		
	}
}


public class LoginWebflowConfigurer extends BaseConfigurer {


    public LoginWebflowConfigurer(FlowBuilderServices flowBuilderServices, FlowDefinitionRegistry loginFlowDefinitionRegistry, ApplicationContext applicationContext, CasConfigurationProperties casProperties) {
        super(flowBuilderServices, loginFlowDefinitionRegistry, applicationContext, casProperties);
    }

    @Override
    protected void doInitialize() {
        final Flow flow = getLoginFlow();
        if (flow != null) {
            this.bindCredential(flow, "viewLoginForm");
            this.createInitialFlowActions(flow);
            this.createDefaultGlobalExceptionHandlers(flow);
            this.createDefaultEndStates(flow);
            this.createDefaultDecisionStates(flow);
            this.createDefaultActionStates(flow);
            this.createDefaultViewStates(flow);
            this.createRememberMeAuthnWebflowConfig(flow);
            this.setStartState(flow, "initialAuthenticationRequestValidationCheck");
        }
    }

    @Override
    protected void createDefaultEndStates(final Flow flow) {
        createRedirectUnauthorizedServiceUrlEndState(flow);
        createServiceErrorEndState(flow);
        createRedirectEndState(flow);
        createPostEndState(flow);
        createInjectHeadersActionState(flow);
        createServiceWarningViewState(flow);
        createEndWebflowEndState(flow);
    }

    /**
     * Create service error end state.
     *
     * @param flow the flow
     */
    private void createServiceErrorEndState(final Flow flow) {
        createEndState(flow, CasWebflowConstants.STATE_ID_VIEW_SERVICE_ERROR, CasWebflowConstants.VIEW_ID_SERVICE_ERROR);
    }
}

CAS学习笔记一:CAS 授权服务器简易搭建 什么是CAS CAS是Central Authentication Service的缩写,中央认证服务,一种独立开放指令协议。CAS 是 耶鲁大学(Yale University)发起的一个开源项目,旨在为 Web 应用系统提供一种可靠的单点登录方法,CAS 在 2004 年 12 月正式成为 JA-SIG 的一个项目。 简单来说,就是开源的企业级单点登录(SSO)服务。 CAS Server 搭建思路 CAS 官方提供了一种使用 Apereo CAS WAR Overlay Template 的方式(开发 阅读详情

相关推荐

CAS单点登录安全加固:深度解析service参数漏洞与防御实战

单点登录(SSO)是现代企业身份认证的核心组件,其核心原理是通过中央认证服务器统一管理用户身份,实现一次登录、多处访问。CAS(Central Authentication Service)作为广泛采用的开源SSO解决方案,其安全性直接关系到整个应用生态。在CAS协议流程中,service参数作为回调地址,若校验不当会引发凭证窃取风险,这是典型的开放重定向漏洞。从技术价值看,严格的service参数校验不仅能防止会话劫持,更是纵深防御体系的关键一环。在金融、政务等高安全要求场景中,此类漏洞可能导致严重的数据

weixin_34408624的博客 381

cas单点登录-服务端集成shiro权限认证(五)

所谓单点登录(SSO),只当企业用户同时访问多个不同(类型的)应用时,他们只需要提供自身的用户凭证信息(比如用户名/密码)一次,当用户在不同的应用间切换时,他们不用再重复地输入自身的用户凭证了。我的设计思路是SSO只做认证中心,各应用的授权在各自的服务做,比如 查看订单权限, 这个权限,它可能仅仅只是订单系统这个应用的权限。因此,授权应该在客户端做,本篇只是简单的介绍cas服务端与shiro 的集成, 只验证是否拥有角色,有角色就可以登录,没角色不可以登录。 这里有两种方式 第一种:一种是官网文档方式,

weixin_42073629的博客 1993

CAS之5.2x版本自定义登录页面-yellowcong

我现在的需求是,我有两个子站点,yellowcong.com,yellowlu.com. 两个站点使用不同的样式。1、在services文件夹添加的json配置文件,2、配置application.properties,设置`cas.serviceRegistry.initFromJson=true`,让配置的json文件生效,3、在static 文件夹,添加静态样式,4、在templates文件夹添加模板

1万+

CAS SSO 登录时报错: org.springframework.webflow.execution.ActionExecutionException: Exception thrown exec

org.springframework.webflow.execution.ActionExecutionException: Exception thrown executing [AnnotatedAction@23dcf889 targetAction = [EvaluateAction@40fcc4 expression = authenticationViaFormAction.subm

whyzh的专栏 9325

自回归分布滞后模型 (ARDL)及 Stata 具体操作步骤

例如,Bahmani-Oskooee 和 Brooks(1999)研究了汇率波动与贸易收支之间的关系,发现汇率的变动在长期和短期内对贸易收支的影响存在差异,ARDL 模型能够有效地捕捉这种复杂的关系。它结合了自回归(Autoregressive,AR)模型和分布滞后(Distributed Lag,DL)模型的特点,能够同时考察变量之间的短期和长期关系。假设我们收集了一段时间内的居民消费和可支配收入数据,通过对这些数据进行分析和估计,可以得到模型的参数估计值,从而揭示消费与收入之间的短期和长期关系。

a519573917的博客 6093

WPS用户看过来:避开格式错乱坑,用WPS Office完美制作红头文件(2024最新版)

本文详细解析了WPS Office与Word在红头文件制作中的核心差异,提供了2024年最新版的零误差实战指南。从字体处理、页面布局到红头制作关键步骤,帮助用户避开格式错乱坑,确保跨设备显示一致。特别针对WPS用户优化,解决字体丢失、版式错位等常见问题。

weixin_26800111的博客 217

cas5.3.2单点登录-服务端集成shiro权限认证(五)

原文地址,转载请注明出处:&amp;amp;amp;amp;nbsp;https://blog.csdn.net/qq_34021712/article/details/81149019&amp;amp;amp;amp;nbsp;&amp;amp;amp;amp;nbsp; &amp;amp;amp;amp;nbsp;&amp;amp;amp;amp;nbsp;©王赛超&amp;amp;amp;amp;nbsp; 所谓单点登录(SSO),只当企业用户同时访问

这个名字想了很久 1万+

协方差矩阵

对两个类内协方差矩阵进行对角化,可以将它们变换为对角矩阵。这个过程可以通过对每个协方差矩阵进行特征值分解来实现,从而得到它们的特征向量和特征值,进而得到它们的对角矩阵形式。这个过程的意义在于,它可以帮助我们找到一个新的坐标系,使得在这个坐标系下,每个特征之间都是独立的,从而简化了计算。具体来说,当我们使用对角协方差矩阵作为特征向量的坐标系时,它意味着每个特征之间都是相互独立的,从而方便了进一步的分析和处理。在实际应用中,对角化协方差矩阵可以用于降维、特征选择和分类等任务。

m0_55196097的博客 1万+

CAS4认证成功后不管有没有service参数,都进入指定页面

使用CAS4实现单点登录后,还要求无论请求的service是什么,都跳转到固定的URL上。 分析登录成功后springmvc的流程是怎么做的,应该就能实现上述目的。所以,就开始了辛苦的源代码跟踪和阅读之旅。 首先想到的就是从login-webflow.xml开始看看登录的流转过程,也幸好是先看了这个文件,很快就寻找到了处置办法。因为当没有service参数时,CAS4进入登录认证成功提示页面,

ZHH309的专栏 4903

Silvaco TCAD 2018安装后,如何配置TonyPlot 5.0.22.R并解决绘图报错?

本文详细介绍了在Windows系统上安装Silvaco TCAD 2018后,如何正确配置TonyPlot 5.0.22.R并解决常见的绘图报错问题。内容包括版本兼容性分析、环境变量设置、常见错误解决方案以及性能优化建议,帮助用户顺利完成仿真结果的可视化工作。

weixin_31031711的博客 420

CMAC算法原理

2、K1 通过以下运算导出:若 L 的最高有效位等于 0,则 K1 是 L 的左移 1 位。3、K2 通过如下运算导出:若 K1 的最高有效位等于 0,则 K2 是 K1 的左移 1 位。采用了 AES 算法中的类似 CBC 模式的加密方式,即对前一个分组的密文与当前分组的明文进行异或操作后在加密,2、分块处理:首先将消息分成多个固定长度的块,若消息长度不是块大小的倍数,则可以使用填充来将其填充到合适的大小。1、子密钥计算,通过主密钥生成子密钥(key1,key2),子密钥用于最后一个块处理;

sky的博客 1658

Apereo CAS 5.0.X JPA Service Registry

Apereo CAS 5.0.X中默认提供了以下集中service信息存储方式。 1. CouchbaseServiceRegistryDao 2. InMemoryServiceRegistryDaoImpl 3. JpaServiceRegistryDaoImpl 4. LdapServiceRegistryDao 5. MongoServiceRegistryDao 6. Embe

来啊 快活啊 6663

大疆前端开发面试题及参考答案(4万字长文)

在前端项目中,难点和性能优化的挑战无处不在。比如在处理复杂交互界面时,实现流畅的动画效果和实时反馈就是一大难点。当界面中有大量元素需要同时进行交互和动态更新,像电商平台的商品筛选和排序功能,不仅要保证操作的即时响应,还要确保界面在各种设备和网络环境下的稳定性,这就需要对事件处理、DOM 操作和数据更新机制有深入理解。在性能优化方面,首屏加载速度是常见的难点。当页面包含大量图片、脚本和样式文件时,如何合理地进行资源压缩、合并与缓存,以减少加载时间,是需要精心考虑的。

大模型大数据攻城狮的专栏 1155

Springboot 集成 Shiro 和 CAS 实现单点登录(服务端篇CAS5)

什么是单点登录?先说一个需求场景,比如:一个企业的内部有N多个子系统,每个子系统都有一套自己的用户名和密码,那么企业的员工要登录N个子系统,这样一个员工 就要记住N个用户名和密码,就算各个...

天行健,君子以自强不息;地势坤,君子以厚德载物。 1518

不会路由器叠加多条宽带?看这个就够了,能让你的局域网速度更快!

通常我们在企业网络或实际项目中,随着用户的增加,一条或者几条带宽不能满足正常使用,便可以对带宽进行叠加,便于网络带度更快;通常家里有可能有两条带宽的,联通或移动的,可能都是充话费送的,但网速都不怎么样,不用可惜,用之委屈,那怎么办呢?如在迅雷上开启下载,多个资源同时下载,此时总带宽可以达到120M,也就是WAN口带宽可以叠加。多wan口路由器, 一般是有2个wan口,分别为wan1与wan2。当然也有更多的wan口的。[1] 对整个局域网来说,出口带宽数量多了,相当于总带宽上升,这样是可以起到叠加效果。

qq_43416206的博客 1112

Java 类与对象 -- Java 语言的类与对象、构造器、static、final、包和 JAR

本篇文章我们将深入了解 Java 语言中的类与对象,探讨构造器、`static`、`final`、包和 JAR 文件。这些概念是面向对象编程的核心,对于理解和掌握 Java 至关重要。

栗筝i的博客 5036

CAS单点登录(十一)——单点退出

在前面我们讲解了CAS的单点登录客户端接入,对于CAS的登录有了更清楚的了解,今天我们讲解一下在CAS中的单点退出问题。 首先我们要明白单点退出(单点注销)与注销的区别: 其实官方文档也给我们详细的解释了: 注销: 1. 应用程序注销 - 结束单个应用程序会话 2. CAS注销 - 结束CAS SSO会话 请注意,在简单的情况下,每种情况下的注销操作对另一种情况都没有影响。 而单点注销(SL...

Anumbrella 1万+

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

基于CAS实现SSO单点登录

程序员的成长之路互联网/程序员/技术/资料共享关注阅读本文大概需要 4 分钟。来自:https://mp.weixin.qq.com/s/x4VAxtUm3HVllfYEabbfGA1....

良月柒 626

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain&#39;s apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath(&#39;DeepLearnToolbox&#39;));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand(&#39;state&#39;,0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W&#39;); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand(&#39;state&#39;,0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = &#39;sigm&#39;;%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, &#39;Too big error&#39;);```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand(&#39;state&#39;,0)sae = saesetup([784 100]);sae.ae{1}.activation_function = &#39;sigm&#39;;sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)&#39;)% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;;nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, &#39;Too big error&#39;);```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x&#39;,28,28,60000))/255;test_x = double(reshape(test_x&#39;,28,28,10000))/255;train_y = double(train_y&#39;);test_y = double(test_y&#39;);%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you&#39;ll get around 1.2% errorrand(&#39;state&#39;,0)cnn.layers = { struct(&#39;type&#39;, &#39;i&#39;) %input layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 6, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %sub sampling layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 12, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, &#39;Too big error&#39;);```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, &#39;Too big error&#39;);%% ex2 neural net with L2 weight decayrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex3 neural net with dropoutrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex4 neural net with sigmoid activation functionrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex5 plotting functionalityrand(&#39;state&#39;,0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = &#39;softmax&#39;; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand(&#39;state&#39;,0)nn = nnsetup([784 20 10]); nn.output = &#39;softmax&#39;; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

cas 登录之后不跳转_75. Django 集成 CAS 实现 SSO 单点登陆

需求在公司平台的开发中,由于内部平台越来越多,本次要求我们开发的平台需要同步公司的 OA 账号。那么怎么同步呢?简单来说就是采用 CAS 服务机制,实现 CAS 服务完成多应用单点登陆 功能。Django 默认的 Session + Cookie 的登陆机制image-20200909110936463在了解 CAS 单点登陆之前,先来回顾一下 Django 默认的 Session + ...

weixin_39859819的博客 436

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

CAS服务端搭建和结合Springboot搭建CAS客户端验证单点登录

1.背景介绍 什么是CAS 单点登录(SSO),在多系统之间用户只需要登录一次就可以访问所有互相信任的系统 SSO基础的访问流程: 1. 访问服务: SSO 客户端发送请求访问应用系统提供的服务资源。 2. 定向认证: SSO 客户端会重定向用户请求到 SSO 服务器。 3. 用户认证:用户身份认证。 4. 发放票据: SSO 服务器会产生一个随机的 Service Ticket 。 ...

第四纵队的博客 3129

Apereo CAS Memcached 监控指南:健康检查、配置属性与源码级实现解析

本文以 [Configuring-Monitoring-Memcached.md](https://link.gitcode.com/i/a46e63bf7359e7959c0112769a1c08a3) 为核心,系统讲解 Apereo CAS 如何监控 Memcached 缓存节点的可用性与容量状态。你将掌握:如何在 WAR overlay 中引入监控模块并选择底层实现(Spymemcached

gitblog_00949的博客 477

Spring Boot 2.x + CAS 6.x 实战:手把手教你配置一个能跑通的单点登录客户端

本文详细介绍了Spring Boot 2.x与CAS 6.x的深度整合实战,从零构建高可靠单点登录客户端。通过版本匹配、核心配置解析、过滤器链组装及常见问题排查,帮助开发者实现生产级单点登录解决方案,提升企业应用系统的安全性和用户体验。

weixin_42528191的博客 371

Apereo CAS 推送通知配置指南:接入 Google Firebase Cloud Messaging (FCM)

通过 Google Firebase Cloud Messaging 向用户移动设备发送推送通知,是 Apereo CAS 通知体系(Notifications)中面向移动端的核心能力。本文以仓库中 [Notifications - Google Firebase Cloud Messaging](https://link.gitcode.com/i/004e97f294e0b7c183b243f

gitblog_00803的博客 1036

iTop CAS 单点登录(SSO)集成实战:authent-cas 扩展配置、登录状态机与用户自动供应解析

> 本文以仓库内 [authent-cas/README.md](https://link.gitcode.com/i/16c6652783749d90cfa37c9ba8ea790b) 为核心骨架,结合 `authent-cas` 模块源码([CASLoginExtension.php](https://link.gitcode.com/i/9966a933bbc07472873f6b7db22

gitblog_00560的博客 416

CAS单点登录部署实战:从原理到跳转配置全解析

单点登录(SSO)是现代企业身份管理的核心技术,旨在解决多系统间重复登录的痛点。其核心原理是通过一个独立的认证中心统一管理用户凭证,用户只需登录一次即可访问所有互信应用,从而提升用户体验并统一安全策略。在技术实现上,CAS(Central Authentication Service)协议是构建SSO系统的流行方案,它定义了认证服务器、客户端应用与浏览器之间的标准交互流程。对于开发者和运维人员而言,CAS的价值在于提供了可扩展、安全的统一认证基础设施,尤其适用于整合OA、CRM、知识库等内部系统。然而,在实

weixin_30463341的博客 469
上一篇: CentOS7 部署Tomcat
下一篇: CAS5.3X 之配置RememberMe & Cookie Secure属性影响
Jeffery Chan
博客等级 码龄10年 24粉丝 15原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值