Skip to content

Commit 87d0e59

Browse files
committed
Ready for review
1 parent 975d5d2 commit 87d0e59

File tree

1 file changed

+11
-11
lines changed
  • public/content/developers/tutorials/ethereum-for-web2-auth

1 file changed

+11
-11
lines changed

public/content/developers/tutorials/ethereum-for-web2-auth/index.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ author: Ori Pomerantz
55
tags: ["web2", "authentication", "eas"]
66
skill: beginner
77
lang: en
8-
published: 2025-04-15
8+
published: 2025-04-30
99
---
1010

1111
## Introduction
@@ -96,14 +96,14 @@ sequenceDiagram
9696
9797
-->
9898

99-
The signature only provides the address. To get other user attributes, you typically use [attestations](https://attest.org/). An attestation typically has these fields:
99+
The signature only verifies the Ethereum address. To get other user attributes, you typically use [attestations](https://attest.org/). An attestation typically has these fields:
100100

101101
- **Attestor**, the address that made the attestation
102102
- **Recipient**, the address to which the attestation applies
103103
- **Data**, the data being attested, such as name, permissions, etc.
104104
- **Schema**, the ID of the schema used to interpret the data.
105105

106-
Because of the decentralized nature of Ethereum, any user can make attestations. The attestor's identity is important to identify which attestations we want to consider reliable.
106+
Because of the decentralized nature of Ethereum, any user can make attestations. The attestor's identity is important to identify which attestations we consider reliable.
107107

108108
## Setup
109109

@@ -127,7 +127,7 @@ The first step is to have a SAML SP and a SAML IdP communicating between themsel
127127
cd ..
128128
```
129129

130-
3. Start the servers
130+
3. Start the servers (both SP and IdP)
131131

132132
```sh
133133
pnpm start
@@ -250,7 +250,7 @@ const fs = await import("fs")
250250
const saml = await import("samlify")
251251
```
252252

253-
We use the [`samlify`](https://www.npmjs.com/package/samlify) to implement SAML.
253+
We use the [`samlify`](https://www.npmjs.com/package/samlify) library to implement SAML.
254254

255255
```typescript
256256
import * as validator from "@authenio/samlify-node-xmllint"
@@ -543,11 +543,11 @@ This is the endpoint that receives a login request from the service provider. Th
543543
res.send(getLoginPage(samlRequest["samlp:AuthnRequest"]["@_ID"]))
544544
```
545545

546-
We should be able to use [`idp.parseLoginRequest`](https://github.com/tngan/samlify/blob/master/src/entity-idp.ts#L127-L144) to read the authentication request's ID. However, I could get it working and it wasn't worth spending a lot of time on it so I just use a [general-purpose XML parser](https://www.npmjs.com/package/fast-xml-parser). The information we need is the `ID` attribute inside the `<samlp:AuthnRequest>` tag, which is at the top level of the XML.
546+
We should be able to use [`idp.parseLoginRequest`](https://github.com/tngan/samlify/blob/master/src/entity-idp.ts#L127-L144) to read the authentication request's ID. However, I couldn't get it working and it wasn't worth spending a lot of time on it so I just use a [general-purpose XML parser](https://www.npmjs.com/package/fast-xml-parser). The information we need is the `ID` attribute inside the `<samlp:AuthnRequest>` tag, which is at the top level of the XML.
547547
548548
## Using Ethereum signatures
549549
550-
Now that we can send a user identity to the service provider, the next step is to obtain the user identity in a trusted manner. Viem allows us to just ask the wallet for the user address, but this means asking the browser for the information. We don't control the browser, so we can't trust any response we get from it.
550+
Now that we can send a user identity to the service provider, the next step is to obtain the user identity in a trusted manner. Viem allows us to just ask the wallet for the user address, but this means asking the browser for the information. We don't control the browser, so we can't automatically trust the response we get from it.
551551
552552
Instead, the IdP is going to send the browser a string to sign. If the wallet in the browser signs this string, it means that it really is that address (that is, it knows the private key that corresponds to the address).
553553
@@ -813,7 +813,7 @@ query GetAttestationsByRecipient {
813813
}
814814
```
815815
816-
This [`schemaId`](https://optimism.easscan.org/schema/view/0xfa2eff59a916e3cc3246f9aec5e0ca00874ae9d09e4678e5016006f07622f977) includes just an e-mail address. This query asks for attestations of this schema. The subject of the attestation is called the `recipient`, is always an address.
816+
This [`schemaId`](https://optimism.easscan.org/schema/view/0xfa2eff59a916e3cc3246f9aec5e0ca00874ae9d09e4678e5016006f07622f977) includes just an e-mail address. This query asks for attestations of this schema. The subject of the attestation is called the `recipient`. It is always an Ethereum address.
817817
818818
Warning: The way we are getting attestations here has two security issues.
819819
@@ -932,7 +932,7 @@ We are looking for attestations.
932932
}
933933
```
934934
935-
The attestations we want are those in our schema, where the recipient is `getAddress(ethAddr)`. The [`getAddress`](https://viem.sh/docs/utilities/getAddress#getaddress) function makes sure our address has the correct [checksum](https://github.com/ethereum/ercs/blob/master/ERCS/erc-55.md).
935+
The attestations we want are those in our schema, where the recipient is `getAddress(ethAddr)`. The [`getAddress`](https://viem.sh/docs/utilities/getAddress#getaddress) function makes sure our address has the correct [checksum](https://github.com/ethereum/ercs/blob/master/ERCS/erc-55.md). This is necessary about GraphQL is case-significant. "0xBAD060A7", "0xBad060A7", and "0xbad060a7" are differemt values.
936936
937937
```typescript
938938
take: 1
@@ -991,9 +991,9 @@ Use the new function to get the e-mail address.
991991
992992
## What about decentralization?
993993
994-
In this configuration users cannot pretend to be somebody they aren't, as long as we rely on trustworthy attesters for the Ethereum to e-mail address mapping. However, our identity provider is still a centralized component. Whoever has the private key of the identity provider can send false information to the service provider.
994+
In this configuration users cannot pretend to be somebody they are not, as long as we rely on trustworthy attesters for the Ethereum to e-mail address mapping. However, our identity provider is still a centralized component. Whoever has the private key of the identity provider can send false information to the service provider.
995995
996-
There may be a solution using [multi-party computation (MPC)](https://ethresear.ch/c/cryptography/mpc/14). If I get it working, I hope to write about it in a future tutorial.
996+
There may be a solution using [multi-party computation (MPC)](https://en.wikipedia.org/wiki/Secure_multi-party_computation). I hope to write about it in a future tutorial.
997997
998998
## Conclusion
999999

0 commit comments

Comments
 (0)