Compare commits

...

196 Commits

Author SHA1 Message Date
Loïc Dachary eaff09efd4 Merge pull request 'do not rename past migrations' (#73) from dachary/dashboard:wip-forgejo into master
ci/woodpecker/push/woodpecker Pipeline failed Details
Reviewed-on: Hostea/dashboard#73
2023-01-09 12:59:42 -05:00
Loïc Dachary d07a644552
upgrade greenlet 1.1.3.post0
ci/woodpecker/pr/woodpecker Pipeline failed Details
ci/woodpecker/push/woodpecker Pipeline failed Details
2023-01-09 18:51:22 +01:00
Loïc Dachary 93c38fc1f9
Forgejo is codeberg.org/forgejo/forgejo:1.18.0-1
ci/woodpecker/pr/woodpecker Pipeline failed Details
ci/woodpecker/push/woodpecker Pipeline failed Details
2023-01-09 18:39:35 +01:00
Loïc Dachary 788e025b98
do not rename past migrations
ci/woodpecker/pr/woodpecker Pipeline failed Details
it is not possible to go back in time
2023-01-09 18:24:10 +01:00
Loïc Dachary 1c165fcea3
upgrade gitea to forgejo
ci/woodpecker/pr/woodpecker Pipeline failed Details
ci/woodpecker/push/woodpecker Pipeline failed Details
Signed-off-by: Loïc Dachary <loic@dachary.org>
2022-12-23 22:34:38 +01:00
Aravinth Manivannan 2e36a186ee Merge pull request 'convert instance names to lowercase' (#70) from dachary/dashboard:wip-lowercase into master
ci/woodpecker/push/woodpecker Pipeline failed Details
Reviewed-on: https://gitea.gna.org/Hostea/dashboard/pulls/70
2022-10-04 04:39:04 -04:00
Loïc Dachary ad925cddfc
convert instance names to lowercase
ci/woodpecker/pr/woodpecker Pipeline was successful Details
Fixes: https://gitea.gna.org/Hostea/dashboard/issues/69

Signed-off-by: Loïc Dachary <loic@dachary.org>
2022-10-04 09:14:50 +02:00
Loïc Dachary 2725b9b1f6
avoid crash in CI when STRIPE is not set
Signed-off-by: Loïc Dachary <loic@dachary.org>
2022-10-04 09:14:50 +02:00
Loïc Dachary 0f1003dbe8 Merge pull request 'fix: receipt email subject' (#68) from fix-email-typo into master
ci/woodpecker/push/woodpecker Pipeline was successful Details
Reviewed-on: https://gitea.gna.org/Hostea/dashboard/pulls/68
2022-10-01 12:01:08 -04:00
Aravinth Manivannan 187d22118f Merge pull request 'do not pin Gitea version' (#67) from dachary/dashboard:wip-gitea into master
ci/woodpecker/push/woodpecker Pipeline was successful Details
Reviewed-on: https://gitea.gna.org/Hostea/dashboard/pulls/67
2022-10-01 07:55:12 -04:00
Hostea dashboard 9b9fb8362d
fix: receipt email subject
ci/woodpecker/push/woodpecker Pipeline was successful Details
ci/woodpecker/pr/woodpecker Pipeline failed Details
2022-09-30 18:36:56 +05:30
Loïc Dachary 498b95848e
do not pin Gitea version
ci/woodpecker/pr/woodpecker Pipeline failed Details
So that it is upgraded when Enough is upgraded.

Signed-off-by: Loïc Dachary <loic@dachary.org>
2022-09-30 14:54:50 +02:00
Loïc Dachary b5afc49f5d Merge pull request 'notify staff when new instance is deployed' (#61) from alert-staff-new-instance into master
ci/woodpecker/push/woodpecker Pipeline was successful Details
Reviewed-on: https://gitea.gna.org/Hostea/dashboard/pulls/61
2022-09-14 02:48:21 -04:00
Hostea dashboard 86fe9a2c59
feat: alert staff on new instance creation
ci/woodpecker/push/woodpecker Pipeline was successful Details
ci/woodpecker/pr/woodpecker Pipeline failed Details
closes: https://gitea.gna.org/Hostea/dashboard/issues/52
2022-09-13 19:57:37 +05:30
Hostea dashboard 9d2a53f2e2
fix: more email project renaming 2022-09-13 19:57:26 +05:30
Loïc Dachary c7def47215 Merge pull request 'fix: don't send pre-payment notification email' (#56) from fix-rm-not-invoice into master
ci/woodpecker/push/woodpecker Pipeline was successful Details
Reviewed-on: https://gitea.gna.org/Hostea/dashboard/pulls/56
2022-09-12 15:48:14 -04:00
Hostea dashboard 9f5032bd28
feat: send subscription renewal notification emails
ci/woodpecker/push/woodpecker Pipeline was successful Details
ci/woodpecker/pr/woodpecker Pipeline failed Details
2022-09-12 21:01:24 +05:30
Hostea dashboard 669a22a004
fix: don't send pre-payment notification email
closes: https://gitea.gna.org/Hostea/dashboard/issues/49
2022-09-12 21:01:21 +05:30
Loïc Dachary 0ab82fe0b4 Merge pull request 'fix: rename Gna! in emails' (#60) from fix-rename-gna-in-emails into master
ci/woodpecker/push/woodpecker Pipeline was successful Details
Reviewed-on: https://gitea.gna.org/Hostea/dashboard/pulls/60
2022-09-12 08:36:17 -04:00
Hostea dashboard 0e0b8db940
fix: test for Gna! in emails
ci/woodpecker/push/woodpecker Pipeline was successful Details
ci/woodpecker/pr/woodpecker Pipeline failed Details
2022-09-12 17:36:24 +05:30
Hostea dashboard ac0775e075
fix: rename to Gna! in email templates 2022-09-12 17:36:04 +05:30
Hostea dashboard 51e7ea4d5e
fix: rename Gna! in emails
ci/woodpecker/push/woodpecker Pipeline failed Details
ci/woodpecker/pr/woodpecker Pipeline failed Details
2022-09-12 16:36:29 +05:30
Loïc Dachary 98973301c3 Merge pull request 'fix: don't send emails to VMs that were requested but not created' (#54) from fix-dead-instance-invoices into master
ci/woodpecker/push/woodpecker Pipeline was successful Details
Reviewed-on: https://gitea.gna.org/Hostea/dashboard/pulls/54
2022-09-11 19:07:41 -04:00
Hostea dashboard 3ebc518e1f
fix: don't send emails to VMs that were requested but not created
ci/woodpecker/push/woodpecker Pipeline was successful Details
ci/woodpecker/pr/woodpecker Pipeline failed Details
SUMMARY
    dash.models.Instance is created upon request and
    infrastructure.models.InstanceCreated when the instance is created.
    Using data from InstanceCreated to send invoices should solve this
    issue.
2022-09-12 04:05:41 +05:30
Aravinth Manivannan 25db390e4d Merge pull request 'Rename hostea to gna!' (#59) from wip-rename-hostea-to-gna into master
ci/woodpecker/push/woodpecker Pipeline was successful Details
Reviewed-on: https://gitea.gna.org/Hostea/dashboard/pulls/59
2022-09-11 18:25:58 -04:00
Hostea dashboard 6365b84d45
feat: run collectstatic before launching development server to update static assets
ci/woodpecker/push/woodpecker Pipeline was successful Details
ci/woodpecker/pr/woodpecker Pipeline failed Details
2022-09-12 03:53:19 +05:30
Hostea dashboard 41ca63244e
feat: update name and web links to Gna! 2022-09-12 03:53:19 +05:30
Hostea dashboard 0e2112e30f
feat: change hostea logo to gna! 2022-09-12 03:53:19 +05:30
Loïc Dachary 5b7cf06c7a Merge pull request 'fix: instance_names in tests must be alphanumeric and be < 20 chars' (#58) from fix-hostname-validation into master
ci/woodpecker/push/woodpecker Pipeline was successful Details
Reviewed-on: https://gitea.gna.org/Hostea/dashboard/pulls/58
2022-09-11 18:13:12 -04:00
Hostea dashboard 1792713952
fix: instance_names in tests must be alphanumeric and be < 20 chars
ci/woodpecker/pr/woodpecker Pipeline failed Details
ci/woodpecker/push/woodpecker Pipeline was successful Details
closes: https://gitea.gna.org/Hostea/dashboard/issues/57
2022-09-12 03:33:20 +05:30
Loïc Dachary 3019d9d739 Merge pull request 'fix: add hostname validation rules' (#55) from fix-hostname-validation into master
ci/woodpecker/push/woodpecker Pipeline failed Details
Reviewed-on: https://gitea.gna.org/Hostea/dashboard/pulls/55
2022-09-11 16:11:58 -04:00
Hostea dashboard bcb2e26f61
feat: test vm name validation 2022-09-04 18:04:37 +05:30
Hostea dashboard 011fb4816f
fix: validate VM names
fixes: https://gitea.gna.org/Hostea/dashboard/issues/51
2022-09-04 17:49:53 +05:30
Hostea dashboard 6c31555a52
feat: password reset workflow
ci/woodpecker/push/woodpecker Pipeline was successful Details
fixes: https://gitea.hostea.org/Hostea/support/issues/2
2022-07-10 12:42:16 +05:30
Hostea dashboard 060e9b84d4
fix: update password reset link 2022-07-10 12:40:00 +05:30
Hostea dashboard 418bb7dec0
fix: tests rely on a string from login page. Login page update reflects
ci/woodpecker/push/woodpecker Pipeline was successful Details
in tests
2022-07-10 12:39:33 +05:30
Loïc Dachary c4375a43b2 Merge pull request 'Update the page content' (#48) from dachary/dashboard:wip-site into master
ci/woodpecker/push/woodpecker Pipeline failed Details
Reviewed-on: https://gitea.hostea.org/Hostea/dashboard/pulls/48
2022-07-10 02:43:43 -04:00
Loïc Dachary 705c3a282b
copy/paste the hostea.org home page content
ci/woodpecker/pr/woodpecker Pipeline failed Details
So they are consistent with each other.

Fixes: #47

Signed-off-by: Loïc Dachary <loic@dachary.org>
2022-07-10 08:42:38 +02:00
Loïc Dachary cfd5518518
Add link to https://hostea.org
So that the user can conveniently go back to hostea.org without
editing with the URL manually.

Signed-off-by: Loïc Dachary <loic@dachary.org>
2022-07-10 08:20:24 +02:00
Aravinth Manivannan a95158f3df
fix: Gite credentials email: fix subject and let user know instance is
ci/woodpecker/push/woodpecker Pipeline was successful Details
being provisioned

fixes: https://gitea.hostea.org/Hostea/dashboard/issues/44
2022-07-09 10:54:45 +05:30
Aravinth Manivannan b12cc044da
fix: Invoice generation must not consider deleted VMs' names for
ci/woodpecker/push/woodpecker Pipeline was successful Details
checking if payment is already fulfilled

DESCRIPTION
    Invoice generation is dependent on instance_name. Deleting a VM
    doesn't delete the corresponding payments record since payment
    receipts should be preserved for accounting purposes.

    But being heavily dependent on instance_name, without taking deleted
    VMs into account produces incorrect behavior under certain
    circumstances: if a VM named 'foo' is paid for and is deleted before
    its billing cycle is competed and a new VM is created with the same
    name, either by the same user or a different user, invoice won't be
    generated for the new VM since a payment record already exists for
    that billing cycle for the VM named 'foo'.

    Marking deleted VMs' payment records unsuitable for checking if a VM
    is already paid for will result in correct behavior.

fixes: https://gitea.hostea.org/Hostea/dashboard/issues/38
2022-07-08 22:28:39 +05:30
Aravinth Manivannan cc12d1a77d
fix: hard-code CI_COMMIT_AUTHOR_* details to avoid failures in PR builds
ci/woodpecker/push/woodpecker Pipeline was successful Details
ref: https://gitea.hostea.org/Hostea/dashboard/pulls/42
2022-07-08 19:51:06 +05:30
Aravinth Manivannan cb6bce0c44 Merge pull request 'git config before push' (#43) from dachary/dashboard:wip-config-3 into master
ci/woodpecker/push/woodpecker Pipeline was successful Details
Reviewed-on: https://gitea.hostea.org/Hostea/dashboard/pulls/43
2022-07-08 10:18:00 -04:00
Aravinth Manivannan bebf18946a
fix: re-enable billing app tests
ci/woodpecker/push/woodpecker Pipeline was successful Details
Commented out for debugging, forgot to enable(!!)
2022-07-08 19:31:06 +05:30
Loïc Dachary 6e84746a2c
git config before push
ci/woodpecker/pr/woodpecker Pipeline failed Details
2022-07-08 15:47:53 +02:00
Aravinth Manivannan 2c8a5909cb
fix: generate absolute URI when attaching links in invoice and payment
ci/woodpecker/push/woodpecker Pipeline was successful Details
notification

fixes: https://gitea.hostea.org/Hostea/dashboard/issues/37
2022-07-08 18:51:04 +05:30
Aravinth Manivannan ce0498b013
fix: add instance link in primary nav bar points to right page 2022-07-08 18:43:04 +05:30
Aravinth Manivannan 809322d245
feat: docs: generate_invoice management cmd
ci/woodpecker/push/woodpecker Pipeline was successful Details
fixes: https://gitea.hostea.org/Hostea/dashboard/issues/29
2022-07-08 01:51:22 +05:30
Aravinth Manivannan 2ee54a71e3
feat: management command to periodically generate invoices
ci/woodpecker/push/woodpecker Pipeline was successful Details
SUMMARY
    `python manage.py generate_invoice` generates invoices for VMs when
    it enters a new billing cycle and sends a notification email to
    VM owners.

    This command should be run as frequently as desirable. Running daily
    is recommended.

BILLING CYCLE
    By default, a billing cycle is 30 days.
2022-07-08 01:46:17 +05:30
Aravinth Manivannan 438e34f7d6
chore: refactor invoice generation into a util fn 2022-07-08 00:51:11 +05:30
Aravinth Manivannan 9c239ad78b
feat: send invoice generated notification email and payments receipt mail
ci/woodpecker/push/woodpecker Pipeline was successful Details
2022-07-07 20:51:33 +05:30
Aravinth Manivannan 147eead388 Merge pull request 'clone instead of fetch' (#19) from dachary/dashboard:wip-pull into master
ci/woodpecker/push/woodpecker Pipeline was successful Details
Reviewed-on: https://gitea.hostea.org/Hostea/dashboard/pulls/19
2022-07-07 04:42:46 -04:00
Aravinth Manivannan f2f2fadae4
feat: use whitenoise for static file in development too for uniform Behavior
ci/woodpecker/push/woodpecker Pipeline was successful Details
> it opens up the possibility for differences in behaviour between development and production environments. For this reason it’s a good idea to use WhiteNoise in development as well.

source: http://whitenoise.evans.io/en/stable/django.html#using-whitenoise-in-development
2022-07-07 13:59:06 +05:30
Aravinth Manivannan 5f6c3c459e
chore: mv common static files to common-static 2022-07-07 13:58:53 +05:30
Loïc Dachary 8d02fe107f
always clone the fleet repository
ci/woodpecker/pr/woodpecker Pipeline failed Details
It is small and not worth the trouble of dealing with fetch/pull

Signed-off-by: Loïc Dachary <loic@dachary.org>
2022-07-07 10:05:18 +02:00
Aravinth Manivannan b4183c1790
feat & fix: install and configure whitenoise to serve static files in
ci/woodpecker/push/woodpecker Pipeline failed Details
prod

fixes: https://gitea.hostea.org/Hostea/dashboard/issues/24
2022-07-07 10:59:23 +05:30
Aravinth Manivannan 22abe08f68
feat: mv static files to dash/static/dash and migrate load static template tags 2022-07-07 10:41:22 +05:30
Aravinth Manivannan 4c51eb77b0 chore: rm gitea/app.in
ci/woodpecker/push/woodpecker Pipeline was successful Details
SUMMARY
    This file was used to spawn a Gitea instance from binary for
    integration testing. That strategy was abandoned long ago but this
    file wasn't cleaned up.

fixes: https://gitea.hostea.org/Hostea/dashboard/issues/34
2022-07-05 01:59:26 -04:00
Aravinth Manivannan 9303ea59ed fix: s/EMAIL_SENDER_ADDRESS/DEFAULT_FROM_EMAIL/
ci/woodpecker/push/woodpecker Pipeline was successful Details
2022-07-04 12:42:02 -04:00
Aravinth Manivannan eb68b1e984 feat: Gitea root creds email with nicer content 2022-07-04 12:42:02 -04:00
Aravinth Manivannan 5e5ce02759 feat: instance created notification email template with nicer body 2022-07-04 12:42:02 -04:00
Aravinth Manivannan 63f4f987a9 feat: verification link email template with polished email body 2022-07-04 12:42:02 -04:00
Aravinth Manivannan 4a1c0a5cdc feat: add EMAIL_SENDER_ADDRESS to settings.py 2022-07-04 12:42:02 -04:00
Aravinth Manivannan 280807d96c
fix: rm dummy section
ci/woodpecker/pr/woodpecker Pipeline failed Details
ci/woodpecker/push/woodpecker Pipeline was successful Details
NOTE
    The dummy section is commented out for future reference.

fixes: https://gitea.hostea.org/Hostea/dashboard/issues/27
2022-07-04 13:55:28 +05:30
Aravinth Manivannan e79fb65cdf
fix: rm WIP services from homepage
ci/woodpecker/pr/woodpecker Pipeline failed Details
ci/woodpecker/push/woodpecker Pipeline was successful Details
fixes: https://gitea.hostea.org/Hostea/dashboard/issues/28
2022-07-04 13:44:43 +05:30
Aravinth Manivannan c72773fc9e Merge pull request 's/ammount/amount/' (#22) from dachary/dashboard:wip-typo into master
ci/woodpecker/push/woodpecker Pipeline failed Details
Reviewed-on: https://gitea.hostea.org/Hostea/dashboard/pulls/22
2022-07-03 16:39:49 -04:00
Aravinth Manivannan 8e7a11b9a4 Merge pull request 'Revert "enough hoste delete is not idempotent"' (#21) from dachary/dashboard:wip-delete into master
ci/woodpecker/push/woodpecker Pipeline was successful Details
Reviewed-on: https://gitea.hostea.org/Hostea/dashboard/pulls/21
2022-07-03 16:38:34 -04:00
Loïc Dachary ed0186912d
s/ammount/amount/
ci/woodpecker/pr/woodpecker Pipeline failed Details
2022-07-03 15:01:09 +02:00
Loïc Dachary 7c045b12d5
Revert "enough hoste delete is not idempotent"
ci/woodpecker/pr/woodpecker Pipeline failed Details
Fixes: #18

This reverts commit ccec1262f0.
2022-07-03 14:58:27 +02:00
Aravinth Manivannan 5397e38d22 Merge pull request 'enough host delete is not idempotent' (#20) from dachary/dashboard:wip-delete into master
ci/woodpecker/push/woodpecker Pipeline was successful Details
Reviewed-on: https://gitea.hostea.org/Hostea/dashboard/pulls/20
2022-07-02 10:48:01 -04:00
Loïc Dachary eefa2120a9
enough host delete is not idempotent
ci/woodpecker/pr/woodpecker Pipeline failed Details
pretend it is until
https://lab.enough.community/main/infrastructure/-/issues/359 is resolved
2022-07-02 16:43:51 +02:00
Aravinth Manivannan ccfa81ce2c Merge pull request 'feat: notify user on instance creation' (#14) from wip-instance-ready-notify into master
ci/woodpecker/push/woodpecker Pipeline was successful Details
Reviewed-on: https://gitea.hostea.org/Hostea/dashboard/pulls/14
2022-07-02 03:42:34 -04:00
Aravinth Manivannan 7464604928 Merge pull request 'feat: configurable VM base domain and customer Gitea and Woodpecker URI generators' (#12) from wip-hostea-domain into master
ci/woodpecker/push/woodpecker Pipeline was successful Details
Reviewed-on: https://gitea.hostea.org/Hostea/dashboard/pulls/12
2022-07-02 03:42:15 -04:00
Aravinth Manivannan 4a47543a0f
hostfix: use default source code link when settings.py doesn't provide one
ci/woodpecker/push/woodpecker Pipeline was successful Details
ci/woodpecker/pr/woodpecker Pipeline failed Details
2022-07-01 20:59:10 +05:30
Aravinth Manivannan e5ebdc29ce
feat: CI: replace fleet repo remote URI with remote URI template
ci/woodpecker/push/woodpecker Pipeline was successful Details
ci/woodpecker/pr/woodpecker Pipeline failed Details
2022-07-01 19:57:22 +05:30
Aravinth Manivannan f86dd2ff37
feat: delete_vm takes only one parameter 2022-07-01 19:54:20 +05:30
Aravinth Manivannan 8fc20d16be
feat: ues separate fleet repo for each unit test 2022-07-01 19:54:15 +05:30
Aravinth Manivannan bbcd373fe4
feat: redirect to VM deletion post sudo authentication 2022-07-01 19:53:00 +05:30
Aravinth Manivannan 412230bd99
feat: create repo and add deploy key util 2022-07-01 19:52:10 +05:30
Aravinth Manivannan 8be1e02a21
feat: load footer ctx in all templates
ci/woodpecker/push/woodpecker Pipeline was successful Details
ci/woodpecker/pr/woodpecker Pipeline failed Details
2022-06-30 14:37:49 +05:30
Aravinth Manivannan faca7286b7
feat: load Dashboard source code repository URL from settings 2022-06-30 14:33:56 +05:30
Aravinth Manivannan 9d89bc071c
fet: show Gitea and woodpecker URIs in view instance page 2022-06-30 13:05:57 +05:30
Aravinth Manivannan f00746a36d
feat: notify user on instance creation
ci/woodpecker/push/woodpecker Pipeline was successful Details
ci/woodpecker/pr/woodpecker Pipeline failed Details
2022-06-30 01:10:55 +05:30
Aravinth Manivannan 53ec0a3982
fix: woodpecker and gitea construction typo
ci/woodpecker/push/woodpecker Pipeline was successful Details
ci/woodpecker/pr/woodpecker Pipeline failed Details
2022-06-30 01:08:22 +05:30
Aravinth Manivannan fc5a23e60a
feat: configurable VM base domain and customer Gitea and Woodpecker URI generators
ci/woodpecker/push/woodpecker Pipeline was successful Details
ci/woodpecker/pr/woodpecker Pipeline failed Details
SUMMARY

    The hostnames are partially generated by the Dashboard and
    enough.community.

    The stuff between angle brackets(`<>`) are substituted and filled-in
    by the Dashboard and the stuff between parenthesis(`{}`) are
    substituted and filled-in by enough.

URI FORMAT

    Gitea URI
	<vm-name>.{{ domain }}

    Woodpecker URI
	<vm-name>-ci.{{ domain }}

    Where domain is agreed to be equal to HOSTEA_DOMAIN

fixes: https://gitea.hostea.org/Hostea/dashboard/issues/11
2022-06-29 11:05:33 +05:30
Aravinth Manivannan e4c418b45b
feat: show Gitea admin's login credentials and send creds via email to admin
ci/woodpecker/push/woodpecker Pipeline was successful Details
2022-06-29 00:49:58 +05:30
Aravinth Manivannan 1bab17193c
fix: sender's email addres typo in send_verification_email 2022-06-29 00:49:35 +05:30
Aravinth Manivannan b123bfa582
feat: grab commit ID after add_vm execution
ci/woodpecker/push/woodpecker Pipeline was successful Details
2022-06-29 00:27:47 +05:30
Aravinth Manivannan 5ec87c83ec
feat: redirect user after successful payments for VM creation 2022-06-29 00:22:49 +05:30
Aravinth Manivannan e63719764a
fix: idempotency: change configuration in fleet repository too, when vm
ci/woodpecker/push/woodpecker Pipeline was successful Details
create is re-run for the same VM with different configuration

fixes: https://gitea.hostea.org/Hostea/dashboard/issues/8
2022-06-28 23:57:02 +05:30
Aravinth Manivannan f7c0e8e296
chore: auto-cleanup ~/.ssh/known_hosts 2022-06-28 23:49:24 +05:30
Aravinth Manivannan 49ae2189d4
feat & fix: make vm create/rm commands idempotent
SUMMARY
    Commands are now tolerant to being invoked twice.

    Command: vm create
	Doesn't fail if VM of same name exists with the same
	configuration

	Doesn't fail if VM of the same name and different configuration
	exist. Updates configuration and deploys(pushes to Hostea/fleet
	repository) new configuration.

    Command: vm delete
	Doesn't fail if VM of given name doesn't exist
2022-06-28 20:54:21 +05:30
Aravinth Manivannan 8baefeb413
fix: don't save Gitea admin passwords in DB 2022-06-28 20:53:56 +05:30
Aravinth Manivannan e4a7310c79
feat & fix: don't append enough commands to hostscript and fix service.yml path
ci/woodpecker/push/woodpecker Pipeline was successful Details
2022-06-28 14:47:21 +05:30
Aravinth Manivannan d4ab0156a7 Merge pull request 'gitea runs on port 22, ssh on port 2222' (#10) from dachary/dashboard:wip-service into master
ci/woodpecker/push/woodpecker Pipeline failed Details
Reviewed-on: https://gitea.hostea.org/Hostea/dashboard/pulls/10
2022-06-28 04:53:23 -04:00
Loïc Dachary 1eaa22b330
gitea runs on port 22, ssh on port 2222
ci/woodpecker/pr/woodpecker Pipeline failed Details
2022-06-28 10:50:17 +02:00
Aravinth Manivannan 947479fc31
fix: enough remove command was hardcoded; fixed with customizable param
ci/woodpecker/push/woodpecker Pipeline failed Details
2022-06-28 13:49:43 +05:30
Aravinth Manivannan f68d051432
fix: provision.yml template error
ci/woodpecker/push/woodpecker Pipeline failed Details
ref: https://gitea.hostea.org/Hostea/dashboard/issues/9
2022-06-28 13:37:02 +05:30
Aravinth Manivannan caadd0783a
fix: hostscript path
ci/woodpecker/push/woodpecker Pipeline failed Details
fixes: https://gitea.hostea.org/Hostea/dashboard/issues/7
2022-06-28 12:00:47 +05:30
Aravinth Manivannan 71d4f793ba
feat: docs: vm management commands
ci/woodpecker/push/woodpecker Pipeline was successful Details
2022-06-28 01:31:42 +05:30
Aravinth Manivannan 927c2a7703
feat: vm delete management command
ci/woodpecker/push/woodpecker Pipeline was successful Details
2022-06-28 01:24:43 +05:30
Aravinth Manivannan 0606c4ade0
feat: vm create management command 2022-06-28 00:57:25 +05:30
Aravinth Manivannan d84021915f
fix: typo 2022-06-28 00:56:34 +05:30
Aravinth Manivannan 026a1a4c12
chore: refactor infrastructure/views.py; move VM creation to utility fn 2022-06-27 20:59:24 +05:30
Aravinth Manivannan 2dc1740aac
chore: refactor instance creation view 2022-06-27 20:43:02 +05:30
Aravinth Manivannan 3318ca8da2
feat: infrastructure tests: check if commits are pushed to remote
ci/woodpecker/push/woodpecker Pipeline was successful Details
2022-06-27 04:53:52 +05:30
Aravinth Manivannan 8640fcf449
fix: ssh deploy key perms
ci/woodpecker/push/woodpecker Pipeline was successful Details
2022-06-27 04:43:28 +05:30
Aravinth Manivannan f99420f51a
fix: ci gitea port
ci/woodpecker/push/woodpecker Pipeline failed Details
2022-06-27 04:40:41 +05:30
Aravinth Manivannan 8997d0ff0f
chore: cleanup config override in infrastructure/tests.py
ci/woodpecker/push/woodpecker Pipeline failed Details
2022-06-27 04:37:56 +05:30
Aravinth Manivannan ca8ffba55e
feat: setup CI to use CI gitea 2022-06-27 04:36:56 +05:30
Aravinth Manivannan 89d8206c34
feat: CI: load deploy key from oenv var 2022-06-27 04:36:23 +05:30
Aravinth Manivannan 9d6c33f194
feat: add infrastructure env vars 2022-06-27 04:35:45 +05:30
Aravinth Manivannan 0c0bb1bed7
feat: refactor and create commit 0 on fleet repository 2022-06-27 04:30:25 +05:30
Aravinth Manivannan 51b047fe40
fix: ssh port. server is started at 22 2022-06-27 04:30:12 +05:30
Aravinth Manivannan 6388e4de10
feat: CI local_settings.py loads config from env vars
ci/woodpecker/push/woodpecker Pipeline failed Details
2022-06-27 02:44:49 +05:30
Aravinth Manivannan 243880f6cc
feat: re-enable gitea service in docker-compose and CI env setup 2022-06-27 02:43:16 +05:30
Aravinth Manivannan 9c64690c12
feat: add test deployment keys 2022-06-26 04:52:01 +05:30
Aravinth Manivannan a4a34194f3
feat: add deploy key client implementation 2022-06-26 04:51:29 +05:30
Aravinth Manivannan 0dac5121fd
feat: enable gitea service and mv vars to separate script 2022-06-26 04:19:02 +05:30
Aravinth Manivannan 6115e734e6
feat: pkg docker 2022-06-26 04:19:02 +05:30
Aravinth Manivannan 442dd921a8
debug: is dashboard accessible? 2022-06-26 04:19:02 +05:30
Aravinth Manivannan 4996e33cad
debug: is maildev accessible? 2022-06-26 04:19:02 +05:30
Aravinth Manivannan b3ffe8c739
fix: run only tests only once 2022-06-26 04:19:01 +05:30
Aravinth Manivannan 28fe03b861
fix: run wget in quiet mode and adapt MAILDEV_URL based on environment 2022-06-26 04:19:01 +05:30
Aravinth Manivannan fb5267a13b
hotfix: run gitea on host 2022-06-26 04:19:01 +05:30
Aravinth Manivannan f019039497
hot fix: disable gitea service 2022-06-26 04:19:01 +05:30
Aravinth Manivannan 3c33d10ca0
fix: mv test dependency services to woodpecker config file 2022-06-26 04:19:01 +05:30
Aravinth Manivannan da318beb58
chore: install docker-compose in CI 2022-06-26 04:19:01 +05:30
Aravinth Manivannan 997e772195
fix: woodpecker config file syntax 2022-06-26 04:19:01 +05:30
Aravinth Manivannan 798a2f03d9
feat: integration testing
SUMMARY
    integration/__main__.py is a CLI-based HTTP client that can interact
    with Hostea Dashboard and Gitea.

    Integration tests are run via integration/tests.sh, which is a
    driver for the HTTP client at integration/__main__.py. The script is
    capable of spinning up a test environment consisting of services
    defined in docker-compose-dev-deps.yml and the Hostea Dashboard and
    tearing it down after a successful run.

    The credentials used to create various accounts and other parameters
    are all defined in integration/tests.sh script it self. So it is
    self contained.

CLIENT FUNCTIONALITY:

    HOSTEA DASHBOARD:
	 - register user with email verification
	 - login
	 - create OIDC app
	 - visit support page

    GITEA:
	 - Install Gitea(DB configuration, etc. The first form that's
	 presented to the visitor after a new instance is deployed)
	 - Register User
	 - Login User
	 - Create repository
	 - Configure OIDC SSO
	 - Login via SSO
2022-06-26 04:19:01 +05:30
Aravinth Manivannan 3fb756bd12
feat: use local gitea instance for hostea support in dev 2022-06-26 04:19:01 +05:30
Aravinth Manivannan 2defc2d804
chore: run dependency services in test script via docker-compose-dev-deps 2022-06-26 04:19:01 +05:30
Aravinth Manivannan 08457c8bb2
feat: define dev env with smtp and gitea services 2022-06-26 04:19:01 +05:30
Aravinth Manivannan 4b20f9a439
feat: Dashboard-Gitea SSO integration test script
STEPS
    1. Register new user on dashboard

    2. Confirm user email, link is received from email. maildev/maildev
       is an SMTP server specifically built for testing emails locally.
       It comes with a REST API[0], which is used to access emails

    3. Sign in to Dashboard

    4. Visit /support/new/ on dashboard to raise new support request

    5. Redirection to Hostea Gitea support repository is done via
       JavaScript, so we simply test to see if the support repository's
       new issue page is present in the Dashboard response

    6. Go to support repository's new issue page. Gitea will redirect to
       sign in page

    7. Parse sign in page, find OIDC SSO link in sign in page

    8. Visit OIDC SSO link in sign in page, to be redirected to
       authorization page

    9. If OIDC integration on Dashboard is setup via `create_oidc`
       management command, then auto-authorization will be enabled for
       the integration. So user will be redirected to Gitea

    10. For new OIDC logins, Gitea will present a form to choose
	preferred username and enter email address. So fill that form
	and submit it.

	Please note the form submits to a different URL than the one at
	which the form is available. See `Gitea.__link_acount` and
	`Gitea.__link_acount_signup` and its usage in `Gitea._sso_login`

    11. Verify user creation by GET /{username}, should respond HTTP 200

    12. Visit new issue on support repository, should respond HTTP 200

RESOURCES
    [0]: https://github.com/maildev/maildev/blob/master/docs/rest.md
2022-06-26 04:19:01 +05:30
Aravinth Manivannan 4542389df8
fix: import vars defined in local_settings.py
ci/woodpecker/push/woodpecker Pipeline failed Details
fixes https://gitea.hostea.org/Hostea/dashboard/issues/5
2022-06-26 04:17:26 +05:30
Aravinth Manivannan 3378e61606
hotfix: use dashboard/local_settings.py instead of env vars
ci/woodpecker/pr/woodpecker Pipeline failed Details
ci/woodpecker/push/woodpecker Pipeline failed Details
My env var loading technique is not allowing local_settings.py to
override settings.py. This hotfix disables env vars in favor of
local_settings.py.

fixes https://gitea.hostea.org/Hostea/dashboard/issues/3
2022-06-26 01:49:32 +05:30
Aravinth Manivannan e7446dea2b Merge pull request 'allow overriding STRIPE_* with local_settings.py' (#2) from dachary/dashboard:wip-settings into master
ci/woodpecker/push/woodpecker Pipeline failed Details
Reviewed-on: https://gitea.hostea.org/Hostea/dashboard/pulls/2
2022-06-25 15:59:53 -04:00
Loïc Dachary adcdd00179
allow overriding STRIPE_* with local_settings.py
ci/woodpecker/pr/woodpecker Pipeline failed Details
Without a default value it will fail before it gets a chance to be
overriden by local_settings.py

Signed-off-by: Loïc Dachary <loic@dachary.org>
2022-06-25 21:29:04 +02:00
Aravinth Manivannan b387e44f49
feat: docs: local_settings.example.py
ci/woodpecker/push/woodpecker Pipeline failed Details
2022-06-25 18:56:54 +05:30
Aravinth Manivannan 0d6968ff0a
feat: custom parameters template
ci/woodpecker/push/woodpecker Pipeline failed Details
2022-06-25 18:42:42 +05:30
Aravinth Manivannan a39bcdb7b8
feat: disable i8ln as it's not implemented yet
> Django’s internationalization hooks are on by default, and that means
there’s a bit of i18n-related overhead in certain places of the
framework. If you don’t use internationalization, you should take the
two seconds to set USE_I18N = False in your settings file. Then Django
will make some optimizations so as not to load the internationalization
machinery. # Please enter the commit message for your changes. Lines
starting

ref: https://docs.djangoproject.com/en/4.0/topics/i18n/translation/
2022-06-25 18:42:41 +05:30
Aravinth Manivannan f0ee46e045 Merge pull request 'Backend integration' (#1) from wip-enough into master
ci/woodpecker/push/woodpecker Pipeline failed Details
Reviewed-on: https://gitea.hostea.org/Hostea/dashboard/pulls/1

Merge approval received on chat
2022-06-25 09:11:56 -04:00
Aravinth Manivannan 26b7ea3ef2
fix & rm: create/rm hostscripts, rm HOSTEA_DOMAIN
ci/woodpecker/push/woodpecker Pipeline failed Details
ci/woodpecker/pr/woodpecker Pipeline failed Details
2022-06-25 18:24:52 +05:30
Aravinth Manivannan 871a05ddd3
feat: payment check before creation and save gitea passwd in DB
ci/woodpecker/push/woodpecker Pipeline failed Details
ci/woodpecker/pr/woodpecker Pipeline failed Details
2022-06-25 18:03:04 +05:30
Aravinth Manivannan beb4b29c49
feat: pass template configuration, map VM sizes, generate secrets
return gitea passwd, git pull before writing and push after add/rm
2022-06-25 18:02:03 +05:30
Aravinth Manivannan 9af5361f63
feat: load local settings 2022-06-25 18:01:39 +05:30
Aravinth Manivannan 922d0c5f81
fix: don't create additional configuration opts 2022-06-25 18:01:08 +05:30
Aravinth Manivannan 94aad8e6ea
fix: templates: load user credentials and pass dynamic configuration.
Also escape curly braces
2022-06-25 18:00:13 +05:30
Aravinth Manivannan 80d6664f0d
feat: load VM domain from settings 2022-06-25 17:57:23 +05:30
Aravinth Manivannan ec49caa973
feat: payment status checking util 2022-06-25 16:27:43 +05:30
Aravinth Manivannan e688528fa3
fix: check payment status on instance level, used to be user level 2022-06-25 16:27:26 +05:30
Aravinth Manivannan 9f55a8ced7
feat: docs: hostea infrastructure config parameters
ci/woodpecker/push/woodpecker Pipeline failed Details
ci/woodpecker/pr/woodpecker Pipeline failed Details
2022-06-24 20:38:37 +05:30
Aravinth Manivannan f3324579c9
feat: utilities to add and remove VM on the Hostea repo 2022-06-24 20:35:32 +05:30
Aravinth Manivannan 1a234d402f
feat: init templates from enough docs[0]
[0]: https://enough-community.readthedocs.io/en/latest/services/hostea.html
2022-06-24 20:35:00 +05:30
Aravinth Manivannan ff8a21d9dc
feat: bootstrap infrastructure app with create_instance delete_instance
views
2022-06-24 20:34:11 +05:30
Aravinth Manivannan 04ec4037a9
feat: init gitpython and infrastructure app 2022-06-24 20:33:32 +05:30
Aravinth Manivannan 19ed720b82
feat: mv redirect if authenticated to decorator and guard other
ci/woodpecker/push/woodpecker Pipeline was successful Details
sigin/signup views
2022-06-22 00:43:10 +05:30
Aravinth Manivannan 96e71d7c32
fix: auto-redirect authenticated user when visiting login page 2022-06-22 00:43:10 +05:30
Aravinth Manivannan f6c89999e9
feat: test account verification email 2022-06-22 00:43:10 +05:30
Aravinth Manivannan 19682874ba
feat: payments system configuration docs
ci/woodpecker/push/woodpecker Pipeline was successful Details
2022-06-22 00:40:06 +05:30
Aravinth Manivannan d470033429
feat: implement billing with stripe
SUMMARY
    PAYMENT WORKFLOW
	1. User is redirected after a new instance is created into a view
	   that generates invoice. There are checks in place to ensure
	   invoices are not generated twice for the same VM. There is also a
	   check in place to generate invoices for time periods that are
	   already paid for
	2. User is redirected to payment form
	3. Stripe takes over
	4. If payment is successful, user is redirected to success page
	5. If payment failed, user is redirected to failure page

    PENDING INVOICES
	The user can see pending invoices on their dashboard

    PAYMENT RECEIPTS
	The user can see payment receipts on their dashboard
2022-06-22 00:37:03 +05:30
Aravinth Manivannan 760c0e90af
feat: create_instance_util test utility 2022-06-22 00:36:59 +05:30
Aravinth Manivannan 4908754b0d
feat: init billing app 2022-06-22 00:36:46 +05:30
Aravinth Manivannan 743f3447e7
feat: redirect to invoice after instance creation 2022-06-21 23:31:04 +05:30
Aravinth Manivannan bddd7a88b2
feat: link billing views in secondary nav bar 2022-06-21 23:30:20 +05:30
Aravinth Manivannan 8507129063
feat: create_oidc management command to create SSO integration for
ci/woodpecker/push/woodpecker Pipeline was successful Details
Hostea
2022-06-19 22:25:33 +05:30
Aravinth Manivannan cc1ecaf6a0
feat: init django-oauth-toolkit 2022-06-19 22:25:27 +05:30
Aravinth Manivannan a04cbf0943
feat: password strength validation during registration and migrate tests to cope with it
ci/woodpecker/push/woodpecker Pipeline was successful Details
2022-06-19 21:23:38 +05:30
Aravinth Manivannan faa7e924cc
feat: get_user_id management command
ci/woodpecker/push/woodpecker Pipeline was successful Details
DESCRIPTION
    Gets the DB assigned ID associated with a username
2022-06-19 21:02:38 +05:30
Aravinth Manivannan 38619babc7
feat: improve view VM styling and show VM configuration 2022-06-19 15:23:50 +05:30
Aravinth Manivannan 429934c795
fix: insert default instance configurations using migrations scripts
ci/woodpecker/push/woodpecker Pipeline was successful Details
2022-06-19 13:36:28 +05:30
Aravinth Manivannan 3f7f9fc1ed
fix: run migrations before testing
ci/woodpecker/push/woodpecker Pipeline failed Details
2022-06-18 22:20:41 +05:30
Aravinth Manivannan d5dc06be18
feat: views for listing, viewing and deleting specific VMs
ci/woodpecker/push/woodpecker Pipeline failed Details
2022-06-18 22:12:41 +05:30
Aravinth Manivannan 2fb1a3d0d1
fix: one user can have multiple instances; OneToOneField -> ForeignKey 2022-06-18 21:56:02 +05:30
Aravinth Manivannan 627087cf0e
feat: sudo view 2022-06-18 21:54:31 +05:30
Aravinth Manivannan 2ccf3d9679
feat: confirm access decorator
DESCRIPTION
    Some views are privileged and unauthorized execution can have
    irreversible changes. confirm_access decorator checks if the user's
    session is verified for privileged operation execution.

    If not, it will redirect user to "accounts.sudo" vie" vie" vie" view
2022-06-18 21:52:18 +05:30
Aravinth Manivannan 1e7d45d53b
fix: login redirection 2022-06-18 20:02:54 +05:30
Aravinth Manivannan ca8bb56d6c
fix: logout route was being served by wrong handler and tests
ci/woodpecker/push/woodpecker Pipeline failed Details
2022-06-18 19:53:26 +05:30
Aravinth Manivannan ce5694d56a
fix: create VM form styling
ci/woodpecker/push/woodpecker Pipeline failed Details
2022-06-18 14:07:04 +05:30
Aravinth Manivannan bdf8f6989f
chore: improve coverage
ci/woodpecker/push/woodpecker Pipeline failed Details
2022-06-18 13:54:03 +05:30
Aravinth Manivannan 39e54df5ef
feat: create default VM configurations on initialization
ref:
    [1] https://gitea.hostea.org/Hostea/july-mvp/issues/10#issuecomment-639
    [2] https://gitea.hostea.org/Hostea/july-mvp/issues/10#issuecomment-642
    [3] https://gitea.hostea.org/Hostea/july-mvp/issues/10#issuecomment-643
2022-06-18 13:52:52 +05:30
Aravinth Manivannan 99a7533a79
feat: test coverage report generation
ci/woodpecker/push/woodpecker Pipeline was successful Details
2022-06-18 00:07:56 +05:30
Aravinth Manivannan 5c8e36ad9d
fix: add rent field to tests
ci/woodpecker/push/woodpecker Pipeline was successful Details
2022-06-18 00:02:18 +05:30
Aravinth Manivannan 391a3502e7
fix: add rent field to instance config
ci/woodpecker/push/woodpecker Pipeline failed Details
2022-06-17 23:56:19 +05:30
Aravinth Manivannan 67d657e8fd
feat: change instance configuration display styling 2022-06-17 23:55:30 +05:30
Aravinth Manivannan d15eb7ae3d
feat: add instance view 2022-06-17 23:29:11 +05:30
Aravinth Manivannan 3705c64616
feat: add instance configuration form visible only to admins
ci/woodpecker/push/woodpecker Pipeline was successful Details
2022-06-17 20:33:48 +05:30
Aravinth Manivannan 3be96ed131
feat: docs: support platform configuration 2022-06-17 19:19:23 +05:30
Aravinth Manivannan 328b44e729
feat: support app
ci/woodpecker/push/woodpecker Pipeline was successful Details
Summary
    Support app shows links to user to create new issue on the Hostea
    meta repository(configurable via settings.py) and view open issues.

    (auto)Redirection via dashboard to new issue page on Gitea and issue
    tracker repository is setup. In future, a form will be exposed
    within the dashboard itself to streamline support related workflows.
2022-06-17 18:12:02 +05:30
Aravinth Manivannan d2fc48f399
feat: add support links to secondary nav 2022-06-17 17:27:49 +05:30
Aravinth Manivannan 5a10b06e11
feat & chore: list logged in user in nav & linting 2022-06-17 17:02:39 +05:30
Aravinth Manivannan 64b4437acd
feat: bootstrap dashboard templates and dashboard homepage view
ci/woodpecker/push/woodpecker Pipeline was successful Details
2022-06-17 16:03:13 +05:30
Aravinth Manivannan 1a0ca0117a
feat: init dash app 2022-06-17 16:03:05 +05:30
Aravinth Manivannan 92a50b8a7a
fix: duplicate main tag 2022-06-17 15:37:32 +05:30
Aravinth Manivannan 11b6a25878
feat & fix: redirect to dash and show page title for login and register 2022-06-17 14:40:42 +05:30
Aravinth Manivannan bd9155dad1
fix: registration page url in nav bar 2022-06-17 14:39:10 +05:30
194 changed files with 7241 additions and 158 deletions

148
.dockerignore Normal file
View File

@ -0,0 +1,148 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
databse.db
.env
node_modules/
dist/
tmp/
northstar.db
instance
northstar/static/docs/openapi

View File

@ -1,3 +1,7 @@
export DATABASE_URL=""
export db=""
export OIDC_RSA_PRIVATE_KEY=""
export STRIPE_SECRET_KEY=""
export STRIPE_PUBLIC_KEY=""
export HOSTEA_INFRA_HOSTEA_REPO_REMOTE="ssh://git@localhost:22/hostea/fleet.git"
export HOSTEA_META_FORGEJO_INSTANCE="http://localhost:3000"
export HOSTEA_INFRA_HOSTEA_REPO_SSH_KEY="$(realpath ./tests/fleet-deploy-key)"

3
.gitignore vendored
View File

@ -152,3 +152,6 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
keys
htmlcov/
tmp/
static/

View File

@ -3,12 +3,17 @@ pipeline:
image: python
environment:
- DATABSE_URL=postgres://postgres:password@database:5432/postgres
- EMAIL_URL=smtp://admin:password@localhost:10025
- EMAIL_URL=smtp://admin:password@smtp:10025
- HOSTEA_INFRA_HOSTEA_REPO_REMOTE=ssh://git@forgejo:22/hostea/
- HOSTEA_META_FORGEJO_INSTANCE=http://forgejo:3000
commands:
- export HOSTEA_INFRA_HOSTEA_REPO_SSH_KEY="$(realpath ./tests/fleet-deploy-key)"
- pip install virtualenv
- make env
- make lint
- make test
- make coverage
# - make integration-test
secrets: [ STRIPE_PUBLIC_KEY, STRIPE_SECRET_KEY ]
services:
database:
@ -16,9 +21,15 @@ services:
environment:
- POSTGRES_PASSWORD=password
forgejo:
image: codeberg.org/forgejo/forgejo:1.18.0-1
container_name: hostea-dash-forgejo
smtp:
image: maildev/maildev
image: maildev/maildev:latest
container_name: hostea-dash-maildev
environment:
- MAILDEV_SMTP_PORT=10025
- MAILDEV_WEB_PORT=1080
- MAILDEV_INCOMING_USER=admin
- MAILDEV_INCOMING_PASS=password

19
Dockerfile Normal file
View File

@ -0,0 +1,19 @@
FROM python
LABEL org.opencontainers.image.source https://forgejo.hostea.org/Hostea/dashboard
RUN useradd -ms /bin/bash -u 1001 hostea
RUN apt-get update && apt-get install -y ca-certificates git
USER hostea
WORKDIR /home/hostea
run mkdir app/
WORKDIR /home/hostea/app/
RUN pip3 install virtualenv
RUN python3 -m virtualenv venv
COPY requirements.txt .
# See https://github.com/pypa/pip/issues/9819
RUN ./venv/bin/pip install --use-feature=in-tree-build -r requirements.txt
COPY . .
#ENV . ./venv/bin/activate && make env
CMD [ "./venv/bin/python3", "manage.py", "runserver", "0.0.0.0:8000" ]

View File

@ -9,10 +9,13 @@ endef
default: ## Run app
$(call run_migrations)
. ./venv/bin/activate && yes yes | python manage.py collectstatic
. ./venv/bin/activate && python manage.py runserver
coverage: ## Generate test coverage report
$(call unimplemented)
. ./venv/bin/activate && coverage run manage.py test
. ./venv/bin/activate && coverage report -m
. ./venv/bin/activate && coverage html
doc: ## Generates documentation
$(call unimplemented)
@ -23,6 +26,8 @@ docker: ## Build Docker image from source
env: ## Install all dependencies
@-virtualenv venv
. ./venv/bin/activate && pip install -r requirements.txt
. ./venv/bin/activate && ./integration/ci.sh init
. ./venv/bin/activate && yes yes | python manage.py collectstatic
freeze: ## Freeze python dependencies
@. ./venv/bin/activate && pip freeze > requirements.txt
@ -30,9 +35,11 @@ freeze: ## Freeze python dependencies
help: ## Prints help for targets with comments
@cat $(MAKEFILE_LIST) | grep -E '^[a-zA-Z_-]+:.*?## .*$$' | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
integration-test: ## run integration tests
. ./venv/bin/activate && integration/tests.sh
lint: ## Run linter
@./venv/bin/black ./dashboard/*
@./venv/bin/black ./accounts/*
@./venv/bin/black dashboard accounts dash support billing infrastructure integration
migrate: ## Run migrations
$(call run_migrations)

View File

@ -2,7 +2,7 @@
# Hostea dashboard
[![status-badge](https://woodpecker.hostea.org/api/badges/Hostea/dashboard/status.svg)](https://woodpecker.hostea.org/Hostea/dashboard)
[![status-badge](https://woodpecker.gna.org/api/badges/Hostea/dashboard/status.svg)](https://woodpecker.gna.org/Hostea/dashboard)
[![AGPL License](https://img.shields.io/badge/license-AGPL-blue.svg?style=flat-square)](http://www.gnu.org/licenses/agpl-3.0)
[![Chat](https://img.shields.io/badge/matrix-hostea:matrix.batsense.net-purple?style=flat-square)](https://matrix.to/#/#hostea:matrix.batsense.net)

43
accounts/decorators.py Normal file
View File

@ -0,0 +1,43 @@
# Copyright © 2022 Aravinth Manivannan <realaravinth@batsense.net>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from django.shortcuts import redirect
from django.urls import reverse
from .utils import ConfirmAccess
def confirm_access(function):
def wrap(request, *args, **kwargs):
return ConfirmAccess.validate_decorator(
request=request, fn=function, *args, **kwargs
)
return wrap
def redirect_if_authenticated(fn):
"""
Redirect authenticated users visiting sign in/sign up views
"""
def wrap(request, *args, **kwargs):
if request.user.is_authenticated:
data = request.GET if request.method == "GET" else request.POST
if "next" in data:
return redirect(data["next"])
return redirect(reverse("accounts.home"))
return fn(request, *args, **kwargs)
return wrap

View File

@ -0,0 +1,110 @@
# Copyright © 2022 Aravinth Manivannan <realaravinth@batsense.net>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from django.core.management.base import BaseCommand
from django.core.exceptions import ValidationError
from django.conf import settings
from django.contrib.auth import get_user_model
from oauth2_provider.models import get_application_model
from oauth2_provider.generators import generate_client_id, generate_client_secret
from accounts.utils import gen_secret
Application = get_application_model()
class Command(BaseCommand):
help = "Get user ID from username"
app_name_key = "app_name"
username_key = "username"
redirect_uri_key = "redirect_uri"
def add_arguments(self, parser):
parser.add_argument(self.app_name_key, type=str, help="The application name")
parser.add_argument(
self.username_key,
type=str,
help="The username of user who will own this app",
)
parser.add_argument(
self.redirect_uri_key,
type=str,
help="The username of user who will own this app",
)
def handle(self, *args, **options):
if self.username_key not in options:
self.stdout.write(self.style.ERROR("Please provide username"))
return
if self.app_name_key not in options:
self.stdout.write(self.style.ERROR("Please provide application name"))
return
if self.redirect_uri_key not in options:
self.stdout.write(self.style.ERROR("Please provide redirect uri"))
return
username = options[self.username_key]
application_name = options[self.app_name_key]
redirect_uri = options[self.redirect_uri_key]
User = get_user_model()
if not User.objects.filter(username=username).exists():
self.stderr.write(self.style.ERROR(f"user {username} not found"))
return
user = User.objects.get(username=username)
# python manage.py createapplication --name demo-oidc-app --user 1 --client-id 22500acb0bcfcba137d6b8ae96d3f2 --client-secret 296055337620b0e443ad24a32cb675 --algorithm HS256 --skip-authorization --redirect-uri http://example.org/uri1 confidential code -v
client_id = generate_client_id()
client_secret = generate_client_secret()
config = {
"name": application_name,
"user_id": user.id,
"client_id": client_id,
"client_secret": client_secret,
"algorithm": "HS256",
"skip_authorization": True,
"redirect_uris": redirect_uri,
"authorization_grant_type": "authorization-code",
"client_type": "confidential",
}
app = Application(**config)
try:
app.full_clean()
except ValidationError as exc:
errors = "\n ".join(
[
"- " + err_key + ": " + str(err_value)
for err_key, err_value in exc.message_dict.items()
]
)
self.stdout.write(
self.style.ERROR("Please correct the following errors:\n %s" % errors)
)
else:
app.save()
self.stdout.write(
self.style.SUCCESS(
f"New application {application_name} created successfully."
)
)
self.stdout.write(f"client_id: {client_id}")
self.stdout.write(f"client_secret: {client_secret}")

View File

@ -0,0 +1,52 @@
# Generated by Django 4.0.3 on 2022-07-10 06:14
import accounts.utils
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
("accounts", "0005_accountconfirmchallenge_created_at"),
]
operations = [
migrations.CreateModel(
name="PasswordResetChallenge",
fields=[
(
"public_ref",
models.CharField(
default=accounts.utils.gen_secret,
editable=False,
max_length=32,
unique=True,
verbose_name="Public referece to challenge text",
),
),
("created_at", models.DateTimeField(auto_now_add=True)),
(
"challenge_text",
models.CharField(
default=accounts.utils.gen_secret,
editable=False,
max_length=32,
primary_key=True,
serialize=False,
unique=True,
verbose_name="Challenge text",
),
),
(
"owned_by",
models.OneToOneField(
on_delete=django.db.models<