Vagi单点登录1.0

Vagi是一款基于CAS(CAS v4)的Web应用单点登录系统.(cas web https://github.com/Jasig/cas)

  • 对数据库用户存储支持
  • 加入登录验证码
  • 新浪微博和QQ互联的支持
  • 历史登录日志
  • 记住登录username
  • 记住登录

基于CAS v4.0.2

project地址:https://github.com/shimingxy/Vagi

群434469201

登录界面

mahua

部署

1、安装Mysql 5.6,创建vagi schema ,把Vagi_mysql.sql导入到vagi中。
用户表

CREATE TABLE `userinfo` ( `ID` varchar(45) NOT NULL, `USERNAME` varchar(100) NOT NULL, `PASSWORD` varchar(200) NOT NULL, `DISPLAYNAME` varchar(45) DEFAULT NULL, `BADPASSWORDCOUNT` smallint(5) unsigned DEFAULT '0', `BADPASSWORDTIME` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', `PASSWORDLASTSETTIME` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '??', `UNLOCKTIME` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', `ISLOCKED` tinyint(3) unsigned DEFAULT NULL, `LASTLOGINTIME` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '??

', `LASTLOGOFFTIME` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '??', `LOGINCOUNT` int(10) unsigned DEFAULT '0', `LASTLOGINIP` varchar(45) DEFAULT NULL, `STATUS` tinyint(3) unsigned DEFAULT '1', PRIMARY KEY (`ID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='?';

登录日志表

CREATE TABLE `login_history` (

`ID` varchar(45) NOT NULL COMMENT '主键', `USERNAME` varchar(200) NOT NULL COMMENT '登录名', `DISPLAYNAME` varchar(45) DEFAULT NULL COMMENT '姓名', `MESSAGE` varchar(200) DEFAULT NULL COMMENT '消息', `SOURCEIP` varchar(45) DEFAULT NULL COMMENT '操作IP', `LOGINTIME` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '认证时间', `LOGINTYPE` varchar(45) DEFAULT NULL COMMENT '类型', `UID` varchar(45) NOT NULL COMMENT '用户ID', `CODE` varchar(45) DEFAULT NULL COMMENT '编码', `PROVIDER` varchar(45) DEFAULT NULL COMMENT '第三方', `SESSIONID` varchar(45) DEFAULT NULL COMMENT '会话', `BROWSER` varchar(45) DEFAULT NULL COMMENT '浏览器版本号', `PLATFORM` varchar(45) DEFAULT NULL COMMENT '平台', `APPLICATION` varchar(45) DEFAULT NULL COMMENT '应用程序', `LOGINURL` varchar(450) DEFAULT NULL COMMENT '登录URL', `LOGOUTTIME` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '登出时间', PRIMARY KEY (`ID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='登录日志表';

第三方登录表

CREATE TABLE `socialsignon_users_token` ( `ID` varchar(45) NOT NULL, `UID` varchar(45) NOT NULL COMMENT '用户id', `PROVIDER` varchar(45) NOT NULL COMMENT '第三方提供商', `SOCIALUSERINFO` text NOT NULL COMMENT '''第三方应用的用户信息''', `SOCIALUID` varchar(100) NOT NULL COMMENT '''第三方应用的用户id''', `EXATTRIBUTE` text, `ACCESSTOKEN` text, `CREATEDDATE` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `UPDATEDDATE` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', `USERNAME` varchar(45) NOT NULL, PRIMARY KEY (`ID`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户和第三方认证提供商的绑定关系';

2、安装TomCat 7.x,配置JDK 7,port号配置为80

tomcat/conf/server.xml

<Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />


3、vagiproject部署到TomCat

vagi连接数据库配置/vagi/WEB-INF/cas.properties

############################################################################ # DataBase configuration ############################################################################ # JDBC Driver # for MySql com.mysql.jdbc.Driver # for oracle oracle.jdbc.driver.OracleDriver # for DB2 com.ibm.db2.jdbc.app.DB2Driver # for SqlServer com.microsoft.jdbc.sqlserver.SQLServerDriver # for SyBase com.sybase.jdbc.SybDriver # for PostgreSQL org.postgresql.Driver config.datasource.driverclass=com.mysql.jdbc.Driver # JDBC URL # you need database hostname,port,databasename # for MySql jdbc:mysql://hostname:port/databasename # for oracle jdbc:oracle:thin:@hostname:port:databasename # for DB2 jdbc:db2://hostname:port/databasename # for SqlServer jdbc:microsoft:sqlserver://hostname:port;DatabaseName=databasename # for SyBase jdbc:sybase:Tds:hostname:port/databasename # config.datasource.url=jdbc:mysql://localhost/vagi?autoReconnect=true&characterEncoding=UTF-8 config.datasource.username=root #connsec config.datasource.password=connsec

以上參数请依据实际情况配置


4、微博、QQ登录互联配置

   配置/vagi/WEB-INF/cas.properties

############################################################################ # Social Sign On Configuration # #you config client.id & client.secret only ############################################################################ ############################################################################ #sina weibo config.socialsignon.sinaweibo.provider=sinaweibo config.socialsignon.sinaweibo.provider.name=\u65B0\u6D6A\u5FAE\u535A config.socialsignon.sinaweibo.icon=images/social/sinaweibo.png config.socialsignon.sinaweibo.client.id=1396991563 config.socialsignon.sinaweibo.client.secret=0e2175bf497817466b0b7d0eefb10f57 config.socialsignon.sinaweibo.authorize.url=https://api.weibo.com/oauth2/authorize?client_id=%s&redirect_uri=%s&response_type=code config.socialsignon.sinaweibo.accesstoken.url=https://api.weibo.com/oauth2/access_token config.socialsignon.sinaweibo.accesstoken.method=POST config.socialsignon.sinaweibo.scope=all config.socialsignon.sinaweibo.verifier.code=code config.socialsignon.sinaweibo.account.url=https://api.weibo.com/2/users/show.json config.socialsignon.sinaweibo.account.id=id config.socialsignon.sinaweibo.sortorder=1 #QQ config.socialsignon.qq.provider=qq config.socialsignon.qq.provider.name=QQ config.socialsignon.qq.icon=images/social/qq.png config.socialsignon.qq.client.id=101225363 config.socialsignon.qq.client.secret=8577d75e0eb4a91ac549cc8be3371bfd config.socialsignon.qq.authorize.url=https://graph.qq.com/oauth2.0/authorize?

client_id=%s&redirect_uri=%s&response_type=code config.socialsignon.qq.accesstoken.url=https://graph.qq.com/oauth2.0/token config.socialsignon.qq.accesstoken.method=POST config.socialsignon.qq.scope=read config.socialsignon.qq.verifier.code=code config.socialsignon.qq.account.url=https://graph.qq.com/oauth2.0/me config.socialsignon.qq.account.id=openid config.socialsignon.qq.sortorder=2

微博配置

config.socialsignon.sinaweibo.client.id=

config.socialsignon.sinaweibo.client.secret=

QQ配置

config.socialsignon.qq.client.id=

config.socialsignon.qq.client.secret=

5、配置hosts

127.0.0.1 sso.connsec.com

6、訪问

   http://sso.connsec.com/vagi



License & Copyright

Apache License, Version 2.0.

posted on 2015-12-20 12:21  gcczhongduan  阅读(284)  评论(0编辑  收藏  举报