stmcginnis / gofish

Gofish is a Golang client library for DMTF Redfish and SNIA Swordfish interaction.
BSD 3-Clause "New" or "Revised" License
211 stars 112 forks source link

Add SessionToken to exisiting connection? #302

Closed derwitzer closed 6 months ago

derwitzer commented 6 months ago

Hi!

I habe to monitor some Dell PowerVault ME50xx Servers. First I have to connect with BasicAuth to get a SessionKey, then I should use the SessionToken to get access. How can I add this token to the existing connectin? Or whats best practice in this kind of case?

Thx

Thomas

stmcginnis commented 6 months ago

Hey @derwitzer,

With BasicAuth, part of the authentication process returns an auth token that is stored in the client.

If using Session based authentication, the ClientConfig has a property to set the session token.

Typically there isn't anything you need to do. If you are using BasicAuth, you should be able to just create your connection and once it's authenticated all subsequent calls contain the token and just work.

There are some examples in the examples directory of this repo, but you can also see BasicAuth being used here: https://github.com/jenningsloy318/redfish_exporter/blob/master/collector/redfish_collector.go#L104

derwitzer commented 6 months ago

Hey @derwitzer, ...

Hi @stmcginnis,

so if I will use BaseAuth your functions will do a CreateSession()? The strange thing is, if I just do the BasicAuth and then query eg the Chassis(), the Dell Server is just replying the Token is missing. The Dell is using Redfish 1.12 btw.

stmcginnis commented 6 months ago

Hmm, that's odd. I know others have been using Gofish against Dell servers successfully for some time.

1.12 is a bit old. It might be good to update the iDRAC on that machine to see if that resolves the problem. There are constantly fixes being merged, so it's quite possible that has a bug that has since been fixed.

derwitzer commented 6 months ago

This is a very special kind of server, it doesn't have any iDRAC! Redfish is offered by the Server itself. Even the adminstrive webgui is looking more like a consumer product then a professional one. I may ask the admin if he can upgrade the firmware.

IF not, might be the CloneWithSession() an opionion? But I guess not, because we don'T get any token. So I may write a function Creating a new session, close the connection and open a new one with the session ID and token. Not that nice, but might work.

derwitzer commented 6 months ago

Another update, it might be interesting for all the people connection to PowerVaul ME5. You have to grant the user for dealing with Redfish "Standard" Access Rights and not only Monitoring, even if you just wanna do monitoring. It seems, these server (or the version of RedFish?) doesn't accept any POST (what you need for the session) when you just grant monitoring rights.

During our conversation I had a session with one of our admins and he showed the admin ui and then I said we may try other rights. Finally it's working. Sorry for opening an issue.