Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overhaul core Tracker: refactor authentication module #1195

Closed
Tracked by #1181
josecelano opened this issue Jan 21, 2025 · 0 comments · Fixed by #1196
Closed
Tracked by #1181

Overhaul core Tracker: refactor authentication module #1195

josecelano opened this issue Jan 21, 2025 · 0 comments · Fixed by #1196
Assignees
Labels
- Developer - Torrust Improvement Experience Code Cleanup / Refactoring Tidying and Making Neat

Comments

@josecelano
Copy link
Member

josecelano commented Jan 21, 2025

Parent issue: #1181

I have extracted an authentication service from the core tracker here. However the authentication service is still used via the tracker public field authentication.

pub struct Tracker {
    /// The tracker configuration.
    config: Core,

    /// A database driver implementation: [`Sqlite3`](crate::core::databases::sqlite)
    /// or [`MySQL`](crate::core::databases::mysql)
    database: Arc<Box<dyn Database>>,

    /// The service to check if a torrent is whitelisted.
    pub whitelist_authorization: Arc<whitelist::authorization::Authorization>,

    /// The in-memory torrents repository.
    torrents: Arc<Torrents>,

    /// The service to authenticate peers.
    pub authentication: Arc<authentication::Facade>, // <--- This is the new authentication service
}

I called it Facade because I want to split the authentication service into more services. It still has many responsibilities.

I will implement that refactor in this issue. After this refactor I will be able to remove the authentication field from the tracker and use the new services directly in other parts of the code like Axum handlers.

At the end, what I expect to have it's something similar to what I did for the whitelist service. I expect to have:

  • A type to handle keys in database (database repository for keys).
  • A type to handle keys in memory (in-memory repository for keys).
  • A type to do some tasks like loading keys from database into memory, ... (keys manager).
  • A type to do the authentication (verify key). I want to separate this behavior because I think is big enough to be encapsulated in its own type and also to be able to mock it in tests.
@josecelano josecelano self-assigned this Jan 21, 2025
@josecelano josecelano added Code Cleanup / Refactoring Tidying and Making Neat - Developer - Torrust Improvement Experience labels Jan 21, 2025
josecelano added a commit to josecelano/torrust-tracker that referenced this issue Jan 21, 2025
We will add more submodules.
@josecelano josecelano linked a pull request Jan 21, 2025 that will close this issue
josecelano added a commit to josecelano/torrust-tracker that referenced this issue Jan 21, 2025
josecelano added a commit to josecelano/torrust-tracker that referenced this issue Jan 21, 2025
josecelano added a commit to josecelano/torrust-tracker that referenced this issue Jan 21, 2025
It was used to group methods by services in the old core tracker.
josecelano added a commit to josecelano/torrust-tracker that referenced this issue Jan 21, 2025
josecelano added a commit to josecelano/torrust-tracker that referenced this issue Jan 21, 2025
josecelano added a commit to josecelano/torrust-tracker that referenced this issue Jan 21, 2025
josecelano added a commit to josecelano/torrust-tracker that referenced this issue Jan 21, 2025
josecelano added a commit to josecelano/torrust-tracker that referenced this issue Jan 22, 2025
josecelano added a commit to josecelano/torrust-tracker that referenced this issue Jan 22, 2025
These tests do not require the authentication service.
josecelano added a commit to josecelano/torrust-tracker that referenced this issue Jan 22, 2025
josecelano added a commit to josecelano/torrust-tracker that referenced this issue Jan 22, 2025
josecelano added a commit to josecelano/torrust-tracker that referenced this issue Jan 22, 2025
…cade

The Facade will be replaced by its dependencies.
josecelano added a commit to josecelano/torrust-tracker that referenced this issue Jan 22, 2025
josecelano added a commit to josecelano/torrust-tracker that referenced this issue Jan 22, 2025
Instead of via the authentication::Facade. The Facade will be removed.
josecelano added a commit to josecelano/torrust-tracker that referenced this issue Jan 22, 2025
josecelano added a commit to josecelano/torrust-tracker that referenced this issue Jan 22, 2025
josecelano added a commit to josecelano/torrust-tracker that referenced this issue Jan 22, 2025
josecelano added a commit to josecelano/torrust-tracker that referenced this issue Jan 22, 2025
josecelano added a commit that referenced this issue Jan 22, 2025
dff6bca refactor: [#1195] remove authentication::Facade service (Jose Celano)
77eccdc fix: [#1195] format (Jose Celano)
661fe6a refactor: [#1195] remove AuthenticationService from authentication Facade (Jose Celano)
747b608 refactor: [#1195] use AuthenticationService directy (Jose Celano)
457d01b refactor: [#1195] rename service to AuthenticationService (Jose Celano)
965e911 refactor: [#1195] inject dependencies into authenticattion::Facade (Jose Celano)
504357c refactor: [#1195] inject dependencies in authenticatio::Facade (Jose Celano)
663250b refactor: [#1195] rename methods (Jose Celano)
9c61b26 refactor: [#1195] move tests to KeysHandler (Jose Celano)
c06da07 refactor: [#1195] more authentication tests to authentication service (Jose Celano)
bb2f9e0 refactor: [#1195] extract core::authentication::handler::KeysHandler (Jose Celano)
23590e7 refactor: [#1195] make method private (Jose Celano)
81b4b3c refactor: [#1195] extract and move method (Jose Celano)
cd542dc refactor: [#1195] extract authentication::Service (Jose Celano)
a93a79c refactor: [#1195] remove deprecated context section in docs (Jose Celano)
12a62ce refactor: [#1195] extract InMemoryKeyRepository (Jose Celano)
f4c7b97 refactor: [#1195] extract DatabaseKeyRepository (Jose Celano)
44255e2 refactor: [#1195] create dir for mod (Jose Celano)

Pull request description:

  Overhaul core Tracker: refactor authentication module.

ACKs for top commit:
  josecelano:
    ACK dff6bca

Tree-SHA512: 6f0fb0c9c97a9bb2056e293d1774bcbcf507e2a922eccb2c97675ac0963efcfe4848b53c45b88b512ae5a73e394f368e9bb9c4c6ee0af3b900a008eeddba02b9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- Developer - Torrust Improvement Experience Code Cleanup / Refactoring Tidying and Making Neat
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant