Skip to content

Pylon auth update#7

Open
neil-botelho-reef wants to merge 11 commits into
masterfrom
pylon-auth-update
Open

Pylon auth update#7
neil-botelho-reef wants to merge 11 commits into
masterfrom
pylon-auth-update

Conversation

@neil-botelho-reef
Copy link
Copy Markdown
Collaborator

Update nexus auth to support:

  • new pylon endpoints for getting certificates
  • Auth via identity name and token.
  • retrying certificate verification when the public key is retrieved from cache

Copy link
Copy Markdown

@jakub-zytka-reef jakub-zytka-reef left a comment

Choose a reason for hiding this comment

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

oh shit, I added comments but haven't published the review.
Sorry, my bad

Comment thread cmd/nexus-auth/main.go Outdated
}
if *netUID >= 0 {
config.SetNetUID(*netUID)
} else if config.GetNetUID() < 0 {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit: why else?
I just want to understand your way of thinking

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

in configuration.NewConfig() netUID is set based on the NEXUS_PYLON_NETUID env variable or it's set to -1. So here the else block is making sure a valid value is set for that env variable in case the user doesn't specify the netUID when calling the run command.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

OK, so when I read:

} else if config.GetNetUID() < 0 {
    // netuid is required

then I think - OK, netuid is required, but not always. Only when the previous condition evaluates to false so that the else triggers.
So I've got to go back and check when is netuid not required when the condition evaluates to true.

It's too complex and I'm lazy.
Thus I write just

if config.GetNetUID() < 0 {
    // netuid is required
}

and then I know that netuid must be provided always, regardless of whether it comes from the env, or the cli.

So that's why I asked if there's a reason for having else.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

That makes sense. That way is easier to read as well. I'll update it accordingly.

Comment thread internal/auth/auth.go Outdated
if cachedKey, found := a.cache.Get(sanitizedOrgName); found {
log.Printf("Cache hit for organization '%s'", sanitizedOrgName)
return cachedKey, nil
if err := a.validatePublicKey(cert, cachedKey); err != nil {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

IIUC, as discussed on slack, we don't need these caching-related changes?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I think the conclusion we came to was to only refresh the cache every 3 minutes. Should I implement that? Or just remove my cache invalidation logic?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think your cache invalidation logic should be removed.

In order to have 3 min TTL for the cache entries - is there anything specific that needs to be implemented? I don't remember, but I think we already have TTL in the cache?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

you're right. I'll remove my cache invalidation.

Comment thread README.md
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.

2 participants