Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add logging message #25

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions pkg/identity/identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"time"

"github.com/yahoo/athenz/clients/go/zts"
"github.com/yahoo/k8s-athenz-identity/pkg/log"
"github.com/yahoo/k8s-athenz-identity/pkg/util"
)

Expand Down Expand Up @@ -102,6 +103,7 @@ func InitIdentityHandler(config *IdentityConfig) (*identityHandler, error) {

// GetX509Cert makes ZTS API calls to generate an X.509 certificate
func (h *identityHandler) GetX509Cert() (*zts.InstanceIdentity, []byte, error) {
log.Debugf("Generating Key And CSR with the following parameters: Subject: %v, SAN: %v", h.csrOptions.Subject, h.csrOptions.SANs)
keyPEM, csrPEM, err := util.GenerateKeyAndCSR(h.csrOptions)
if err != nil {
return nil, nil, err
Expand All @@ -112,25 +114,31 @@ func (h *identityHandler) GetX509Cert() (*zts.InstanceIdentity, []byte, error) {
return nil, nil, err
}

provider := zts.ServiceName(h.config.ProviderService)
domain := zts.DomainName(h.domain)
service := zts.SimpleName(h.service)
attestationData := string(saToken)
csrPEMString := string(csrPEM)

if h.config.Init {
log.Debugf("Sending PostInstanceRegisterInformation request to ZTS, Provider: %s, Domain: %s, Service: %s, Attestation Data: %s, CSR: %s", provider, domain, service, attestationData, csrPEM)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we not log the attestationData since it could be used for replay attacks?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prabushyam Hi Prabu, since it's set as a debug level, I suppose it wouldn't be a risk to print. I would also think it's useful for some troubleshooting cases.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prabushyam Are you okay with attestationData being printed in debug mode?

id, _, err := h.client.PostInstanceRegisterInformation(&zts.InstanceRegisterInformation{
Provider: zts.ServiceName(h.config.ProviderService),
Domain: zts.DomainName(h.domain),
Service: zts.SimpleName(h.service),
AttestationData: string(saToken),
Csr: string(csrPEM),
Provider: provider,
Domain: domain,
Service: service,
AttestationData: attestationData,
Csr: csrPEMString,
})
return id, keyPEM, err
}

id, err := h.client.PostInstanceRefreshInformation(
zts.ServiceName(h.config.ProviderService),
zts.DomainName(h.domain),
zts.SimpleName(h.service),
zts.PathElement(h.config.PodUID),
podUID := zts.PathElement(h.config.PodUID)

log.Debugf("Sending PostInstanceRefreshInformation request to ZTS, Provider: %s, Domain: %s, Service: %s, podUID: %s, Attestation Data: %s, CSR: %s", provider, domain, service, podUID, attestationData, csrPEM)
id, err := h.client.PostInstanceRefreshInformation(provider, domain, service, podUID,
&zts.InstanceRefreshInformation{
AttestationData: string(saToken),
Csr: string(csrPEM),
AttestationData: attestationData,
Csr: csrPEMString,
})

return id, keyPEM, err
Expand Down