DelineaXPM / tss-sdk-go

A Golang SDK for Delinea Secret Server
https://delinea.com/products/secret-server
MIT License
2 stars 9 forks source link

Getting Login failed #28

Closed tibco-postman closed 4 months ago

tibco-postman commented 4 months ago

Description of the issue

I have setup an application account in Secret Server, and I have verified that it works by trying the Windows TSS SDK client. Now, when I'm trying with the Go SDK, setting TSS_USERNAME to my application account name and having tried with TSS_PASSWORD set to either the SDK key or the application account's password and passing in a secret to retrieve - I get "Login failed".

Obviously, I missing something fundamental here, but I fail to understand what. With the Windows TSS SDK client, you initialize the SDK with the URL, key and role, but I don't see anything equivalent in the Go SDK?

tibco-postman commented 4 months ago

Forgot to mention that in the Go SDK, I have also set the TSS_TENANT to a valid value

pacificcode commented 4 months ago

@tibco-postman What is the top level domain i.e. TLD of your URL? If it is not .com then try setting the TLD var to the value of your URL i.e.

tss, err := server.New(server.Configuration{
    Credentials: server.UserCredential{
        Username: "<yourUserName>",
        Password: "<yourPassword>",
    },
    Tenant: "<yourTenantName>",
    TLD:       "eu",
})

You can also try setting the full URL i.e.

tss, err := server.New(server.Configuration{
    Credentials: server.UserCredential{
        Username: "<yourUserName>",
        Password: "<yourPassword>",
    },
    ServerURL: "https://<yourTenantName>.secretservercloud.com",
})
tibco-postman commented 4 months ago

TLD is com, so not setting that. Tenant is cloudsg (full URL https://cloudsg.secretservercloud.com/)

What value should be used for TSS_PASSWORD? SDK key?

pacificcode commented 4 months ago

TSS_PASSWORD=ActualAccountPassword To debug if needed, navigate to https://cloudsg.secretservercloud.com/, select "Local Login" and enter the username/password you are using with the tss-sdk-go API calls. If you have issues here you may need to do some configuring with your authentication provider.

tibco-postman commented 4 months ago

Well, the odd thing is that I got it to work with the Windows TSS SDK Client - after running the initialization part (where you provide a "role" that seem to be the SS application account name plus the SDK key. I interpret this as the setup in SS is correct and works - or does the Go SDK operate in a different way?

But in the Go SDK, I see no trace of need to do initialization?

pacificcode commented 4 months ago

Im not familiar enough with the windows sdk to advise. The go sdk does not require initialization.

delinea-sagar commented 4 months ago

@tibco-postman Can you try to get token using your application account username and password through postman first. You can refer secret server rest API guide for this https://cloudsg.secretservercloud.com/RestApiDocs.ashx?doc=oauth-help. Request URL will be: https://cloudsg.secretservercloud.com/oauth2/token Request body will be: UserName = Password = grant_type = "password"

Also make sure Enable Webservices flag is set to true in secret server configuration image

If you are able to get token successfully then try in go-sdk with below configuration. tss, err := server.New(server.Configuration{ Credentials: server.UserCredential{ Username: "", Password: "", }, ServerURL: "https://cloudsg.secretservercloud.com", })

CC: @tylerezimmerman

tibco-postman commented 4 months ago

I've verified that Webservices is enabled, but still get "Login Failed". Tried using Postman, same result:

image

tibco-postman commented 4 months ago

I managed to get the Postman call to work. What was needed was to add the parameter domain to the call. Adding that to the Credentials var made things work!

Thanks for help!