Commit Graph

1336 Commits

Author SHA1 Message Date
Flori 82a3f98db7
bump package versions (#458) 2024-01-11 19:51:27 +01:00
bitfl0wer 7fdb4bae49
bump package versions 2024-01-11 19:36:36 +01:00
bitfl0wer de42299fd0
bump reqwest to 0.11.23 2024-01-11 19:30:40 +01:00
bitfl0wer b87af21c31
Revert last commit 2023-12-17 22:16:53 +01:00
bitfl0wer e0492bb2f6
Add MANAGE_ENCRYPTION permission 2023-12-17 20:47:52 +01:00
Flori abd25b2040
merge backend branch into dev (#454) 2023-12-15 00:22:46 +01:00
Flori 7a517b3663
Well known required (#456)
Title: Add User Authentication Feature

Description:

This pull request introduces user authentication functionality to our
web application. The main goal of this feature is to ensure that each
action performed on the platform is tied to a valid, logged-in user,
thus providing accountability and maintaining data security.

Changes:

New models: Added the User model to represent users in our system. This
model includes fields: username, password_hash, email etc.

User seriliazer and views: Implemented serializers and API views for
user registration, login, and logout.

Authentication Middlewares: Added middlewares to check for a valid
session or token before allowing access to certain views.

Tests: Included comprehensive test coverage for the new feature. Tests
were implemented to verify user registration, login, and logout
functionality, as well as checking authentication enforcement on
applicable views.

    Documentation: Updated API documentation related to User endpoints.

This feature is expected to improve the overall security of our
application by properly managing user sessions and actions.

Note: You will see references to some helper tools like make_password
and check_password methods, these are security measures to ensure we are
not storing plain text passwords in the database.

This PR follows our Python coding standards and is fully linted and
tested.

Requesting review and feedback. If all points are clear and no issues
are detected during the review, we would appreciate it if this PR could
be merged at the earliest convenience.

Related Issue: #123
2023-12-15 00:22:36 +01:00
bitfl0wer fd3aad03e3
Refactor instance creation 2023-12-15 00:10:33 +01:00
Flori b319f3f720
Update docs (#453) 2023-12-10 18:51:32 +01:00
bitfl0wer ce6f09b657
Update documentation and examples 2023-12-10 18:40:03 +01:00
bitfl0wer 6b0fd238c8
Update cargo lock 2023-12-10 18:37:38 +01:00
bitfl0wer 1cbeba45c4
Merge branch 'dev' 2023-12-03 22:37:28 +01:00
bitfl0wer bbdcd35b60
Bump version 2023-12-03 22:35:45 +01:00
Flori 5ff206db8a
QoL Updates (#452)
- Make register and login not take an instance by ownership
- Add README information to `lib.rs`
- Add more derives to ChorusUser and Instance
- Impl From reqwest::Error for ChorusError
- Add support for .well-known #449 
- Remove "limited: bool" as an argument for `Instance::new` in favour of
dynamic instance limit checking #450
2023-12-03 22:31:21 +01:00
bitfl0wer 565670c5b7
Remove limited argument from Instance 2023-12-03 21:44:08 +01:00
bitfl0wer dc1991a9cc
Make get_limits_config part of public api 2023-12-03 21:42:41 +01:00
bitfl0wer 37125e7973
Remove "limited" parameter 2023-12-03 21:34:44 +01:00
Flori 081a938749
Get URLs from .well-known (#451)
Closes #449.

+ `Instance::from_root_url(root_url: &str, limited: bool)`: Creates a
new Instance by trying to get the relevant instance urls (UrlBundle)
from a root url. Shorthand for
`Instance::new(UrlBundle::from_root_domain(root_domain).await?)`
+ `UrlBundle::from_root_url(url: &str)`: Performs a few HTTP requests to
try and retrieve a UrlBundle from an instance's root URL. The method
tries to retrieve the UrlBundle via these three strategies, in order:
- GET: $url/.well-known/spacebar -> Retrieve UrlBundle via
$wellknownurl/api/policies/instance/domains
    - GET: $url/api/policies/instance/domains
    - GET: $url/policies/instance/domains
    
The URL stored at .well-known/spacebar is the instance's API endpoint.
The API stores the CDN and WSS URLs under the
$api/policies/instance/domains endpoint. If all three of the above
approaches fail, it is very likely that the instance is misconfigured,
unreachable, or that a wrong URL was provided.
+ Add clippy warnings for: `clippy::todo,
    clippy::unimplemented,
    clippy::dbg_macro,
    clippy::print_stdout,
    clippy::print_stderr`
2023-12-03 16:05:58 +01:00
bitfl0wer 0553ecb753
wasm-safari CI seems to be bugged - disabling for now 2023-12-03 15:57:03 +01:00
bitfl0wer 0c92ffb64d
Try giving macos-safari its own cache key to fix CI 2023-12-03 15:06:09 +01:00
bitfl0wer df7ee4d2fc
Change macOS Safari test strategy to no-fail-fast 2023-12-03 14:18:14 +01:00
bitfl0wer 4ad1201032
Rename from_root_domain to from_root_url 2023-12-03 13:39:23 +01:00
bitfl0wer 7c5d7f731c
Add Instance::from_root_domain(), change documentation wording 2023-12-03 13:37:32 +01:00
bitfl0wer 906f2234f7
Add test if an example well-known response gets parsed correctly. 2023-12-03 13:33:24 +01:00
bitfl0wer bae3bc3aef
Write test to check basic functionality of UrlBundle::from_root_domain() 2023-12-03 13:29:38 +01:00
bitfl0wer d28ccf209a
check for dbg! println! eprintln! in production code 2023-12-03 13:28:50 +01:00
bitfl0wer dc263dbd5a
impl from_api_url 2023-12-03 13:16:34 +01:00
bitfl0wer 0e1f52edba
add warning lint for usage of todo!() 2023-12-03 13:13:57 +01:00
bitfl0wer 5792c61d09
move WellKnownResponse to src/types/ 2023-12-03 13:04:17 +01:00
bitfl0wer 8224acf897
Create domains_config, create Domains struct 2023-12-03 13:04:02 +01:00
bitfl0wer b6324173b5
clean up imports 2023-12-03 12:51:34 +01:00
bitfl0wer a27a3626f4
impl from_root_domain for UrlBundle 2023-12-03 12:49:22 +01:00
bitfl0wer 4aa45b3841
impl From reqwest::Error for ChorusError 2023-12-03 12:49:07 +01:00
bitfl0wer 367c0a8ca5
impl PartialEq for ChorusUser 2023-12-02 20:30:04 +01:00
Flori 81eda95ac0
More derives and impls (#448)
Add some sensible implementations for PartialEq, Eq, etc. where I found
them to be necessary
2023-12-02 17:52:31 +01:00
bitfl0wer 734cbf8d30
Mark code blocks as no-run 2023-12-02 17:44:24 +01:00
bitfl0wer 2a40f804c1
fix import order 2023-12-02 17:36:36 +01:00
bitfl0wer 28637ef731
Add Default, Hash, etc. where needed 2023-12-02 17:35:47 +01:00
Flori 4786d0c767
Update README.md 2023-11-25 13:26:24 +01:00
bitfl0wer c9501e6fad
Add README information into lib.rs 2023-11-24 22:21:57 +01:00
bitfl0wer 9336c7ac9b
Change text passages for better clarity 2023-11-24 21:37:30 +01:00
bitfl0wer 9d581441e8
Remove "prettyfyme" -> solved 2023-11-22 20:54:51 +01:00
Flori 371cf2efb3
Coverage, change register/login (#447)
Register and login, for some reason, required ownership of the
`Instance` object. This was not necessary and has been changed in this
PR. The PR also includes some extra tests, like logging in, logging in
with a token, etc.
2023-11-22 19:41:29 +01:00
bitfl0wer 05fd02a717
Add tests for coverage 2023-11-22 18:48:44 +01:00
bitfl0wer 7954e38643
Change: register/login no longer require ownership
Register/login used to require ownership of `instance`. This wasn't really necessary and has been changed.
2023-11-22 18:48:37 +01:00
bitfl0wer 72b954af00
Token login test 2023-11-22 18:38:23 +01:00
bitfl0wer eb71a77a2c
Update reqwest dependency to version 0.11.22 2023-11-22 17:32:22 +01:00
Flori a2e1567ecf
wasm support, bugfixes (#446)
This PR fixes #430 and enables full support for the
`wasm32-unknown-unknown` compilation target, making chorus the first(?)
Rust Discord-API implementation to support this target.
2023-11-22 17:30:20 +01:00
bitfl0wer fe5acc6e10
Update branch filter for push event 2023-11-22 16:43:48 +01:00
bitfl0wer b8b1a10c8b
Prevent CI from running twice on PR to main 2023-11-22 16:43:03 +01:00