Skip to content

Commit

Permalink
Merge pull request #36 from dangeroustech/fix/cert-renewal
Browse files Browse the repository at this point in the history
Add Cert Renewal Option
  • Loading branch information
biodrone authored Jan 1, 2022
2 parents 17ec6bf + c77a55a commit a6eee3e
Show file tree
Hide file tree
Showing 4 changed files with 241 additions and 4 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ jobs:
env:
PKR_VAR_LINODE_TOKEN: "${{ secrets.LINODE_TOKEN }}"
PKR_VAR_DOMAIN: "${{ secrets.DOMAIN }}"
PKR_VAR_FEALTY_USER: "${{ secrets.FEALTY_USER }}"
PKR_VAR_FEALTY_PASS: "${{ secrets.FEALTY_PASS }}"
DOMAIN: "${{ secrets.DOMAIN }}"

steps:
Expand Down Expand Up @@ -126,6 +128,6 @@ jobs:
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
force-bump-patch-version: true
changelog-generator-opt: "emojis=true"
changelog-generator-opt: "name=default, emojis=true"
changelog-file: true
allow-initial-development-versions: true
38 changes: 38 additions & 0 deletions .github/workflows/cert_renewal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Cert Renewal

on:
workflow_dispatch:
schedule:
- cron: "0 2 * * 1" # 2AM Every Week on Monday

jobs:
CertRenewal:
runs-on: ubuntu-latest
name: Cert Renewal
env:
TF_VAR_LINODE_TOKEN: "${{ secrets.LINODE_TOKEN }}"
TF_VAR_DOMAIN: "${{ secrets.DOMAIN }}"
AWS_ACCESS_KEY_ID: "${{ secrets.OBJECT_ACCESS_KEY }}"
AWS_SECRET_ACCESS_KEY: "${{ secrets.OBJECT_SECRET_KEY }}"

steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
ref: main

- name: Setup
uses: hashicorp/setup-terraform@v1

- name: Init
id: init
run: terraform -chdir=deploy init

- name: Refresh
id: refresh
run: terraform -chdir=deploy refresh

- name: Renew Cert
id: renew
run: terraform -chdir=deploy apply -target=acme_certificate.certificate
201 changes: 199 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!-- markdownlint-disable MD024 -->
# FealTY

FealTY - An open source and easy to deploy customer rewards scheme.
Expand Down Expand Up @@ -123,6 +124,8 @@ In order for our infrastructure to be deployed from 'the cloud' we need to creat

![GH10](docs/readme/GH10.png)

- After this, head to "https://rewards.$YourDomainHere/api/v1/accounts/admin" and log in with username fealty and password fealty to gain access. If you'd like this to change, just add the FEALTY_USER and FEALTY_PASS variables to your repository, same as you did for the others.

### Destroy

- Head to the Actions tab again and select the 'Fealty Infrastructure Destroyer' workflow
Expand All @@ -136,6 +139,200 @@ _Caveat: won't remove the Object Storage bucket, do that manually_

## Dev Info - API Routes

### Accounts
> All endpoints are protected by Bearer authentication besides the healthcheck
---

### /healthz

**Type**: GET

**Info**: Healthcheck endpoint

**Returns**: HTTP 200

---

### /api/v1/accounts/admin

**Type**: GET

**Info**: Admin UI for administering accounts

**Returns**: Rendered HTTP interface (requests Bearer auth from browser if necessary)

---

### /api/v1/accounts/get

**Type**: GET

**Info**: Gets all account info at once back as JSON

**Returns**: JSON list of accounts, example:

```JSON
{
"accounts": {
"account": {
"accountid": "ObjectID(1234567890)",
"rewardpoints": 45,
"email": "test@test.com",
"marketing": false,
},
"account": {
"accountid": "ObjectID(0987654321)",
"rewardpoints": 54,
"email": "test2@test.com",
"marketing": true,
},
}
}
```

---

### /api/v1/account

**Type**: GET

**Info**: Gets a single account's details. Requires:

```JSON
{
"email": "test@test.com"
}
```

**Returns**: Account information. Example:

```JSON
{
"account": {
"accountid": "ObjectID(1234567890)",
"rewardpoints": 45,
"email": "test@test.com",
"marketing": false,
}
}
```

**Returns**: Alternatively, an error:

```JSON
{
"Error": "Account For test@test.com Not Found"
}
```

---

### /api/v1/account

**Type**: POST

**Info**: Create a new account. Requires:

```JSON
{
"email": "test@test.com",
"rewardpoints": 123,
"marketing": false,
}
```

**Returns**: Newly created account information. Example:

```JSON
{
"account": {
"accountid": "ObjectID(1234567890)",
"rewardpoints": 123,
"email": "test@test.com",
"marketing": false,
}
}
```

**Returns**: Alternatively, an error:

```JSON
{
"Error": "Account for This Email Already Exists"
}
```

---

### /api/v1/account

**Type**: PUT

**Info**: Update current account. Partial update possible.
Only provided data will be changed. Requires:

```JSON
{
"email": "test@test.com",
"rewardpoints": 123,
"marketing": false,
}
```

**Returns**: Updated account information. Example:

```JSON
{
"account": {
"accountid": "ObjectID(1234567890)",
"rewardpoints": 123,
"email": "test@test.com",
"marketing": false,
}
}
```

**Returns**: Alternatively, an error:

```JSON
{
"Error": "Account Not Found"
}
```

---

### /api/v1/account

**Type**: DELETE

**Info**: Delete account. Requires:

```JSON
{
"email": "test@test.com"
}
```

**Returns**: Full account info for the deleted account. Example:

```JSON
{
"account": {
"accountid": "ObjectID(1234567890)",
"rewardpoints": 123,
"email": "test@test.com",
"marketing": false,
}
}
```

- [ ] Update (Partial) - **STRETCH**
**Returns**: Alternatively, an error:

```JSON
{
"Error": "Account Not Found"
}
```

---
2 changes: 1 addition & 1 deletion app/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func main() {
app := fiber.New(fiber.Config{
CaseSensitive: true,
ServerHeader: "FealTY API v1",
AppName: "FealTY v1.0.0",
AppName: "FealTY v1.0.1",
Views: htmlEngine,
})

Expand Down

0 comments on commit a6eee3e

Please sign in to comment.