Layer7 API Management

Expand all | Collapse all

Storing of data in custom column in otk databse

  • 1.  Storing of data in custom column in otk databse

    Posted Feb 06, 2018 11:57 AM

    Hi ,

    I am using otk 4.1 and i want to store a custom value in the custom column when a token is generated and retrieve it when the token is checked in the next call.

    Any ideas of how to implement this .



  • 2.  Re: Storing of data in custom column in otk databse

    Broadcom Employee
    Posted Feb 08, 2018 10:16 PM

    Dear PavanReddy ,

    You can do it on /oauth/manager by editing the oauth client key,

     

    Note that the Custom Field needs to be json format.

     

    when you validate the assess token with OTK Require Oauth 2.0 Token assertion, you can get the saved custom field from ${session.custom} as below,

     

      {     "otk": {"client_type": "confidential","grant_type": "refresh_token"},     "portal": {},     "mag": {},     "clientkey": { Your custom field }   }

    Regards,

    Mark



  • 3.  Re: Storing of data in custom column in otk databse

    Posted Feb 19, 2018 11:54 AM

    Hi Mark,

     

    Thanks,But i have a requirement to store the custom data dynamically for every user 

    1)I am using a back end service to authenticate the user 

    2)When the user is authenticated i generate a access token /token ,then i want to store the custom data from the back end service in custom column of otk databse 

    3)Retrieve the custom column for the subsequent calls when the token is valid 

     

    Any sample policies would be really helpful 



  • 4.  Re: Storing of data in custom column in otk databse

    Broadcom Employee
    Posted Feb 19, 2018 06:05 PM

    1. token usually stored in cookie, not sure why you have to persist it in database -- as you said, it's dynamic

    2. if "every user" is one to one against oauth client, you may use perform jdbc query assertion to save and retrieve your token to and from custom column of oauth_client table in otk database. If it's not one to one relationship, you may need to design a new database schema to store your tokens -- I cannot suggest you to create a new table in otk database, although I cannot stop you to do so.



  • 5.  Re: Storing of data in custom column in otk databse

    Posted Mar 12, 2018 02:24 PM

    Hi Mark,

    Thanks for your reply,

    Can you share me any sample polices if you have any for OTK Session-Get,Store,Delete,DB.

     

     

    Thanks,

    Pavan



  • 6.  Re: Storing of data in custom column in otk databse

    Posted Mar 12, 2018 04:23 PM

    Hi Mark,

    Above is the policy i am unable to get the ${session.custom } values from OAuth Manager.

    WARNING 11000 Policy processing caught an exception: RaiseErrorAssertion is stopping execution.

     

    Below is the json client_key_cutom column in Oauth manager 

    {

    "a":"a",

    "b":"b",

    "c":"c"

    }

     

    What are these variables related to ${client_key_custom},${session_custom}

     

    Can you please help me out .



  • 7.  Re: Storing of data in custom column in otk databse

    Broadcom Employee
    Posted Mar 12, 2018 06:51 PM

    Dear PavanReddy ,

    As mentioned in previous comment, the value of ${session.custom} is in following format,

    {
        "otk": {
            "client_type": "confidential",
            "grant_type": "refresh_token"
        },
        "portal": {
            
        },
        "mag": {
            
        },
        "clientkey": {
            "a": "a",
            "b": "b",
            "c": "c"
        }
    }

     

    So, your json path expression should be "clientkey",

     

    Regards,

    Mark



  • 8.  Re: Storing of data in custom column in otk databse

    Posted Mar 13, 2018 08:55 PM

    Thanks Mark,

     

    Can you please help me understand what these variables are 

    1)${client_key_custom},

    2)${session_custom}  Are these used as a part of OTK Session Tracking 



  • 9.  Re: Storing of data in custom column in otk databse

    Broadcom Employee
    Posted Mar 13, 2018 10:51 PM

    I don't know context variable of ${client_key_custom}, context variable ${session_custom} is set after assertion OTK Require OAuth 2.0 Token is executed.

     

    I don't see ${client_key_custom} from your screenshot, the ${client_key_custom_message} is set as ${session_custom}, you only need to change the expression of the json path assertion to the correct one.



  • 10.  Re: Storing of data in custom column in otk databse

    Posted Mar 13, 2018 10:54 PM



  • 11.  Re: Storing of data in custom column in otk databse

    Broadcom Employee
    Posted Mar 13, 2018 11:25 PM

    Where do you use this otk session tracking assertion? the input parameters are the nodes of ${session_custom}



  • 12.  Re: Storing of data in custom column in otk databse

    Posted Mar 22, 2018 05:54 PM

    Hi Mark,

    This is a part of the token end point we are customizing the end point to get values from oauth manager. 



  • 13.  Re: Storing of data in custom column in otk databse

    Broadcom Employee
    Posted Dec 24, 2018 12:52 PM

    Pravan,

     

    I strongly recommend not to use the OTK database to store custom columns as any upgrade path by the OTK scripts may break any integration that you have created. If you are looking to create some other mapping, look to use either another database with the columns you need, or centralized cache server.

     

    Sincerely,

     

    Stephen Hughes

    Broadcom Support