IBM Verify

IBM Verify

Join this online user group to communicate across Security product users and IBM experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  How to manage return codes when using WebSEAL as an OAuth Enforcement Point

    Posted Mon February 17, 2020 10:03 AM
    We want to use WebSEAL to protect applications with OAuth sent as a bearer token. As I understand it WebSEAL should send a 401 if the token is incorrect, expired or missing.
    For the "oauth-eas" mechanism you can configure the following:

    unauthorized-rsp-file = oauth_template_rsp_401_unauthorized.html

    But for "oauth-auth" there doesn't seem to be such a config. And if I understood correctly "oauth-eas" was the old way to do oauth and "oauth-auth" is the new one.

    I've now tried playing around with the various custom return codes that I can configure in the login/error pages but until now I haven't found a satisfying solution.

    If the only mechanism activated is oauth-auth, then the response for an unauthenticated request will be a 403 (38cf0427.html). I can now change this file to 38cf0427.401.html, but I'm not sure if this would be a good idea because then basically every 403 will be a 401.

    If I also add "forms-auth" as an authentication mechanism then I can change login.html to login.401.html. This has the advantage that only login operations are impacted but I have to active an authentication mechanism that I didn't want to allow on this instance. So I will have to use a POP with the correct authentication level to prevent users login in with passwords.

    What's also missing with this approach of changing the return code is that no "WWW-Authenticate" header will be sent. Now I could write a http transformation which checks for the presence of the "Authorization" header and sends the correct challenge back if this header is missing. But I don't know how I should treat an expired or incorrect token this way.

    What is the correct way in which IBM recommends to use WebSEAL as an enforcement point?

    ------------------------------
    Laurent Asselborn
    ------------------------------


  • 2.  RE: How to manage return codes when using WebSEAL as an OAuth Enforcement Point

    Posted Wed August 05, 2020 09:28 AM

    Hi Laurent, and all !

    The way I have been thinking about this over last 24 hours goes as follow. It re-uses some of your suggestions Laurent.

    Use Case Description:

    • Emulating as much as possible an API server with a Web Reverse Proxy to protect a single junctioned back-end API application.
    • Authentication mechanism configured: "oauth-auth = https" (and is forms-auth enabled by default, for now)
    • We have no requierment to authenticate "web" users using forms-auth.
    • Web Authenticated users are prevented from navigating the API back-end junction using forms as special POP is set and attached to require OAuth token on the API endpoint.
    • OAuth Flow: Client Credential, short token duration lifetime (5 min).
    • OAuth client: pure stateless client (no care for webseal session cookie returned).
    • OAuth token consumed on this WRP is obtained from another configured OAuth Authorization Server (WRP).


    Requirement:

    On expired/invalid OAuth (bearer) token received, return a HTTP 401 status code instead of the now HTTP 200 (TAMOP: Login) behavior that is depicted below:

    HTTP/1.1 200 OK

    content-length: 30

    content-type: application/json

    date: Wed, 05 Aug 2020 13:11:49 GMT

    isam-op: login

    {

        "operation" : "login"

    }

     

    Option A:

    Develop a HTTP Transformation (XSLT) that will inspect in the HTTP Response for the presence of the TAM OP header (http-rsp-header = isam-op:TAM_OP, see https://www.ibm.com/support/knowledgecenter/en/SSPREK_9.0.5/com.ibm.isam.doc/wrp_stza_ref/reference/ref_http_rsp_header.html) and if present, trigger a re-write of the HTTP 200 status code into a HTTP 401 status code (might as well update the "OK" reason code while at it to "Unauthorized"). This should do the trick most of the time. Technical errors scenario I imagine would fall more under the range of HTTP 500 status code and in such cases, the XSLT would leave the status code as-is.

    We are gaining in momentum with XSLT HTTP Transformation, so we are not "afraid" going that road.

    Option B:

    I was wondering if another cleaner (OOTB) option existed that didn't require modifying (with XSLT) the behavior of WebSEAL wanting to let know the user that no "session" existed.



    ------------------------------
    Sylvain Gilbert
    ------------------------------



  • 3.  RE: How to manage return codes when using WebSEAL as an OAuth Enforcement Point

    Posted Wed August 05, 2020 04:41 PM
    Hi all

    Should I be able to have an HTTP transformation rule executes itself even for unauth session ?

    I realize that my http transformation rules that attempts to convert http 200 status code (no valid session) into a 401 status code is not executed at all (validated with pdweb.httptransformation trace) but it is executed when the provided oauth token (Bearer) is valid.

    I am using configuration file matching rules (not POP).

    Am I trying to do something that is not suppose to be done ?

    9.0.7.0

    ------------------------------
    Sylvain Gilbert
    ------------------------------



  • 4.  RE: How to manage return codes when using WebSEAL as an OAuth Enforcement Point

    Posted Thu August 06, 2020 04:24 AM
    Hi Sylvain,

    A transformation rule should work whether you are unauthenticated or authenticated.  There are certainly some cases I've seen where a rule triggered in the configuration does not work but will work when configured in a POP.  I would try using a POP to trigger and see if that helps.

    Someone else will have to explain exactly WHY some rules don't work from the configuration  - I've just learnt to try the POP method whenever the configuration file method doesn't work for me.

    Jon.

    ------------------------------
    Jon Harry
    Consulting IT Security Specialist
    IBM
    ------------------------------



  • 5.  RE: How to manage return codes when using WebSEAL as an OAuth Enforcement Point

    Posted Thu August 06, 2020 04:36 AM
    Hi Sylvain,

    If you're getting op=login then I assume that this response is being generated because a login is required.  The Reverse Proxy is seeing that it needs to return application/json and is not finding a login.json file - so is returning the default.json file (from /management/C) instead.

    If you create a login.json file this will be returned instead for the login required event - you can customize it to your needs.
    If, instead of creating login.json, you create login.401.json, then the content of the file will be returned with a 401 response code.

    If there is an error condition, and accept header is application/json, then Reverse Proxy will attempt to load the <error code>.json file.  If this isn't found it will use the default.json file (from error/C).  You can create new <error code>.json (or <error code>.<response code>.json for specific error messages.

    It is NOT possible to dynamically set the response code for a Reverse Proxy page.

    Jon.

    ------------------------------
    Jon Harry
    Consulting IT Security Specialist
    IBM
    ------------------------------



  • 6.  RE: How to manage return codes when using WebSEAL as an OAuth Enforcement Point

    Posted Thu August 06, 2020 04:40 AM
    Hi Laurent,

    As a workaround to your "I don't want to enable forms login" issue, perhaps you could enable EAI instead (but not set any trigger URLs - or set one that isn't real).
    When EAI is enabled, Reverse Proxy will show the login.html (before local-response-redirect it was used to re-direct to the EAI application).  I think that means it would show login.xxx.json too.

    Jon.

    ------------------------------
    Jon Harry
    Consulting IT Security Specialist
    IBM
    ------------------------------



  • 7.  RE: How to manage return codes when using WebSEAL as an OAuth Enforcement Point

    Posted Fri August 07, 2020 12:25 PM
    Edited by Sylvain Gilbert Fri August 07, 2020 12:43 PM

    Hi

    Just wanted to share how I finally came to have the solution working as our requirements (WRP emulating as closely as possible an API server supporting only OAuth):

    1. Found out indeed that the forms login mechanism (forms-auth = https), which is configured by default, was conflicting with the oauth-auth mechanism. Since I only need to authenticate API calls with OAuth tokens passed as Bearer on this WRP, I completely disabled forms login mechanism (forms-auth = none).
    2. At this point, passing an invalid access token returned the following which is better than before (200/Login) but not quite yet:

    {

        "error_code"    : "0x38cf0427",

        "error_message" : "Forbidden"

    }
            3. One last change I had to apply (as hinted by someone on another channel): [oauth] continue-on-auth-failure = false. With this last change, I get what I want (401/Unauthorized) on an invalid/expired OAuth token:

    {

        "error_code"    : "0x38cf0425",

        "error_message" : "Unauthorized"

    }

     

    So, I didn't need after all to use an http transformation for this. It is kind on what I had expected originally but still some digging was required.

     

    Thanks for all your inputs and suggestions.



    ------------------------------
    Sylvain Gilbert
    ------------------------------