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

feat: authenticator #493

Merged
merged 25 commits into from
Oct 2, 2024
Merged

feat: authenticator #493

merged 25 commits into from
Oct 2, 2024

Conversation

brendt
Copy link
Member

@brendt brendt commented Sep 27, 2024

No description provided.

@coveralls
Copy link

coveralls commented Sep 27, 2024

Pull Request Test Coverage Report for Build 11137713319

Details

  • 209 of 223 (93.72%) changed or added relevant lines in 28 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.4%) to 81.776%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/Tempest/Reflection/src/PropertyReflector.php 4 5 80.0%
src/Tempest/Framework/Testing/Http/TestResponseHelper.php 3 16 18.75%
Files with Coverage Reduction New Missed Lines %
src/Tempest/Mapper/src/Casters/EnumCaster.php 1 87.5%
Totals Coverage Status
Change from base Build 11135946327: 0.4%
Covered Lines: 6143
Relevant Lines: 7512

💛 - Coveralls

@brendt
Copy link
Member Author

brendt commented Sep 27, 2024

After this PR, we'll look into an authorization API (preferably with user roles built-in). All front-end stuff and user-management is left alone for now.

src/Tempest/Auth/.gitattributes Outdated Show resolved Hide resolved
src/Tempest/Auth/composer.json Outdated Show resolved Hide resolved
src/Tempest/Database/src/database.sqlite Outdated Show resolved Hide resolved
@innocenzi
Copy link
Member

I think this is great, there shouldn't need to be more built-in (besides authorization) 👍

However, I wouldn't let Tempest take care of the user model itself and the migration, I would rather have Tempest use an interface that has to be implemented in userland

@brendt
Copy link
Member Author

brendt commented Sep 27, 2024

However, I wouldn't let Tempest take care of the user model itself and the migration, I would rather have Tempest use an interface that has to be implemented in userland

Yeah, that's a fair point.

@brendt
Copy link
Member Author

brendt commented Sep 27, 2024

While I want the user model to be configurable, I do want to provide a default implementation — I might reconsider that though.

Also, I'm ok with "the user" being tied to the database, I don't really care about other ways of storing user data for now.

@innocenzi
Copy link
Member

Looking at the current code, it's unclear to me—is it possible to ignore the provided migration? Or would you recommend to add another one that would run after it and modify the table as we see fit?

That'd be one reason I was suggesting not to provide a default model/migration, but it seems low enough friction

@aidan-casey
Copy link
Member

aidan-casey commented Sep 27, 2024

I'd love to see this use a repository to decouple retrieving the user details. If it were me personally, my criteria would be for this to be decoupled so that it could work entirely outside the framework. I understand that's a bit of an extreme view, though. 🙂

I don't really care about other ways of storing user data for now.

We have to think about the people storing passwords in the filesystem, @brendt!

@brendt
Copy link
Member Author

brendt commented Sep 28, 2024

Looking at the current code, it's unclear to me—is it possible to ignore the provided migration? Or would you recommend to add another one that would run after it and modify the table as we see fit?

Right now it's not possible, but this is something I already planned on figuring out before merging this PR :)

@brendt
Copy link
Member Author

brendt commented Sep 28, 2024

I understand that's a bit of an extreme view, though. 🙂

Yes, not within my scope for now :)

@brendt
Copy link
Member Author

brendt commented Sep 28, 2024

We have to think about the people storing passwords in the filesystem, @brendt!

I thought about it: they are free to roll their own auth layer separate from Tempest's default implementation 👍

src/Tempest/Auth/phpunit.xml Outdated Show resolved Hide resolved
src/Tempest/Auth/composer.json Outdated Show resolved Hide resolved
src/Tempest/Auth/src/User.php Show resolved Hide resolved
src/Tempest/Database/src/Id.php Show resolved Hide resolved
src/Tempest/Auth/src/CanAuthorize.php Outdated Show resolved Hide resolved
@brendt
Copy link
Member Author

brendt commented Oct 1, 2024

How to deal with this circular dependency: auth requires http because of session management, but http also requires auth because of the middleware.

Since this auth layer is only concerned with http authentication, would it make sense to keep it all within the same component?

I know @aidan-casey will tell me otherwise :)

@innocenzi
Copy link
Member

Is the circular dependency itself a technical issue? If not, I think keeping the tempest/auth package separate is a good idea

@brendt
Copy link
Member Author

brendt commented Oct 1, 2024

Apparently it is, composer can't deal with it (at least not in our CI setup). There's no issue in this branch because I haven't added the circular dependency yet, but we had the same issue once before between core and event-bus.

Maybe there's a solution for it, I'll do some digging.

@aidan-casey
Copy link
Member

@brendt - I haven't looked through the code yet, but probably I would have said use a driver/repository for storing the auth data. 🙈 🙃

@brendt
Copy link
Member Author

brendt commented Oct 2, 2024

I solved the issue, it was pretty straight forward: just need to hook into the Kernel::BOOTED event and add the middleware like so

@brendt
Copy link
Member Author

brendt commented Oct 2, 2024

Ok so, this branch contains so much code that I want to merge it rather sooner than later. I'm still going to write an implementation for revokePermission, but after that I plan on merging it.

@brendt brendt merged commit 5017c5f into main Oct 2, 2024
55 checks passed
@brendt brendt deleted the auth-manager branch October 2, 2024 04:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants