forked from CSE134B-F23/Script-Integrity-Demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
61 lines (50 loc) · 2.35 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Subresource Integrity (SRI) Demo</title>
<link rel="stylesheet" href="style.css"
integrity="sha384-oqVuAfXRKap7fdgcCY5uykM6+R9GqQ8K/uxy9rx7HNQlGYl1kPzQho1wx4JwY8wC">
</head>
<body>
<header>
<h1>Subresource Integrity (SRI) in Browsers</h1>
</header>
<nav>
<ul>
<li><a href="#what-is-sri">What is SRI?</a></li>
<li><a href="#how-it-works">How It Works</a></li>
<li><a href="#usage">Usage</a></li>
</ul>
</nav>
<main>
<section id="what-is-sri">
<h2>What is Subresource Integrity (SRI)?</h2>
<p>Subresource Integrity (SRI) is a security feature in modern web browsers that helps protect web
applications from potential security vulnerabilities.</p>
<p>It allows a website to ensure that the resources (such as JavaScript or CSS files) it fetches from
external sources have not been tampered with during delivery.</p>
</section>
<section id="how-it-works">
<h2>How It Works</h2>
<p>SRI works by generating a cryptographic hash of the expected resource and comparing it to the hash
provided in the HTML source. If the hashes match, the resource is considered secure and is loaded by the
browser. If they don't match, the resource is blocked to protect against potential attacks.</p>
</section>
<section id="usage">
<h2>Usage</h2>
<p>To use SRI in your HTML, you can include the <code>integrity</code> attribute within your
<code><script></code> or <code><link></code> tags:
</p>
<pre>
<script src="example.js" integrity="sha384-abc123456789" crossorigin="anonymous"></script>
<link rel="stylesheet" href="styles.css" integrity="sha256-def456789123" crossorigin="anonymous">
</pre>
<p>The <code>integrity</code> attribute contains the hash of the expected resource, and the
<code>crossorigin</code> attribute should be set to "anonymous" for SRI to work correctly.
</p>
</section>
</main>
</body>
</html>