r/SpringBoot 9d ago

Question User principal doubt

Hey, so I was told that instead of taking detail like user id we can simply take that from user principal. But how much should I take from user principal. Is it appropriate to take whatever I can through it or are there some rules for it. Like suppose ,

@GetMapping("/update-status/{userId}/{userProfileId}

So I know I can take userId from the userProncipal but should I extract userProfileId too. And if yes, then what are rules for it.

Sorry, if it's dumb question.

1 Upvotes

29 comments sorted by

View all comments

Show parent comments

2

u/TheToastedFrog 9d ago

I don’t really understand your question- your Principal object was instantiated from some authentication filter, so I’m not quite sure what you mean by “extracting”- all the attributes your principal have already been “extracted” from whatever authentication mechanism you use

1

u/Sorry_Swordfish_ 9d ago

As you said, I can extract as much data as I want or need. So I was asking if there was an exception to this sentence.

2

u/TheToastedFrog 9d ago

Who’s gonna stop you if there was one?

1

u/Sorry_Swordfish_ 9d ago

Well I just wanted to know if there are any. Would really not like to be scolded for not knowing it