[SSO single-point series] (2): Custom CAS logon page, ssocas

Source: Internet
Author: User

[SSO single-point series] (2): Custom CAS logon page, ssocas

 

The previous [SSO single point series] (1): the setup of the CAS environment introduces the setup of the simplest CAS environment, and an example is used to explain a basic usage of CAS. Today, we will introduce how to customize the CAS logon page.

I. Start

It is the default logon interface of CAS. You can see that this interface cannot be directly used in the production environment, because there are many English letters on it. In short, this is a very unfriendly interface for customers. So how can we modify it? Let's look down!

Ps: the address of this page in the project is cas \ WEB-INF \ view \ jsp \ default \ ui \ casLoginView. jsp, you can open a look.

  

2. modify the configuration file

In fact, all CAS interface locations are specified in cas. properties (specific location: cas \ WEB-INF \ cas. properties. Open this file and find the following line.

 

Cas. securityContext. status. allowedSubnet = 127.0.0.1cas.themeResolver.defaultThemeName = cas-theme-default // pay attention to the following line of cas. viewResolver. basename = default_views

 

 

Look at the key-Value Pair cas. viewResolver. basename. Its value is default_views, indicating the default view configuration, which is actually the name of a properties file. Check whether there is a file named default_views.properties (specific location: cas \ WEB-INF \ classes \ default_views.properties) in the project, the specific content of the file is as follows:

 

CasLoginView. (class) = org. springframework. web. servlet. view. jstlViewcasLoginView. url =/WEB-INF/view/jsp/default/ui/casLoginView. jsp ### Display login (warning) messagescasLoginMessageView. (class) = org. springframework. web. servlet. view. jstlViewcasLoginMessageView. url =/WEB-INF/view/jsp/default/ui/casLoginMessageView. jsp ### Login confirmation view (logged in, warn = true) casLoginConfirmView. (class) = org. springframework. web. servlet. view. jstlViewcasLoginConfirmView. url =/WEB-INF/view/jsp/default/ui/casConfirmView. jsp ### Logged-in view (logged in, no service provided) casLoginGenericSuccessView. (class) = org. springframework. web. servlet. view. jstlViewcasLoginGenericSuccessView. url =/WEB-INF/view/jsp/default/ui/casGenericSuccess. jsp ### Logout view (/logout) casLogoutView. (class) = org. springframework. web. servlet. view. jstlViewcasLogoutView. url =/WEB-INF/view/jsp/default/ui/casLogoutView. jsp // omitted

 

We can see that our logon page is configured above, and the logon success page and exit page are also configured, which will be described later.

After we know the page configuration, can we customize a set of pages based on the business.

 

1. Modify cas. viewResolver. basename in cas. properties to bokeyuan_view, and the system will automatically find the configuration file bokeyuan_view.properties.

2. The bokeyuan_view.properties found at is unavailable. We need to create a new one and copy the original default_views.properties directly, and rename it bokeyuan_view.properties.

3. But the address in bokeyuan_view.properties is/WEB-INF/view/jsp/default, we replace this address with the WEB-INF \ view \ jsp \ bokeyuan

4. Next we copy all the files under cas \ WEB-INF \ view \ jsp \ default and rename it to the name we need, cas \ WEB-INF \ view \ jsp \ bokeyuan

5. Now we can modify the logon interface at will.

Ps: Some people say that directly modify the original cas \ WEB-INF \ view \ jsp \ default \ ui \ casLoginView. jsp on the line, save trouble. In fact, this is also a line, but if you need the initial interface later, it will be gone.

The Configuration modification method is more flexible, and the original backup can be retained.

Pps: The jquery library in the login interface is configured in cas \ WEB-INF \ view \ jsp \ default \ ui \ mongodes \ bottom. in jsp, but this is directly referenced by googleapis. We cannot access it. We need to change it to your local or accessible CDN Library (Baidu CDN, 360CDN, etc)

Ppps: you can modify the original interface at will, but the original logic cannot be modified. In fact, the main reason is that the content in the form: form label should not be changed. You must modify the style.

 

Iii. Summary

In this way, we can customize our logon interface as needed.

The original interface only contains two forms: name and password. You may want to add a verification code to it,Add Verification CodeWe will introduce it in the next article, so stay tuned!

 

 

Okay, close the job!

 

 

 

  

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.