Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TECH-156 - Update the Civic frontend canister #14

Merged
merged 27 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
3cb7423
TECH-156 - Update the Civic frontend canister
TYRONEMICHAEL May 10, 2024
62b897d
TECH-156 - Get Civic issuing Credential canister to work
TYRONEMICHAEL May 12, 2024
1eb0a9b
alternative origin file with placeholder
happyhackerbird May 10, 2024
61eebf2
configure civic deploy script (including alternative origins)
happyhackerbird May 13, 2024
fd2f063
fix derivationOrigin in civic frontend login
happyhackerbird May 13, 2024
5fc95cf
fixes for derivationOrigin
happyhackerbird May 13, 2024
07676e0
fix the alternative_frontend url in the civic-deploy script
happyhackerbird May 13, 2024
f079fc9
TECH-156 - Add initial commit for the relying canister frontend appli…
TYRONEMICHAEL May 13, 2024
bcc883a
ci for local setup
happyhackerbird May 13, 2024
d6944d5
fix yaml
happyhackerbird May 13, 2024
3d81df8
use npm instead of yarn
happyhackerbird May 13, 2024
a117c9e
test fixes & mainnet ci
happyhackerbird May 13, 2024
ad54283
Merge branch 'feature/TECH-156-update-frontend-applications' into loc…
happyhackerbird May 13, 2024
b3f8a67
Merge pull request #15 from civicteam/local-ci
TYRONEMICHAEL May 13, 2024
230c57a
TECH-156 - Fix issue with retrieving the credential
TYRONEMICHAEL May 13, 2024
d3d600d
snake case for canister names; fix CI
happyhackerbird May 13, 2024
9a2ce47
fix ci
happyhackerbird May 13, 2024
9560d94
fix
happyhackerbird May 13, 2024
4087e00
fix
happyhackerbird May 13, 2024
a9994c7
Update README.md
happyhackerbird May 13, 2024
f7ef8c2
fix yaml
happyhackerbird May 13, 2024
c2225db
fix yaml
happyhackerbird May 13, 2024
62171d5
fix yaml
happyhackerbird May 14, 2024
bcfe3e5
fix yaml
happyhackerbird May 14, 2024
76c50dd
env-vars script & fixes
happyhackerbird May 14, 2024
258b9bc
fix
happyhackerbird May 14, 2024
d90db71
fix
happyhackerbird May 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 26 additions & 16 deletions .github/workflows/ci.yaml → .github/workflows/ci-local.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: CI Build and Test
name: CI Build and Test (Local setup)

on: [push, pull_request]
# push:
# branches: [ "gh-actions" ]
# branches: [ "develop" ]
# pull_request:
# branches: [ "gh-actions" ]
# branches: [ "develop" ]


env:
Expand All @@ -26,35 +26,45 @@ jobs:
steps:
- name: Check out repository code
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Set up environment
run: |
echo "Setting up on ${{ matrix.os }}"
mv ic-test-machine-binaries/ic-test-state-machine${{ matrix.file_suffix }} ic-test-state-machine

- name: Install dfx
uses: dfinity/setup-dfx@main
- name: Confirm successful installation
run: dfx --version
- name: Install Rust target
run: rustup target add wasm32-unknown-unknown

- name: Install dependencies
run: |
yarn install
npm install
cargo install ic-wasm
- name: Install canisters and start local ICP replica
- name: Create canisters and start local ICP replica
run: |
mkdir src/civic_canister_backend/dist
mkdir src/relying_canister_frontend/dist
dfx start --clean --background
dfx canister create --all
- name: Build canisters
run: dfx build
- name: Deploy canisters
run: dfx canister install --all && dfx deploy
- name: Set env variables
run: |
chmod +x scripts/set-env-vars.sh
scripts/set-env-vars.sh
- name: Deploy Civic Canister and Internet Identity
run: |
scripts/deploy-civic.sh
dfx deploy internet_identity
- name: Deploy RP
id: deploy_rp
continue-on-error: true
run: |
dfx deploy relying_canister_frontend
- name: Deploy Civic FE
run: dfx deploy civic_canister_frontend
- name: Try again to deploy RP if it previously failed
if: steps.deploy_rp.outcome == 'failure'
run: dfx deploy relying_canister_frontend

- name: Run tests
run: |
chmod +x ic-test-state-machine
# cargo test --test integration_tests --verbose
- run: echo "🐧 This job's status is ${{ job.status }}."
cargo test --test integration_tests
29 changes: 25 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
node_modules
target
dist
.dfx
# Various IDEs and Editors
.vscode/
.idea/
**/*~

# Mac OSX temporary files
.DS_Store
**/.DS_Store

# dfx temporary files
.dfx/

# generated files
**/declarations/

# rust
target/

# frontend code
node_modules/
dist/
.svelte-kit/

# environment variables
.env
4 changes: 0 additions & 4 deletions .gitmodules

This file was deleted.

10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,16 @@ cargo test --test integration_tests
1. Open the ```civic_canister_frontend``` using the second URL (looks like so: `http://${canister-id}.localhost:4943/`). Login & issue the credential. The credential is now stored against the principal that's printed.
2. Open the ```relying_canister_frontend``` using the second URL again. Login and request the VC through Internet Identity.

## Alternative Frontends

Setting the correct derivationOrigin/Alternative Frontends of the canisters allows the II backend to correctly convert the principals from the civic POV to the RP POV. The key point is that the the `origin` of the issuer inside the vc-flow call should match the `derivationOrigin` in the login process to the issuer (ie in the civic frontend canister).

1. In the civic frontend, the user logs into the canister using the civic canister backend as `derivationOrigin`. This allows the user's principal to be the same for civic canister backend (since the user is using the _frontend_ canister and they are two separate canisters, II would otherwise use different principals)
2. In the RP, the user wants to request from the issuer of the credentials, namely the civic canister backend. Therefore, the `origin` in the call to the start the vc-flow is set as the civic canister backend.

3. II must map the generated alias between the RP Canister and the Issuing Canister (in order to provide unlinkability of the user's identities). In the vc-flow, when II is sending a `request_credential` to the backend, the principal that it's using must be the one that the civic canister backend stored the credentials under. By specifying a `derivationOrigin` during the login, II knows to use the same principal as in the login to send to the backend and check for stored credentials. Otherwise there will be an `unauthorized principal` error.


## ICP Notes

### Flow for the user sign-in
Expand Down
33 changes: 7 additions & 26 deletions dfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@
"__1": "We use '__X' fields (unknown fields are ignored by dfx) to leave comments.",
"canisters": {
"internet_identity": {
"__0": "The development build of Internet Identity. For more information, see https://github.com/dfinity/internet-identity#build-features-and-flavors",
"type": "custom",
"candid": "https://github.com/dfinity/internet-identity/releases/latest/download/internet_identity.did",
"wasm": "https://github.com/dfinity/internet-identity/releases/latest/download/internet_identity_dev.wasm.gz",

"__2": "The remote block indicates that this canister is only used locally and should not be deployed on the IC.",
"frontend": {},
"remote": {
"id": {
"ic": "rdmx6-jaaaa-aaaaa-aaadq-cai"
}
}
},
"type": "custom",
"wasm": "https://github.com/dfinity/internet-identity/releases/latest/download/internet_identity_dev.wasm.gz"
},

"civic_canister_backend": {
Expand All @@ -22,38 +20,21 @@
"type": "rust"
},



"civic_canister_frontend": {
"__0": "Canisters of type 'assets' are like buckets. When deployed, dfx creates a canister that is just one big empty map.",
"__1": "After the canister itself is created, dfx uploads all the files specified in the 'source' field.",
"__2": "Those files are then stored in the canister's map and served with http_request.",

"__3": "NOTE: dfx will run 'npm run build' when the canister is to be built (dfx build or dfx deploy)",
"__4": "(which in this case populates 'dist/', see package.json).",
"__5": "source must be a directory, otherwise we get a cryptic error.",
"frontend": {
"entrypoint": "src/civic_canister_frontend/dist/index.html"

},
"source": [
"src/civic_canister_frontend/dist"

],
"type": "assets",
"__6": "NOTE: the 'frontend' signals dfx that it is useful to print out the front-end URL of this canister when deploying. It is not strictly required."
"workspace": "civic_canister_frontend"
},

"relying_canister_frontend": {
"frontend": {
"entrypoint": "src/relying_canister_frontend/src/index.html"
},
"source": [
"src/relying_canister_frontend/dist"
],
"type": "assets"
"type": "assets",
"workspace": "relying_canister_frontend"
}

},
"defaults": {
"build": {
Expand Down
Loading
Loading