Skip to content

Commit e637ff4

Browse files
committed
Rewrite 400s templates with the flowless layout and header
HTTP 400 errors are not expected during normal authentication and authorization flow between OSF CAS and OSF. Sometimes they do not trigger login or logout flow init and are handled and routed to built-in templates directly by Tomcat. This unfortunately breaks OSF CAS customized fragment templates that relies on web flow init. The fix is to use a flowless layout and header, then replace the no-service "/login?" href with one with "errorSource=4XX" as query param so that the pre-login check action can handle.
1 parent 1daafea commit e637ff4

7 files changed

Lines changed: 148 additions & 58 deletions

File tree

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
<!DOCTYPE html>
2-
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{layout}">
2+
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{layoutFlowless}">
33

44
<head>
55
<meta charset="UTF-8">
66
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
77
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
8-
98
<title th:text="#{screen.error.page.title.accessdenied}">Error - 401</title>
10-
<link href="../../static/css/cas.css" rel="stylesheet" th:remove="tag" />
9+
<link href="../../static/css/cas.css" rel="stylesheet" th:remove="tag"/>
1110
</head>
1211

1312
<body>
14-
<main role="main" class="container mt-3 mb-3">
15-
<div layout:fragment="content" class="mdc-card p-4 w-lg-66 m-auto">
16-
<h2 th:utext="#{screen.error.page.accessdenied}">Access Denied</h2>
17-
<p th:utext="#{screen.error.page.permissiondenied}">You do not have permission to view this page.</p>
18-
<a class="mdc-button mdc-button-raised" th:href="@{/login}">
19-
<span class="mdc-button__label" th:utext="#{screen.error.page.loginagain}">Login Again</span>
20-
</a>
21-
</div>
22-
</main>
13+
<main role="main" class="container mt-3 mb-3">
14+
<div layout:fragment="content" class="mdc-card p-4 w-lg-66 m-auto">
15+
<h2 th:utext="#{screen.error.page.accessdenied}">Access Denied</h2>
16+
<p th:utext="#{screen.error.page.permissiondenied}">You do not have permission to view this page.</p>
17+
<a class="mdc-button mdc-button-raised" th:href="@{/login(errorSource=401)}">
18+
<span class="mdc-button__label" th:utext="#{screen.error.page.loginagain}">Login Again</span>
19+
</a>
20+
</div>
21+
</main>
2322
</body>
23+
2424
</html>
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
<!DOCTYPE html>
2-
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{layout}">
2+
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{layoutFlowless}">
33

44
<head>
55
<meta charset="UTF-8">
66
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
77
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
8-
98
<title th:text="#{screen.error.page.title.permissiondenied}">Error - Permission Denied</title>
10-
<link href="../../static/css/cas.css" rel="stylesheet" th:remove="tag" />
9+
<link href="../../static/css/cas.css" rel="stylesheet" th:remove="tag"/>
1110
</head>
1211

1312
<body>
14-
<main role="main" class="container mt-3 mb-3">
15-
<div layout:fragment="content" class="mdc-card p-4 w-lg-66 m-auto">
16-
<h2 th:utext="#{screen.error.page.authdenied}">Authorization Denied</h2>
17-
<p th:utext="#{screen.error.page.permissiondenied}">You do not have permission to view this page.</p>
18-
<a class="mdc-button" th:href="@{/login}">
19-
<span class="mdc-button__label" th:utext="#{screen.error.page.loginagain}">Login Again</span>
20-
</a>
21-
</div>
22-
</main>
13+
<main role="main" class="container mt-3 mb-3">
14+
<div layout:fragment="content" class="mdc-card p-4 w-lg-66 m-auto">
15+
<h2 th:utext="#{screen.error.page.authdenied}">Authorization Denied</h2>
16+
<p th:utext="#{screen.error.page.permissiondenied}">You do not have permission to view this page.</p>
17+
<a class="mdc-button" th:href="@{/login(errorSource=403)}">
18+
<span class="mdc-button__label" th:utext="#{screen.error.page.loginagain}">Login Again</span>
19+
</a>
20+
</div>
21+
</main>
2322
</body>
23+
2424
</html>
Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
11
<!DOCTYPE html>
2-
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{layout}">
2+
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{layoutFlowless}">
33

44
<head>
55
<meta charset="UTF-8">
66
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
77
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
8-
98
<title th:text="#{screen.error.page.title.pagenotfound}">Error - Page Not Found</title>
10-
<link href="../../static/css/cas.css" rel="stylesheet" th:remove="tag" />
9+
<link href="../../static/css/cas.css" rel="stylesheet" th:remove="tag"/>
1110
</head>
1211

1312
<body>
14-
<main role="main" class="container mt-3 mb-3">
15-
<div layout:fragment="content" class="mdc-card p-4 w-lg-66 m-auto">
16-
<h2 th:utext="#{screen.error.page.notfound}">Page Not Found</h2>
17-
<p th:utext="#{screen.error.page.doesnotexist}">The page you are attempting to access does not exist at the
18-
moment.</p>
19-
<a class="mdc-button" th:href="@{/login}">
20-
<span class="mdc-button__label" th:utext="#{screen.error.page.loginagain}">Login Again</span>
21-
</a>
22-
</div>
23-
</main>
13+
<main role="main" class="container mt-3 mb-3">
14+
<div layout:fragment="content" class="mdc-card p-4 w-lg-66 m-auto">
15+
<h2 th:utext="#{screen.error.page.notfound}">Page Not Found</h2>
16+
<p th:utext="#{screen.error.page.doesnotexist}">The page you are attempting to access does not exist at the moment.</p>
17+
<a class="mdc-button" th:href="@{/login(errorSource=404)}">
18+
<span class="mdc-button__label" th:utext="#{screen.error.page.loginagain}">Login Again</span>
19+
</a>
20+
</div>
21+
</main>
2422
</body>
23+
2524
</html>
Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
<!DOCTYPE html>
2-
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{layout}">
2+
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{layoutFlowless}">
33

44
<head>
55
<meta charset="UTF-8">
66
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
77
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
8-
98
<title th:text="#{screen.error.page.title.requestunsupported}">Error - Unsupported Request</title>
10-
<link href="../../static/css/cas.css" rel="stylesheet" th:remove="tag" />
9+
<link href="../../static/css/cas.css" rel="stylesheet" th:remove="tag"/>
1110
</head>
1211

1312
<body>
14-
<main role="main" class="container mt-3 mb-3">
15-
<div layout:fragment="content" class="mdc-card p-4 w-lg-66 m-auto">
16-
<h2 th:utext="#{screen.error.page.requestunsupported}">The request type or syntax is not supported.</h2>
17-
<p th:utext="#{screen.error.page.permissiondenied}">You do not have permission to view this page.</p>
18-
<a class="mdc-button" th:href="@{/login}">
19-
<span class="mdc-button__label" th:utext="#{screen.error.page.loginagain}">Login Again</span>
20-
</a>
21-
</div>
13+
<main role="main" class="container mt-3 mb-3">
14+
<div layout:fragment="content" class="mdc-card p-4 w-lg-66 m-auto">
15+
<h2 th:utext="#{screen.error.page.requestunsupported}">The request type or syntax is not supported.</h2>
16+
<p th:utext="#{screen.error.page.permissiondenied}">You do not have permission to view this page.</p>
17+
<a class="mdc-button" th:href="@{/login(errorSource=405)}">
18+
<span class="mdc-button__label" th:utext="#{screen.error.page.loginagain}">Login Again</span>
19+
</a>
20+
</div>
21+
</main>
2222
</body>
23+
2324
</html>
Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
<!DOCTYPE html>
2-
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{layout}">
2+
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{layoutFlowless}">
33

44
<head>
55
<meta charset="UTF-8">
66
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
77
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
8-
98
<title th:text="#{screen.error.page.title.blocked}">Error - Permission Denied</title>
10-
<link href="../../static/css/cas.css" rel="stylesheet" th:remove="tag" />
9+
<link href="../../static/css/cas.css" rel="stylesheet" th:remove="tag"/>
1110
</head>
1211

1312
<body>
14-
<main role="main" class="container mt-3 mb-3">
15-
<div layout:fragment="content" class="mdc-card p-4 w-lg-66 m-auto">
16-
<h2 th:utext="#{screen.blocked.header}">Access Denied</h2>
17-
<p th:utext="#{screen.blocked.message}">You've entered the wrong password for the user too many times.
18-
You've been throttled.</p>
19-
</div>
20-
</main>
13+
<main role="main" class="container mt-3 mb-3">
14+
<div layout:fragment="content" class="mdc-card p-4 w-lg-66 m-auto">
15+
<h2 th:utext="#{screen.blocked.header}">Access Denied</h2>
16+
<p th:utext="#{screen.blocked.message}">You've entered the wrong password for the user too many times. You've been throttled.</p>
17+
<a class="mdc-button" th:href="@{/login(errorSource=423)}">
18+
<span class="mdc-button__label" th:utext="#{screen.error.page.loginagain}">Login Again</span>
19+
</a>
20+
</div>
21+
</main>
2122
</body>
23+
2224
</html>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
7+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
8+
<title></title>
9+
<link href="../../static/css/cas.css" rel="stylesheet" th:remove="tag"/>
10+
</head>
11+
12+
<body>
13+
<div th:fragment="headerflowless">
14+
<header id="app-bar" class="mdc-top-app-bar mdc-top-app-bar--fixed mdc-elevation--z4">
15+
<nav class="mdc-top-app-bar__row">
16+
<section class="mdc-top-app-bar__section mdc-top-app-bar__section--align-start">
17+
</section>
18+
<section class="mdc-top-app-bar__section mdc-top-app-bar__section--align-center">
19+
<span class="cas-brand mx-auto">
20+
<img class="cas-logo" src="/images/osf-cas-banner-white.png">
21+
<span class="sr-only">OSF CAS</span>
22+
</span>
23+
</section>
24+
<section class="mdc-top-app-bar__section mdc-top-app-bar__section--align-end">
25+
</section>
26+
</nav>
27+
</header>
28+
<script type="text/javascript">
29+
(function (material) {
30+
var header = {
31+
init: function () {
32+
header.attachTopbar();
33+
material.autoInit();
34+
},
35+
attachTopbar: function (drawer) {
36+
},
37+
checkCaps: function (ev) {
38+
var s = String.fromCharCode(ev.which);
39+
if (s.toUpperCase() === s && s.toLowerCase() !== s && !ev.shiftKey) {
40+
ev.target.parentElement.classList.add('caps-on');
41+
} else {
42+
ev.target.parentElement.classList.remove('caps-on');
43+
}
44+
},
45+
}
46+
document.addEventListener('DOMContentLoaded', function () {
47+
header.init();
48+
});
49+
})(mdc);
50+
</script>
51+
</div>
52+
</body>
53+
54+
</html>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<!DOCTYPE html>
2+
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
3+
4+
<head>
5+
<meta charset="UTF-8" />
6+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
7+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
8+
<title layout:title-pattern="$LAYOUT_TITLE &#124; $CONTENT_TITLE">OSF</title>
9+
<link rel="stylesheet" type="text/css" href="../static/css/normalize.css" th:href="@{#{webjars.normalize.css}}" />
10+
<link rel="stylesheet" type="text/css" href="../static/css/bootstrap-grid.min.css" th:href="@{#{webjars.bootstrap-grid.css}}" />
11+
<link rel="stylesheet" type="text/css" href="../static/css/material-components-web.min.css" th:href="@{#{webjars.material-components.css}}" />
12+
<link rel="stylesheet" type="text/css" href="../static/css/mdi-font.css" th:href="@{#{webjars.mdi-font.css}}" />
13+
<link rel="stylesheet" type="text/css" href="../static/css/cas.css" th:href="@{${#themes.code('cas.standard.css.file')}}"/>
14+
<link rel="icon" th:href="@{/favicon.ico}" type="image/x-icon"/>
15+
</head>
16+
17+
<body>
18+
<script th:replace="fragments/scripts"></script>
19+
<div th:replace="fragments/headerflowless :: headerflowless">
20+
<a href="fragments/headerflowless.html"></a>
21+
</div>
22+
<div class="mdc-drawer-scrim"></div>
23+
<div class="mdc-drawer-app-content mdc-top-app-bar--fixed-adjust d-flex justify-content-center">
24+
<main role="main" id="main-content" class="container-lg py-4">
25+
<div layout:fragment="content" id="content">
26+
</div>
27+
</main>
28+
</div>
29+
<div th:replace="fragments/footer :: footer">
30+
<a href="fragments/footer.html"></a>
31+
</div>
32+
</body>
33+
34+
</html>

0 commit comments

Comments
 (0)