BPM, Workflow, and Case

BPM, Workflow, and Case

Come for answers. Stay for best practices. All we’re missing is you.

 View Only
  • 1.  Restrict access to exposed REST services in BAW

    Posted Fri November 10, 2023 04:02 AM

    Hello! As far as I understand, REST services created in BAW and exposed externally (as exposed automation services) can be called by anyone who is authenticated on the hosting BAW environment when using basic authentication (see Creating a REST service). There is no way to restrict access to the services to members of certain user groups or teams, correct?

    What would be the easiest approach to achieve such a simple team filter to ensure that only certain people can access/use the exposed REST services?

    I understand that customizing authentication using TAI would be an option as outlined by @Jens Engelke in another post but this is probably rather complex to implement. Are there any alternative solutions? 

    Is there a way to just fetch and use the username provided by the REST call's basic authentication information in the implementing BAW service?

    Thanks for your input!



    ------------------------------
    Gregor Schikorski
    ------------------------------


  • 2.  RE: Restrict access to exposed REST services in BAW

    Posted Fri November 10, 2023 05:39 AM

    Hello, 

    Not an ideal solution but you can always check authorization as first step of exposed service.
    I mean like:

    var user = tw.system.org.findUserByName(tw.system.user_loginName);
    var authorizedTeam = tw.system.org.findTeamByName("AuthorizedUsersGroup");
    tw.local.authorized = user.isInTeam(authorizedTeam); 

    .... 

    There are obvious drawbacks of such choice:
     - if you have many services you have to touch all of them 
     - you can return response to caller as modeled response (200) or generic error (500) not as more natural authorization error (403) in this case  - what goes against any good practices in REST services world  
    - there is some minimal performance penalty if you care about service response time 



    ------------------------------
    Sebastian Tylko
    ------------------------------



  • 3.  RE: Restrict access to exposed REST services in BAW

    Posted Wed December 13, 2023 10:26 AM

    We have a similar need in that we would like a way to selectively authorize service accounts created in the IBM OnCloud environment to only have access to specific REST endpoints exposed through BAW. I've submitted to IBM as an idea - if you feel this could help your use case as well, please vote for the idea:

    https://ideas.ibm.com/ideas/ICPFORA-I-377



    ------------------------------
    Don Williams
    ------------------------------



  • 4.  RE: Restrict access to exposed REST services in BAW

    Posted Wed December 13, 2023 10:42 AM

    You got my vote.



    ------------------------------
    Gregor Schikorski
    ------------------------------



  • 5.  RE: Restrict access to exposed REST services in BAW

    Posted Thu December 14, 2023 06:42 AM

    Please do not misused authentication customization to implement authorization. 

    Authentication is the process of finding out if the user is who she claims to be.

    If you want to restrict if your service is executed at all or maybe follows different code paths depending on who the authenticated user is, then @Sebastian Tylko's response is the way to go.

    While "failing early" is a good practice, you may also want to consider adding authorization logic to "deeper layers" of your application, that is, if you expose something as a REST service, it may invoke another service, which in turn invokes another service etc.

    Authorization should be checked at each layer. Why would you have a service in your process app that should only respond to some users, but is executed without conditions? You noticed that lack of due diligence now at the "very outside" while exposing the service as REST, however, the same considerations apply even within your own application logic.

    HTH

    Jens



    ------------------------------
    Jens Engelke
    ------------------------------



  • 6.  RE: Restrict access to exposed REST services in BAW

    Posted Fri December 15, 2023 06:07 AM

    Thanks for your comments, Jens. Obviously, you are right about the need for authorization checks at different layers of the application.

    I also agree that the approach outlined by @Sebastian Tylko could eventually solve the access restriction problem. However, what about the response sent to the user who invoked the service? It would be nice to directly send them a response code other than 200 so the calling user knows about the rejection. I assume this cannot be achieved if we do not check authorization upon authentication, or am I wrong?



    ------------------------------
    Gregor Schikorski
    ------------------------------