4.2 KiB
From 0 to "Hello World"
Goal:
The purpose of this tutorial is to install Walnut and be able to launch a simple "Hello World" app.
Pre-requisites:
- You have compatible server hardware
- Daplie Server
- EspressoBin
- Raspberry Pi
- MacBook
- (pretty much anything, actually)
- You have compatible softwar
- Linux of any sort that uses systemd
- macOS using launchd
- You own a domain
- through Daplie Domains
- or you understand domains and DNS and all that stuff
Choose a domain
For the purpose of this instruction we'll assume that your domain is example.com
,
but you can use, say, johndoe.daplie.me
for testing through Daplie Domains.
Anyway, go ahead and set the bash variable $my_domain
for the purposes of the
rest of this tutorial:
my_domain=example.com
Subodmains
Auth will be loaded with the following domains
provider.example.com
api.provider.example.com
The Hello World app will be loaded with the following domains
example.com
www.example.com
api.example.com
assets.example.com
Basic Walnut Install
Follow the walnut.js README.md for instructions to install Goldilocks.js and Walnut.js (and manually setup domains with daplie tools).
Since the app store and package manager are not built yet, you should also change the permissions on the walnut directory for the purposes of this tutorial:
sudo chown -R $(whoami) /srv/walnut/
OAuth3 Install
# Frontend
git clone git@git.daplie.com:OAuth3/org.oauth3.git /srv/walnut/packages/pages/issuer@oauth3.org
pushd /srv/walnut/packages/pages/issuer@oauth3.org
bash ./install.sh
popd
echo "issuer@oauth3.org" >> /srv/walnut/var/sites/provider.$my_domain
# APIs
git clone git@git.daplie.com:OAuth3/org.oauth3.provider.git /srv/walnut/packages/rest/issuer@oauth3.org
pushd /srv/walnut/packages/rest/issuer@oauth3.org/
git checkout v1.2
npm install
popd
echo "issuer@oauth3.org" >> /srv/walnut/packages/client-api-grants/provider.$my_domain
You also need to change to presently-hardcoded email values (TODO use getSiteConfig()
)
vim /srv/walnut/packages/rest/issuer@oauth3.org/lib/provide-oauth3.js
OAuth3 Secrets
OAuth3 is currently configured to use mailgun for sending verification emails. It is intended to provide a way to use various mail services in the future, just bear with us for the time being (or open a Merge Request).
vim /srv/walnut/var/example.com/config.json
{ "mailgun.org": {
"apiKey": "key-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
, "apiPublicKey": "pubkey-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
, "auth": {
"user": "robtherobot@example.com"
, "pass": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
, "api_key": "key-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
, "domain": "example.com"
}
}
, "issuer@oauth3.org": {
"mailer": {
"from": "login@example.com"
, "subject": "Login code request"
, "text": ":code\n\nis your login code"
}
}
}
Install the 'hello@example.com' package
git clone git@git.daplie.com:Daplie/com.example.hello.git /srv/walnut/packages/rest/hello@example.com
echo "hello@example.com" >> /srv/walnut/packages/client-api-grants/provider.$my_domain
What it should look like:
/srv/walnut/packages/rest/hello@example.com/
package.json
api.js
models.js
rest.js
/srv/walnut/packages/client-api-grants/example.com
hello@example.com
The Daplie Seed App
Get the Seed App
pushd /srv/walnut/packages/pages/
git clone git@git.daplie.com:Daplie/seed_example.com.git --branch v1 seed@example.com
pushd seed@example.com/
git clone git@git.daplie.com:OAuth3/oauth3.js.git --branch v1.1 assets/oauth3.org
mkdir -p .well-known
ln -sf ../assets/oauth3.org/.well-known/oauth3 .well-known/oauth3
popd
echo "seed@example.com" >> /srv/walnut/var/sites/$my_domain
popd
Change the authenication from oauth3.org
to your domain (i.e. provider.example.com
)
vim /srv/walnut/packages/pages/seed@example.com/js/config.js
{ "azp@oauth3.org": { issuer_uri: 'provider.example.com', client_uri: 'example.com' } }