# README
xrhidgen
xrhidgen
generates X-Rh-Identity JSON records suitable for passing into HTTP
requests to console.redhat.com services. Any field not explicitly set via a
command line flag will be populated by an appropriate random value.
Command Line
Installation
go install github.com/subpop/xrhidgen/cmd/xrhidgen@latest
Usage
USAGE
xrhidgen [flags] <subcommand>
xrhidgen can be used to generate JSON records suitable for passing in to
the X-Rh-Identity header. Each subcommand will generate a record of the
specified type. Any flag set will be inserted instead of a random value.
All remaining fields will be filled with a suitably random value.
SUBCOMMANDS
user generate a user identity JSON record
internal generate an internal identity JSON record
system generate a system identity JSON record
associate generate an associate identity JSON record
service-account generate a service account identity JSON record
FLAGS
-account-number value set the identity.account_number field (string)
-auth-type value set the identity.authtype field (string)
-employe-account-number value set the identity.employee_account_number field (string)
-org-id value set the identity.org_id field (string)
-type value set the identity.type field (string)
Examples
$ xrhidgen user -email [email protected]
{"identity":{"org_id":"45841","internal":{"org_id":"45841"},"user":{"username":"backbencher","email":"[email protected]","first_name":"Cira","last_name":"Roob","is_active":false,"is_org_admin":true,"is_internal":false,"locale":"li","user_id":"nicole"},"system":{},"associate":{"Role":null,"email":"","givenName":"","rhatUUID":"","surname":""},"x509":{"subject_dn":"","issuer_dn":""},"service_account":{"client_id":"","username":""},"type":"User","auth_type":"cert-auth"},"entitlements":null}
$ xrhidgen system | base64 -w0
eyJpZGVudGl0eSI6eyJvcmdfaWQiOiIyMTcwMyIsImludGVybmFsIjp7Im9yZ19pZCI6IjIxNzAzIn0sInVzZXIiOnsidXNlcm5hbWUiOiIiLCJlbWFpbCI6IiIsImZpcnN0X25hbWUiOiIiLCJsYXN0X25hbWUiOiIiLCJpc19hY3RpdmUiOmZhbHNlLCJpc19vcmdfYWRtaW4iOmZhbHNlLCJpc19pbnRlcm5hbCI6ZmFsc2UsImxvY2FsZSI6IiIsInVzZXJfaWQiOiIifSwic3lzdGVtIjp7ImNuIjoiRyIsImNlcnRfdHlwZSI6ImNvbnN1bWVyIiwiY2x1c3Rlcl9pZCI6IkhKbyJ9LCJhc3NvY2lhdGUiOnsiUm9sZSI6bnVsbCwiZW1haWwiOiIiLCJnaXZlbk5hbWUiOiIiLCJyaGF0VVVJRCI6IiIsInN1cm5hbWUiOiIifSwieDUwOSI6eyJzdWJqZWN0X2RuIjoiIiwiaXNzdWVyX2RuIjoiIn0sInNlcnZpY2VfYWNjb3VudCI6eyJjbGllbnRfaWQiOiIiLCJ1c2VybmFtZSI6IiJ9LCJ0eXBlIjoiU3lzdGVtIiwiYXV0aF90eXBlIjoiYmFzaWMtYXV0aCJ9LCJlbnRpdGxlbWVudHMiOm51bGx9Cg==
ht GET http://localhost:8080/api/module-update-router/v1/channel?module=insights-core "X-Rh-Identity: $(xrhidgen system | base64 -w0)"
The SEED
environment variable can be set to an integer. If set, it will be
used to initialize the generator to a deterministic state.
$ SEED=100 xrhidgen user
{"identity":{"employee_account_number":"02299","org_id":"41123","internal":{"org_id":"41123"},"user":{"username":"skeptic","email":"[email protected]","first_name":"Cameron","last_name":"Stehr","is_active":false,"is_org_admin":false,"is_internal":false,"locale":"fi","user_id":"meredeth"},"system":{},"associate":{"Role":null,"email":"","givenName":"","rhatUUID":"","surname":""},"x509":{"subject_dn":"","issuer_dn":""},"service_account":{"client_id":"","username":""},"type":"User","auth_type":"basic-auth"},"entitlements":null}
Go package
Installation
go get github.com/subpop/xrhidgen@latest
Usage
package main
import (
"encoding/json"
"fmt"
"github.com/subpop/xrhidgen"
)
func main() {
xrhidgen.SetSeed(103)
id, err := xrhidgen.NewUserIdentity(xrhidgen.Identity{}, xrhidgen.User{})
if err != nil {
panic(err)
}
data, err := json.Marshal(id)
if err != nil {
panic(err)
}
fmt.Println(string(data))
}
# Packages
No description provided by the author
# Functions
NewAssociate will build and return a fully populated Associate data structure, using any values that are present in template.
NewAssociateIdentity will build and return a fully populated Associate identity record, using any values that are present in identityTemplate and associateTemplate.
NewIdentity will build and return a partially populated Identity data structure, using any values that are present in template.
NewInternal will build and return a fully populated Internal data structure, using any values that are present in template.
NewInternalIdentity will build and return a fully populated Internal identity record, using any values that are present in identityTemplate and internalTemplate.
NewServiceAccount will build and return a fully populated ServiceAccount data structure, using any values that are present in template.
NewServiceAccountIdentity will build and return a fully populated ServiceAccount identity record, using any values that are present in identityTemplate and serviceAccountTemplate.
NewSystem will build and return a fully populated System data structure, using any values that are present in template.
NewSystemIdentity will build and return a fully populated System identity record, using any values that are present in identityTemplate and systemTemplate.
NewUser will build and return a fully populated User data structure, using any values that are present in template.
NewUserIdentity will build and return a fully populated User identity record, using any values that are present in identityTemplate and userTemplate.
NewX509 will build and return a fully populated X509 data structure, using any values that are present in template.
NewX509Identity will build and return a fully populated X509 identity record, using any values that are present in identityTemplate and x509Template.
SetSeed uses the provided seed value to initialize the generator to a deterministic state (see rand.Seed).
# Structs
Associate holds values to be used as input when generating an associate identity record.
Identity holds values to be used as input when generating a main identity record.
Internal holds values to be used as input when generating an internal identity record.
ServiceAccount holds values to be used as input when generating a service account identity record.
System holds values to be used as input when generating a system identity record.
User holds values to be used as input when generating a user identity record.
X509 holds values to be used as input when generating an x509 identity record.