Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
apollo
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
openSource
apollo
Commits
083ed49b
Commit
083ed49b
authored
Jun 24, 2016
by
张乐
Committed by
GitHub
Jun 24, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #289 from nobodyiam/sso-auto-login
add mechanism to keep sso auto login
parents
bf5dd4cc
e7830312
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
41 additions
and
13 deletions
+41
-13
WebSecurityConfig.java
...ctrip/framework/apollo/common/auth/WebSecurityConfig.java
+1
-0
pom.xml
apollo-portal/pom.xml
+2
-2
CtripLogoutHandler.java
...trip/framework/apollo/portal/auth/CtripLogoutHandler.java
+5
-1
AuthConfiguration.java
...mework/apollo/portal/configutation/AuthConfiguration.java
+6
-2
AppUtils.js
apollo-portal/src/main/resources/static/scripts/AppUtils.js
+1
-1
sso_heartbeat.html
apollo-portal/src/main/resources/static/sso_heartbeat.html
+22
-0
footer.html
...portal/src/main/resources/static/views/common/footer.html
+1
-4
pom.xml
pom.xml
+3
-3
No files found.
apollo-common/src/main/java/com/ctrip/framework/apollo/common/auth/WebSecurityConfig.java
View file @
083ed49b
...
...
@@ -17,6 +17,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
protected
void
configure
(
HttpSecurity
http
)
throws
Exception
{
http
.
httpBasic
();
http
.
csrf
().
disable
();
http
.
headers
().
frameOptions
().
sameOrigin
();
}
@Autowired
...
...
apollo-portal/pom.xml
View file @
083ed49b
...
...
@@ -66,8 +66,8 @@
</properties>
<dependencies>
<dependency>
<groupId>
org.jasig.cas.client
</groupId>
<artifactId>
cas-client-core-infosec-credis
</artifactId>
<groupId>
com.ctrip.framework.apollo-sso
</groupId>
<artifactId>
apollo-sso-ctrip
</artifactId>
</dependency>
</dependencies>
</profile>
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/auth/CtripLogoutHandler.java
View file @
083ed49b
...
...
@@ -9,6 +9,7 @@ import java.io.IOException;
import
javax.servlet.http.Cookie
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpSession
;
public
class
CtripLogoutHandler
implements
LogoutHandler
{
...
...
@@ -18,7 +19,10 @@ public class CtripLogoutHandler implements LogoutHandler{
@Override
public
void
logout
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
//将session销毁
request
.
getSession
().
invalidate
();
HttpSession
session
=
request
.
getSession
(
false
);
if
(
session
!=
null
)
{
session
.
invalidate
();
}
Cookie
cookie
=
new
Cookie
(
"memCacheAssertionID"
,
null
);
//将cookie的有效期设置为0,命令浏览器删除该cookie
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/configutation/AuthConfiguration.java
View file @
083ed49b
...
...
@@ -73,9 +73,11 @@ public class AuthConfiguration {
filterInitParam
.
put
(
"redisClusterName"
,
"casClientPrincipal"
);
filterInitParam
.
put
(
"serverName"
,
serverConfigService
.
getValue
(
"serverName"
));
filterInitParam
.
put
(
"casServerLoginUrl"
,
serverConfigService
.
getValue
(
"casServerLoginUrl"
));
//we don't want to use session to store login information, since we will be deployed to a cluster, not a single instance
filterInitParam
.
put
(
"useSession"
,
"false"
);
casFilter
.
setInitParameters
(
filterInitParam
);
casFilter
.
setFilter
(
filter
(
"
org.jasig.cas.client.authentication.
AuthenticationFilter"
));
casFilter
.
setFilter
(
filter
(
"
com.ctrip.framework.apollo.sso.filter.Apollo
AuthenticationFilter"
));
casFilter
.
addUrlPatterns
(
"/*"
);
return
casFilter
;
...
...
@@ -88,6 +90,8 @@ public class AuthConfiguration {
filterInitParam
.
put
(
"casServerUrlPrefix"
,
serverConfigService
.
getValue
(
"casServerUrlPrefix"
));
filterInitParam
.
put
(
"serverName"
,
serverConfigService
.
getValue
(
"serverName"
));
filterInitParam
.
put
(
"encoding"
,
"UTF-8"
);
//we don't want to use session to store login information, since we will be deployed to a cluster, not a single instance
filterInitParam
.
put
(
"useSession"
,
"false"
);
filterInitParam
.
put
(
"useRedis"
,
"true"
);
filterInitParam
.
put
(
"redisClusterName"
,
"casClientPrincipal"
);
...
...
@@ -105,7 +109,7 @@ public class AuthConfiguration {
public
FilterRegistrationBean
assertionHolder
(){
FilterRegistrationBean
assertionHolderFilter
=
new
FilterRegistrationBean
();
assertionHolderFilter
.
setFilter
(
filter
(
"
org.jasig.cas.client.util.
AssertionThreadLocalFilter"
));
assertionHolderFilter
.
setFilter
(
filter
(
"
com.ctrip.framework.apollo.sso.filter.Apollo
AssertionThreadLocalFilter"
));
assertionHolderFilter
.
addUrlPatterns
(
"/*"
);
return
assertionHolderFilter
;
...
...
apollo-portal/src/main/resources/static/scripts/AppUtils.js
View file @
083ed49b
...
...
@@ -3,7 +3,7 @@ appUtil.service('AppUtil', ['toastr', function (toastr) {
return
{
errorMsg
:
function
(
response
)
{
if
(
response
.
status
==
-
1
)
{
return
"您的登录信息已过期,请
重新登录
"
;
return
"您的登录信息已过期,请
刷新页面后重试
"
;
}
var
msg
=
"Code:"
+
response
.
status
;
if
(
response
.
data
.
message
!=
null
)
{
...
...
apollo-portal/src/main/resources/static/sso_heartbeat.html
0 → 100644
View file @
083ed49b
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
SSO Heartbeat
</title>
<script
type=
"text/javascript"
>
var
reloading
=
false
;
setInterval
(
function
()
{
if
(
document
.
cookie
.
indexOf
(
'memCacheAssertionID='
)
==
-
1
)
{
if
(
reloading
)
{
return
;
}
reloading
=
true
;
console
.
log
(
"sso memCacheAssertionID expires, try reloading"
);
location
.
reload
(
true
);
}
},
1000
);
</script>
</head>
<body>
</body>
</html>
apollo-portal/src/main/resources/static/views/common/footer.html
View file @
083ed49b
...
...
@@ -5,7 +5,4 @@
<a
href=
"http://conf.ctripcorp.com/display/FRAM/Apollo"
target=
"_blank"
>
wiki
</a>
</p>
</div>
<iframe
src=
"/sso_heartbeat.html"
class=
"hide"
></iframe>
pom.xml
View file @
083ed49b
...
...
@@ -177,9 +177,9 @@
</exclusions>
</dependency>
<dependency>
<groupId>
org.jasig.cas.client
</groupId>
<artifactId>
cas-client-core-infosec-credis
</artifactId>
<version>
3.1.12
</version>
<groupId>
com.ctrip.framework.apollo-sso
</groupId>
<artifactId>
apollo-sso-ctrip
</artifactId>
<version>
1.0.0
</version>
</dependency>
<!--third party -->
<dependency>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment