SSO英文全称Single Sign On,单点登录。SSO是在多个应用系统中,用户只需要登录一次就可以访问所有相互信任的应用系统。它包括可以将这次主要的登录映射到其他应用中用于同一个用户的登录的机制。它是目前比较流行的企业业务整合的解决方案之一。
此方式在只有一个web工程时是没有问题。
集群环境下会出现要求用户多次登录的情况。
解决方案:
单点登录系统是使用redis模拟Session,实现Session的统一管理。
需要创建一个sso服务工程,可以参考taotao-manager创建。
Taotao-sso(pom聚合工程)
|--taotao-sso-interface(jar)
|--taotao-sso-Service(war)
可以参考taotao-manager创建
<projectxmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0modelVersion> <parent> <groupId>com.taotaogroupId> <artifactId>taotao-parentartifactId> <version>0.0.1-SNAPSHOTversion> parent> <groupId>com.taotaogroupId> <artifactId>taotao-ssoartifactId> <version>0.0.1-SNAPSHOTversion> <packaging>pompackaging> <dependencies> <dependency> dependency> dependencies>
<build> <plugins> <plugin> <groupId>org.apache.tomcat.mavengroupId> <artifactId>tomcat7-maven-pluginartifactId> <configuration> <port>8087port> <path>/path> configuration> plugin> plugins> build> project> |
<projectxmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0modelVersion> <parent> <groupId>com.taotaogroupId> <artifactId>taotao-ssoartifactId> <version>0.0.1-SNAPSHOTversion> parent> <artifactId>taotao-sso-serviceartifactId> <packaging>warpackaging> <dependencies> <dependency> <groupId>com.taotaogroupId> <artifactId>taotao-manager-daoartifactId> <version>0.0.1-SNAPSHOTversion> dependency> <dependency> <groupId>com.taotaogroupId> <artifactId>taotao-sso-interfaceartifactId> <version>0.0.1-SNAPSHOTversion> dependency>
<dependency> <groupId>org.springframeworkgroupId> <artifactId>spring-contextartifactId> dependency> <dependency> <groupId>org.springframeworkgroupId> <artifactId>spring-beansartifactId> dependency> <dependency> <groupId>org.springframeworkgroupId> <artifactId>spring-webmvcartifactId> dependency> <dependency> <groupId>org.springframeworkgroupId> <artifactId>spring-jdbcartifactId> dependency> <dependency> <groupId>org.springframeworkgroupId> <artifactId>spring-aspectsartifactId> dependency> <dependency> <groupId>org.springframeworkgroupId> <artifactId>spring-jmsartifactId> dependency> <dependency> <groupId>org.springframeworkgroupId> <artifactId>spring-context-supportartifactId> dependency>
<dependency> <groupId>com.alibabagroupId> <artifactId>dubboartifactId>
<exclusions> <exclusion> <groupId>org.springframeworkgroupId> <artifactId>springartifactId> exclusion> <exclusion> <groupId>org.jboss.nettygroupId> <artifactId>nettyartifactId> exclusion> exclusions> dependency> <dependency> <groupId>org.apache.zookeepergroupId> <artifactId>zookeeperartifactId> dependency> <dependency> <groupId>com.github.sgroschupfgroupId> <artifactId>zkclientartifactId> dependency>
<dependency> <groupId>redis.clientsgroupId> <artifactId>jedisartifactId> dependency> dependencies> project> |
表现层工程包含登录和注册页面,需要调用sso服务实现。
给app提供服务,restful形式的服务。
Taotao-sso-web(war包)
可以参考taotao-manager-web创建。
<projectxmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0modelVersion> <parent> <groupId>com.taotaogroupId> <artifactId>taotao-parentartifactId> <version>0.0.1-SNAPSHOTversion> parent> <groupId>com.taotaogroupId> <artifactId>taotao-sso-webartifactId> <version>0.0.1-SNAPSHOTversion> <packaging>warpackaging> <dependencies> <dependency> <groupId>com.taotaogroupId> <artifactId>taotao-sso-interfaceartifactId> <version>0.0.1-SNAPSHOTversion> dependency>
<dependency> <groupId>org.springframeworkgroupId> <artifactId>spring-contextartifactId> dependency> <dependency> <groupId>org.springframeworkgroupId> <artifactId>spring-beansartifactId> dependency> <dependency> <groupId>org.springframeworkgroupId> <artifactId>spring-webmvcartifactId> dependency> <dependency> <groupId>org.springframeworkgroupId> <artifactId>spring-jdbcartifactId> dependency> <dependency> <groupId>org.springframeworkgroupId> <artifactId>spring-aspectsartifactId> dependency> <dependency> <groupId>org.springframeworkgroupId> <artifactId>spring-jmsartifactId> dependency> <dependency> <groupId>org.springframeworkgroupId> <artifactId>spring-context-supportartifactId> dependency>
<dependency> <groupId>jstlgroupId> <artifactId>jstlartifactId> dependency> <dependency> <groupId>javax.servletgroupId> <artifactId>servlet-apiartifactId> <scope>providedscope> dependency> <dependency> <groupId>javax.servletgroupId> <artifactId>jsp-apiartifactId> <scope>providedscope> dependency>
<dependency> <groupId>com.alibabagroupId> <artifactId>dubboartifactId>
<exclusions> <exclusion> <groupId>org.springframeworkgroupId> <artifactId>springartifactId> exclusion> <exclusion> <groupId>org.jboss.nettygroupId> <artifactId>nettyartifactId> exclusion> exclusions> dependency> <dependency> <groupId>org.apache.zookeepergroupId> <artifactId>zookeeperartifactId> dependency> <dependency> <groupId>com.github.sgroschupfgroupId> <artifactId>zkclientartifactId> dependency> <dependency> <groupId>junitgroupId> <artifactId>junitartifactId> dependency> dependencies>
<build> <plugins> <plugin> <groupId>org.apache.tomcat.mavengroupId> <artifactId>tomcat7-maven-pluginartifactId> <configuration> <port>8088port> <path>/path> configuration> plugin> plugins> build> project> |