Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor Shneer committed Feb 16, 2023
0 parents commit faf5adb
Show file tree
Hide file tree
Showing 10 changed files with 155 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Gradle
.gradle/
build/

# Eclipse
.project
.classpath
.settings/
bin/


# IntelliJ
.idea/
.idea
*.ipr
*.iml
*.iws

# NetBeans
nb-configuration.xml

# Visual Studio Code
.vscode
.factorypath

# OSX
.DS_Store

# Vim
*.swp
*.swo

# patch
*.orig
*.rej

# Local environment
.env
env.sh

*.daml/

*.log
log/

21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# DAML WITH AUTH

The goal of this repo is to provide an example of a simple daml app with Auth0 protection
AuthT and AuthZ for Navigator, JSON API client and UI

## Launch tips
```
daml sandbox --config auth.conf
```
```
daml ledger upload-dar --host localhost --port 6865 --access-token-file m2m-access.token .daml/dist/daml-with-auth-0.0.1.dar
```
```
daml script --dar .daml/dist/daml-with-auth-0.0.1.dar --script-name Test:allocateParties --access-token-file m2m-access.token --ledger-host localhost --ledger-port 6865
```
```
daml ledger list-parties --host localhost --port 6865 --access-token-file m2m-access.token
```
```
token : {"admin": true, "actAs": ["Alice::1220dcfdf8c383f01ecc8a1d0147ec5ef58cfa1939736da62bbecc774e836b50a8bc", "Bob::1220dcfdf8c383f01ecc8a1d0147ec5ef58cfa1939736da62bbecc774e836b50a8bc"]}
```
5 changes: 5 additions & 0 deletions auth.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
canton.participants.sandbox.ledger-api.auth-services = [{
type = jwt-rs-256-jwks
url = "https://dev-rphl6e3zqdlcram3.us.auth0.com/.well-known/jwks.json"
}]

8 changes: 8 additions & 0 deletions daml.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
sdk-version: 2.5.0
name: daml-with-auth
source: daml
version: 0.0.1
dependencies:
- daml-prim
- daml-stdlib
- daml-script
23 changes: 23 additions & 0 deletions daml/Main.daml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module Main where

template Agreement
with
proposer: Party
counterparty: Party
payload: Text
where
signatory proposer, counterparty

template Proposal
with
proposer: Party
counterparty: Party
payload: Text
where
signatory proposer
observer counterparty

choice Accept : ContractId Agreement
controller counterparty
do
create Agreement with ..
21 changes: 21 additions & 0 deletions daml/Test.daml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module Test where

import Daml.Script

import Main (Proposal(..), Accept(..))

allocateParties : Script((Party, Party))
allocateParties = script do
proposer <- allocatePartyWithHint "proposer" (PartyIdHint "proposer")
counterparty <- allocatePartyWithHint "counterparty" (PartyIdHint "counterparty")

return (proposer, counterparty)

testIt : Script ()
testIt = script do
(proposer, counterparty) <- allocateParties
let payload = "rent agreement"
proposalCid <- submit proposer do createCmd Proposal with ..
agrCid <- submit counterparty do exerciseCmd proposalCid Accept

pure ()
28 changes: 28 additions & 0 deletions env.sh-template
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# The following options relate to Auth0 setup and service credentials. Please see documentation for meaning
# Use in auth-config.json in UI
AUTH0_DOMAIN="-"
AUTH0_CLIENT_ID="-"

# Auth0 Service Account credentials

M2M_CLIENT_ID='-'
M2M_CLIENT_SECRET='-'

NAVIGATOR_CLIENT_ID='-'
NAVIGATOR_CLIENT_SECRET='-'

TRIGGER_CLIENT_ID='-'
TRIGGER_CLIENT_SECRET='-'

# Minimal token for JSON API - public rights only to retrieve DAML Packages
JSON_CLIENT_ID='-'
JSON_CLIENT_SECRET='-'

ALICE_CLIENT_ID='-'
ALICE_CLIENT_SECRET='-'

BOB_CLIENT_ID='-'
BOB_CLIENT_SECRET='-'

LEDGER_ID="sandbox"

4 changes: 4 additions & 0 deletions tokens/get_tokens.sh-template
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
curl -v --request POST \
--url https://dev-rphl6e3zqdlcram3.us.auth0.com/oauth/token \
--header 'content-type: application/json' \
--data "{ \"client_id\": \"\", \"client_secret\": \"\", \"audience\": \"https://daml.com/ledger-api\", \"grant_type\": \"client_credentials\" }"
Empty file added tokens/m2m-access.token
Empty file.
Empty file added tokens/navigator-access.token
Empty file.

0 comments on commit faf5adb

Please sign in to comment.