Monday, August 2, 2021

單點登錄APP

製作單點登錄服務器

文章內容來源為︰https://www.wolfcode.cn/new/portal/listPage.html?id=121

經過重新整理寫到這邊,如看原作者有更多介紹及解釋,這邊直接列出需要的執行指令搭建SSO服務器。好了,開始!

首先到github下載服務器代碼︰https://github.com/javalanxiongwei/sso-server-base-project

到github下載客戶端代碼︰https://github.com/javalanxiongwei/sso-client-base-project

進入到兩個eclipse目錄中,用cmd分別執行︰

            mvn eclipse:eclipse

然後就可以在eclipse使用import 導入。

由於server 原代碼漏了getter及setter,所以需要補充至ClientInfoVo.java

在兩個目錄的pom.xml加入jre的運行目錄︰

        <plugin>

            <artifactId>maven-compiler-plugin</artifactId>

            <version>3.1</version>

            <configuration>

                <fork>true</fork>

                <executable>C:\Program Files\Java\jre1.8.0_271\bin\javac.exe</executable>

            </configuration>

        </plugin>

將client目錄中的sso.properties內容改回為︰

            server-url-prefix=http://localhost:8443

            client-host-url=http://localhost:8088

然後分別在client及server使用cmd執行下面指令︰

            mvn update

            mvn tomcat7:run

成功後會看到兩個terminal顯示︰

            Starting ProtocolHandler ["http-bio-8088"]

            Starting ProtocolHandler ["http-bio-8443"]

            表示運行成功

接著就可以在瀏覽器中試運行︰http://localhost:8088/main

默認賬戶zhangsan,密碼666

基本的SSO服務器就建設好了,詳細解釋請到原作者查看。

No comments: