简体   繁体   English

如何使用angular2 webpack starter typescript进行CAS身份验证?

[英]How to use CAS authentication with angular2 webpack starter typescript?

I am using the following: 我使用以下内容:

https://github.com/gdi2290/angular-starter

I start the application with npm start that uses webpack dev server. 我用npm start启动应用npm start ,使用webpack dev服务器。 My issue is I want to add CAS authentication, but have no idea where what goes. 我的问题是我想添加CAS身份验证,但不知道发生了什么。 This is the library I am trying to use: 这是我想要使用的库:

https://github.com/TencentWSRD/connect-cas2

All the examples appear to use express, though I am not sure if I can use this with the webpack-dev-server as is with the starter I am using? 所有的例子似乎都使用了express,虽然我不确定我是否可以在webpack-dev-server中使用它和我正在使用的启动器一样? If so, how do I use it? 如果是这样,我该如何使用它? Or do I need a different CAS library that is compatible with the npm start? 或者我需要一个与npm start兼容的不同CAS库吗?

Webpack is more of a build tool with minimal server capability. Webpack更像是一种具有最小服务器功能的构建工具。 It can serve static content making it perfect for updating content on the fly and put together simple websites with basic routing and client side side logic. 它可以提供静态内容,使其非常适合动态更新内容,并将具有基本路由和客户端侧逻辑的简单网站组合在一起。

If you want anything even a little more complex you will need a server side technology. 如果您想要任何更复杂的东西,您将需要服务器端技术。 So the connect-cas2 will require you to use node.js and express. 所以connect-cas2将要求你使用node.js和express。 The documentation shows you exactly how to set it up. 文档向您展示了如何设置它。

I don't know anything about connect-cas2 but I know passport for authentication, but they wouldn't be terribly different. 我对connect-cas2一无所知,但我知道身份验证的护照,但它们不会完全不同。 I would follow the quick start and if you have any issues then edit your question with the code that you are having issues with or have trouble understanding. 我会按照快速入门,如果您有任何问题,请使用您遇到问题或难以理解的代码编辑您的问题。

I have been digging around and you might be able to proxy the authentication if you already have a CAS server setup somewhere. 我一直在挖掘,如果你已经在某处设置了CAS服务器,你可以代理身份验证。 I would try the following: 我会尝试以下方法:

// the proxy option is part of the devServer in your webpack.config.js
devServer: {
    contentBase: 'public',

    // setup a proxy
    proxy: {
        // just replace the /cas/validate endpoint to the endpoint in your 
        // website that will trigger the api call
        '/cas/validate': 'https://url-to-your-cas-server.com'
    }
},

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM