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

Auth for exporting traces #1226

Merged
merged 10 commits into from
Jun 16, 2023

Conversation

RebeccaMahany
Copy link
Contributor

@RebeccaMahany RebeccaMahany commented Jun 12, 2023

Adds a gRPC wrapper that adds a bearer auth header to all outgoing trace exports. Also allows the ingest server URL and the export traces flag to be set by the control server.

sequenceDiagram
    Participant Control server
    Box Launcher
        Participant Control service
        Participant Agent flags subsystem
        Participant Auth token subsystem
        Participant Traces exporter
    end
    Participant Agent collector

    loop Config generation
        Control server ->> Control server: Generate JWT with TTL of 24 hours
        Control service ->> Control server: Perform regular check to see if subsystem data has changed
        Control server ->> Control service: Return config, including JWT
    end

    opt Ingest URL update
        Control service ->> Agent flags subsystem: Perform update
        Agent flags subsystem ->> Traces exporter: Notify that URL has changed
        Traces exporter ->> Traces exporter: Init new exporter using new ingest URL
    end

    opt Token update
        Control service ->> Auth token subsystem: Perform update
        Auth token subsystem ->> Auth token subsystem: Store new token
        Control service ->> Traces exporter: Ping
        Traces exporter ->> Auth token subsystem: Fetch new token
        Traces exporter ->> Traces exporter: Replace token used for export
    end

    Traces exporter ->> Agent collector: Send traces with bearer auth header to stored ingest URL
    
    Agent collector ->> Agent collector: Validate JWT
    Agent collector ->> Agent collector: Process and store traces
Loading

@RebeccaMahany RebeccaMahany marked this pull request as ready for review June 13, 2023 21:34
cmd/launcher/options.go Outdated Show resolved Hide resolved
pkg/traces/exporter/exporter.go Outdated Show resolved Hide resolved
Comment on lines +9 to +11
type clientAuthenticator struct {
token string
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This makes sense to me, but I think it would benefit from the addition of SetNewToken(token string)

That would allow the token to be updated, without create a new exporter.

Copy link
Contributor

Choose a reason for hiding this comment

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

I suspect it would be super clean to create one, and register it with knapsack.RegisterChangeObserver

Maybe pull that into New(k knapsack)? Not sure...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, definitely cleaner! I'll update

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is updated -- I ended up making TraceExporter subscribe to the ingest updates, and swap in the token when pinged.

Copy link
Contributor

@James-Pickett James-Pickett left a comment

Choose a reason for hiding this comment

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

nice!

pkg/agent/flags/flag_controller.go Outdated Show resolved Hide resolved
pkg/traces/exporter/exporter.go Outdated Show resolved Hide resolved
James-Pickett
James-Pickett previously approved these changes Jun 15, 2023
Copy link
Contributor

@James-Pickett James-Pickett left a comment

Choose a reason for hiding this comment

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

awesome sauce

@RebeccaMahany RebeccaMahany merged commit ff41b09 into kolide:main Jun 16, 2023
@RebeccaMahany RebeccaMahany deleted the becca/auth-for-export branch June 16, 2023 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants