Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any difference between oauth scopes and roles when using Spring Security? [duplicate]

When using Spring security to secure an API with oauth is there any distinction between scopes and roles?

For example when using non oauth based role based authorization I might have a user named john with the role admin.

If I'm using oauth then it seems john would just have the scope admin instead.

Am I thinking about this the right way?

like image 469
Ole Avatar asked Dec 30 '25 21:12

Ole


1 Answers

Typically you would use scopes to indicate permissions that a user allows a client app. Think how Facebook asks a user if he wants to allow a certain third party to access his resources such as: name, email, profile, list of friends, etc. On the other hand, you would use roles to denote whether the user is just a regular user, or an admin.

So rule of thumb is: if it's about a user granting a client app permission to access resources, then use scopes to represent the authority needed. Otherwise use roles to denote authority in terms of what type of user one is.

like image 122
sofiaguyang Avatar answered Jan 01 '26 13:01

sofiaguyang



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!