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

Cleanup Identity #443

Merged
merged 18 commits into from
Feb 9, 2022
Merged

Cleanup Identity #443

merged 18 commits into from
Feb 9, 2022

Conversation

fretje
Copy link
Contributor

@fretje fretje commented Feb 6, 2022

I started working on #385

  • re-design permissions
  • consistency
  • rename IIdentityService to IProfileService
  • rename StatsController to DashboardController
  • remove roleclaimscontroller
  • add personalController and move myauditlogs and mypermissions there
  • move FSHRoles to shared project
  • remove isdefault from roledto

An accompanying PR is following on the blazor repo...

Will update this PR with more cleanup, but please review already!

* re-design permissions
* consistency
* rename IIdentityService to IProfileService
* rename StatsController to DashboardController
* remove roleclaimscontroller
* add personalController and move myauditlogs and mypermissions there
* move FSHRoles to shared project
* remove isdefault from roledto
* clear cache from RoleService.UpdatePermissions
* also remove roleclaimservice and further cleanup
also clear permissioncahe on assignroles
profile service cleanup
and clearuserpemissioncachehandler which handles those events
@fretje
Copy link
Contributor Author

fretje commented Feb 6, 2022

Think I'm almost there...

Still not sure about the whole "Profile" name thing... still feels like it should all go into one "userservice"... but that might get a bit bloated... maybe using partial classes in different files?

I've created some events ApplicationRoleUpdated and ApplicationUserUpdated, which I use now in the ClearUserPermissionCacheHandler to clear the userpermission cache (the one that's used in UserService.HasPermission which is called on every request).

I have now only added the publishing of these events in the places where it's relevant for that specific handler... we should probably add all the event types and send them everywhere where it's necessary...
I do think we need some more refactoring then, as there are many different places where a user is updated or created now for instance...

@xlogex
Copy link
Contributor

xlogex commented Feb 6, 2022

Probably the street of the partial classes could be a less bloated road.
The fact remains that the list of permits is always long, and if you split them in 2 or more the list how many they end in other files? .... evalueate afterwards.

@iammukeshm
Copy link
Member

Could you please update the postman collections too? since there are a couple of controller changes that I can see,

Also, do we need to re-generate migrations ?

@fretje
Copy link
Contributor Author

fretje commented Feb 6, 2022

Concerning migration: only some fields been removed, so in theory it's not needed (but the database will contain some unused fields)... But I suppose they will have to be re-generated anyways for a release... That should actually be part of the build process I think...

I have never done postman updates before... is that simply exporting again? I'll have a look later...

@xlogex
Copy link
Contributor

xlogex commented Feb 6, 2022

Concerning migration: only some fields been removed, so in theory it's not needed (but the database will contain some unused fields)... But I suppose they will have to be re-generated anyways for a release... That should actually be part of the build process I think...

I have never done postman updates before... is that simply exporting again? I'll have a look later...

about postman we can regenerate after ... (maybe exist import nswag.json file present in swagger)

@xlogex
Copy link
Contributor

xlogex commented Feb 6, 2022

image

image

@fretje
Copy link
Contributor Author

fretje commented Feb 6, 2022

Ok, the postman collection has been updated...

@fretje
Copy link
Contributor Author

fretje commented Feb 7, 2022

Still not sure about the controllernames "Personal" and "Profile" and "users"... seems like they overlap somewhere...

But I hear no other suggestions? ;-)

image

@xlogex
Copy link
Contributor

xlogex commented Feb 7, 2022

I think they are well organized.
Personal: aggregate personal information (log, credentials/grant)
Profile: aggregate single user actions (register, update info, recovery ...)
Users: Manage users

Copy link

@CanMehmetK CanMehmetK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_context is very general
as suggested using variables with full
like _applicationDbContext or some like

Copy link

@CanMehmetK CanMehmetK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is more sensible.

@iammukeshm
Copy link
Member

iammukeshm commented Feb 7, 2022

This looks neat. But wouldn't it be better to merge user and profile controller into a single user controller

Create a new user sounds better than create a new profile.

@fretje
Copy link
Contributor Author

fretje commented Feb 7, 2022

Jep... thinking GET /api/profile goes to personal (GET /api/personal/profile) and the rest go to users...

I'll have a looksie later ;-)

@fretje
Copy link
Contributor Author

fretje commented Feb 7, 2022

Hmm... the PUT /profile doesn't really fit under users, as that's also only for the currently logged on user...
I suppose that one also goes to personal.
There isn't a way now to actually update (or delete) users from the user admin side... I guess if we were to add that, that would be other endpoints under /users then...

@fretje
Copy link
Contributor Author

fretje commented Feb 7, 2022

Something like this?

image

@fretje
Copy link
Contributor Author

fretje commented Feb 7, 2022

I've used partial class to separate UserService into several files now...
Still feels a bit cluncky...

I'm wondering if we can't just create RequestHandlers like we do in the applicationProject but then in the infrastructure project... that would be the best solution I think... Now that I've already added AddMediatR(Assembly.GetExecutingAssembly()) in the infrastructure project (for the InvalidateUserPermissionCacheHandler), I think it would "just work".

@frankyjquintero
Copy link
Contributor

It seems to me a breakthrough in terms of the development and separation it is taking. As for the events from infrastructure I consider viable but must be in another PR, the mixture of several ideas confuses the update of projects in progress

@fretje fretje closed this Feb 8, 2022
@fretje fretje reopened this Feb 8, 2022
@iammukeshm iammukeshm merged commit f0d4049 into fullstackhero:main Feb 9, 2022
@fretje fretje deleted the identity branch February 9, 2022 11:56
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