Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7975281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:36:24+00:00 2026-06-04T08:36:24+00:00

I have an API which I’m exposing via REST and I’m deliberating about where

  • 0

I have an API which I’m exposing via REST and I’m deliberating about where to place the authorities restrictions.
I’ve read that there is a best practice about securing the service layer as it is the one doing the work and you don’t know where it’s going to get called but I’m not sure what’s the best practice with respect to the WS layer.
One thought I have is that I need to have a very fine grained model of authorization on the service layer and a very coarse grained model of authorization on the WS layer as to minimize breaking the DRY principle on the one hand but still have some notion of defence in depth.

Example:

For the Users resource there is a UserWS and a UserService. Admins can create/update/delete users and Users can read about other users.
Assuming the UserWS is bound to %root%/users I will define an intercept-url for that url with the ROLE_USER authority which just says that you have to be a user to get there but the service layer itself will specify the specific authorities for the relevant methods.

Other options are:

  • Place the same authorization requirements on both the service and the WS-
    Pro- You’ll filter out as early as possible intruders (and save for example the conversion of parameters if you’re using spring mvc)
    Con- Duplication of configuration is a maintenance issue and is error prone => security issue

  • Place the authorization requirements only on the WS-
    Pro- Filter as soon as possible if comming from the WS
    Con- The service layer might be used from different contexts

  • Plate the authorization requirements only on the service-
    Pro- No Duplication
    Con- Overhead of allowing “bluntly” inept request to arrive to the service layer

Would really appreciate any feedback about the options

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T08:36:25+00:00Added an answer on June 4, 2026 at 8:36 am

    Ittai,
    Using the very same security mechanism at both the WS and Service layer is considered as repeating yourself – and it requires maintenance at these two levels.
    Not having any security at the WS layer is a bad thing – since you actually let anyone to get into your system ( even if you’ll block them later on – many see that as a bad thing ).
    In short, I think that you should mix up these two – use a very rough mechanism at the WS layer and a very strong one at the service layer, That’s how you wont repeat yourself and wont have to maintain the code in both places (as it not the SAME security level ); and you’ll be able to filter out undersized users as soon as possible but still have a very high security level where it should be placed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a REST API which is fairly typical, except that the id's of
Lets say I have a Rest API which can be accessed via e.g.: mypage.com/v1/users/1234
I have a scenario in which I have REST API which manages a Resource
I have download an API which has the following structure: In the folder, there
I have a rest API which is able to produce objects keys with null
I have a REST api which dumps some json data (user info, etc). Now
I have the win32 API CommandLineToArgvW which returns a LPWSTR* and warns me that
I have some issue regarding REST API which i have built using servicestack. End
not so clear about this feature. the situation is we have API which has
I have successfully created a PHP REST API which resides on my server. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.