Solved

Options for passing a username to a locally hosted REST service

  • 13 June 2020
  • 1 reply
  • 5 views

Hi, I'm creating a REST API with .NET, which I will be hosting on the same server as K2.

I'm using the REST service broker for this - we're using K2 5.2.

 

What I'd like to do is pass in the user's login name. Ideally without having to pass this in as a parameter to the rest service SmartObject, which could be manipulated.

We can use impersonation to get K2 to pass in the users identity, but I don't see a way of making this work without setting up Kerberos, which is a dependency I'd like to avoid for just checking who triggered the request.

 

 

 

 

 

 

icon

Best answer by simeonreilly 25 June 2020, 21:27

View original

1 reply

Finally found a way to do this that might be obvious to anyone who is used to editing SmartObjects. Since I was fond of generating SmartObjects, I didn't see this.

 

First, I had to add an endpoint to my API for the username. In my particular case this wasn't an issue as the API is only exposed to the K2 server, so no one else can jump in and provide some one elses username as a parameter. I suppose if your API is only authorized against service accounts that would be okay too.

 

Generate your SmartObjects. Then go to K2 designer, edit the REST Smartobject -> edit the SmartObject method you are using -> and assign the user login to the System Value - Current Users Identity.

Reply