GithubHelp home page GithubHelp logo

dnascimento / tss-sdk-go Goto Github PK

View Code? Open in Web Editor NEW

This project forked from delineaxpm/tss-sdk-go

0.0 2.0 0.0 98 KB

A Golang SDK for Delinea Secret Server

Home Page: https://delinea.com/products/secret-server

License: MIT License

Go 100.00%

tss-sdk-go's Introduction

The Delinea Secret Server SDK for Go

Tests

A Golang API and examples for Delinea Secret Server.

Configure

The API requires a Configuration object containing a Username, Password and either a Tenant for Secret Server Cloud or a ServerURL:

type UserCredential struct {
    Username, Password string
}

type Configuration struct {
    Credentials UserCredential
    ServerURL, TLD, Tenant, apiPathURI, tokenPathURI string
}

Use

Define a Configuration, use it to create an instance of Server:

tss := server.New(server.Configuration{
    Credentials: UserCredential{
        Username: os.Getenv("TSS_USERNAME"),
        Password: os.Getenv("TSS_PASSWORD"),
    },
    // Expecting either the tenant or URL to be set
    Tenant:    os.Getenv("TSS_API_TENANT"),
    ServerURL: os.Getenv("TSS_SERVER_URL"),
})

Get a secret by its numeric ID:

s, err := tss.Secret(1)

if err != nil {
    log.Fatal("failure calling server.Secret", err)
}

if pw, ok := secret.Field("password"); ok {
    fmt.Print("the password is", pw)
}

Create a Secret:

secretModel := new(Secret)
secretModel.Name = "New Secret"
secretModel.SiteID = 1
secretModel.FolderID = 6
secretModel.SecretTemplateID = 8
secretModel.Fields = make([]SecretField, 1)
secretModel.Fields[0].FieldID = 270
secretModel.Fields[0].ItemValue = somePassword

newSecret, err := tss.CreateSecret(*secretModel)

Update the Secret:

secretModel.ID = newSecret.ID
secretModel.Fields[0].ItemValue = someNewPassword

updatedSecret, err := tss.UpdateSecret(*secretModel)

Delete the Secret:

err := tss.DeleteSecret(newSecret.ID)

Test

The tests populate a Configuration from JSON:

config := new(Configuration)

if cj, err := ioutil.ReadFile("../test_config.json"); err == nil {
    json.Unmarshal(cj, &config)
}

tss := New(*config)

../test_config.json:

{
    "credentials": {
        "username": "my_app_user",
        "password": "Passw0rd."
    },
    "serverURL": "http://example.local/SecretServer"
}

The necessary configuration may also be configured from environment variables:

Env Var Name Description
TSS_USERNAME The user name for the Secret Server
TSS_PASSWORD The password for the user
TSS_TENANT Name for tenants hosted in the Secret Server Cloud. This is prepended to the *.secretservercloud.com domain to determine the server URL.
TSS_SERVER_URL URL for servers not hosted in the cloud, eg: https://delinea.mycompany.com/SecretServer

Test #1 - Read Secret Password

Reads the secret with ID 1 or the ID passed in the TSS_SECRET_ID environment variable and extracts the password field from it.

Test #2 - Perform Secret CRUD

Creates a secret with a fixed password using the values passed in the environment variables below. It then reads the secret from the server, validates its values, updates it, and deletes it.

Env Var Name Description
TSS_SITE_ID The numeric ID of the distributed engine site
TSS_FOLDER_ID The numeric ID of the folder where the secret will be created
TSS_TEMPLATE_ID The numeric ID of the template that defines the secret's fields
TSS_TEST_PASSWORD The password to set for testing

Test #3 - Perform CRUD for an SSH Key Secret

Creates a secret with generated SSH keys using the values passed in the environment variables below. It then reads the secret from the server, validates its values, updates it, and deletes it.

Env Var Name Description
TSS_SITE_ID The numeric ID of the distributed engine site
TSS_FOLDER_ID The numeric ID of the folder where the secret will be created
TSS_SSH_KEY_TEMPLATE_ID The numeric ID of the template that defines the secret's fields. This template must have extended mappings that support SSH keys.
TSS_TEST_PASSWORD The password to set for testing

Test #4 - Perform field based search for password secret

Searches for secrets with a field value using the values passed in the environment variables below.

Env Var Name Description
TSS_SEARCH_FIELD The secret field to be searched
TSS_SEARCH_TEXT The text to search

Test #5 - Perform search for password secret

Searches for secrets containing text using the values passed in the environment variables below.

Env Var Name Description
TSS_SEARCH_TEXT The text to search

Test #6 - Password Generation

Retrieves the template indicated in the environment variable below, iterates its fields, and validates that we can generate a password value for every field that is a password field.

Env Var Name Description
TSS_TEMPLATE_ID The numeric ID of the template that defines the secret's fields

tss-sdk-go's People

Contributors

endlesstrax avatar delineakrehl avatar tylerezimmerman avatar amigus avatar chaserb avatar mend-for-github-com[bot] avatar dustingregory avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.