Skip to content

Conversation

@prakhar29jain
Copy link

Initially the auth used the PERSES_TOKEN directly to initialize a Perses client which was not secure.
Now we are using the client credentials to fetch the token.
Removed manual OAuth token retrieval from main; Perses client now handles auth internally.
Aligned Perses client initialization with configuration structure (HTTPClient, RestConfigClient, OAuth).
Updated main.go to use the new config-based client initialization.


func initializePersesClient(baseURL string) (apiClient.ClientInterface, error) {

bearerToken := os.Getenv(PERSES_TOKEN)
Copy link
Member

Choose a reason for hiding this comment

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

To not introduce breaking change, you can keep taking the PERSES_TOKEN env var to set it in the config if provided.

config/config.go Outdated

type GlobalConfig struct {
AppConfig AppConfig `yaml:"app_config"`
AuthConfig AuthConfig `yaml:"auth_config"`
Copy link
Member

Choose a reason for hiding this comment

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

RestConfigClient contains already everything you need to communicate with Perses. The server URL, the token URL, the client id and secret. You don't need all that.

Even AppConfig is useless here. It's only logged for the most part. Please don't introduce unrelated configuration into this PR. this is only about perses creds

main.go Outdated

restClient, err := config.NewRESTClient(config.RestConfigClient{
func initializePersesAPIClient(baseURL string, authConfig config.AuthConfig) (apiClient.ClientInterface, error) {
restClient, err := clientConfig.NewRESTClient(clientConfig.RestConfigClient{
Copy link
Member

Choose a reason for hiding this comment

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

you should pass directly a RestConfigClient, from the config.

Copy link
Member

@celian-garcia celian-garcia left a comment

Choose a reason for hiding this comment

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

Thanks for taking care of this! I like the intent, but I guess it's still a bit rough to be ready to merge.

main.go Outdated
Comment on lines 30 to 37
flag.StringVar(&configFile, "config", "", "Path to the yaml configuration file")
flag.StringVar(&persesServerURL, "perses-server-url", "http://localhost:8080", "The Perses backend server URL")
flag.StringVar(&logLevel, "log-level", "info", "Log level (debug, info, warn, error)")
flag.StringVar(&transport, "transport", "stdio", "MCP protocol currently supports 'stdio' and 'http-streamable' transport mechanisms")
flag.StringVar(&transport, "transport", "stdio", "MCP protocol supports 'stdio' and 'streamable-http' transports")
flag.StringVar(&port, "port", "8000", "Port to run the HTTP Streamable server on")
flag.BoolVar(&readOnly, "read-only", false, "Restrict the server to read-only operations")
flag.StringVar(&tokenURL, "token-url", "", "Perses token endpoint URL")
flag.BoolVar(&readOnly, "read-only", false, "Restrict the server to read-only ops")
flag.Parse()

Choose a reason for hiding this comment

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

IMHO since you are introducing the usage of config file managed via perses/common then you can (should?) get rid of the flags that are duplicating the same information.

Choose a reason for hiding this comment

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

But I agree with Celian that changes regarding app config (e.g port & transport) are out of scope of this PR

Copy link
Member

Choose a reason for hiding this comment

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

I created an issue for that #60

Copy link
Author

Choose a reason for hiding this comment

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

Thank You for your input @celian-garcia , @AntoineThebaud
I will take make a separate PR for the config based approach soon.

In the mean time I have updated this PR for you to check.

@prakhar29jain prakhar29jain force-pushed the feature/auth branch 2 times, most recently from 4de7432 to d75db8b Compare December 18, 2025 17:25
…Grant

Signed-off-by: Prakhar JAIN <prakhar.jain@amadeus.com>
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