-
Notifications
You must be signed in to change notification settings - Fork 487
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
Enable agent path template customization for azure_msi node attestor plugin #3488
Enable agent path template customization for azure_msi node attestor plugin #3488
Conversation
…e_msi plugin spiffe#3420 Signed-off-by: Guilherme Carvalho <guilhermbrsp@gmail.com>
Signed-off-by: Guilherme Carvalho <guilhermbrsp@gmail.com>
Signed-off-by: Guilherme Carvalho <guilhermbrsp@gmail.com>
Signed-off-by: Guilherme Carvalho <guilhermbrsp@gmail.com>
Thanks for opening this, @guilhermocc ! I'll see if I can get it reviewed here shortly. Just for information, you don't need to bother keeping the branch up to date. Once it has been approved, we (the maintainers) will update it as needed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @guilhermocc! Just a few comments.
} | ||
return u.String() | ||
TenantID string `json:"tid,omitempty"` | ||
PrincipalID string `json:"sub,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a double take and had to remind myself what happens with the JSON decoder when there are two fields with the same tag. Fortunately the top level field takes precedence over the embedded struct but this is going to be a little subtle if there is any code that tries to use the .Subject
field (since it will be unset). Should be easy enough to catch in testing though. I think we're ok here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about creating a new struct for only storing claims/fields that we want to expose and use. But we would still have another struct being composed by jwt.Claims
only, since we use the ValidateWithLeeway
method for validation, but I'm not sure if that would make the code clearer since we will be going to deserialize the token two times for two different structs, what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we're ok with it as-is. If the Subject
field is used at all the unit-tests should catch that it is empty.
Co-authored-by: Andrew Harding <azdagron@gmail.com> Signed-off-by: Guilherme Carvalho <guilhermbrsp@gmail.com>
fa1ff86
to
d9c540f
Compare
Signed-off-by: Guilherme Carvalho <guilhermbrsp@gmail.com>
b038635
to
430a6c6
Compare
pkg/common/plugin/azure/msi_test.go
Outdated
|
||
for _, test := range tests { | ||
t.Run(test.name, func(t *testing.T) { | ||
td, _ := spiffeid.TrustDomainFromString(test.args.td) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
td, _ := spiffeid.TrustDomainFromString(test.args.td) | |
td := spiffeid.RequireTrustDomainFromString(test.args.td) |
pkg/common/plugin/azure/msi_test.go
Outdated
{ | ||
name: "successfully applies template", | ||
args: args{ | ||
"example.org", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you set far names in all cases you create a new struct? it can resutl in unexpected errors if we choose to add more fields
pkg/common/plugin/azure/msi_test.go
Outdated
name string | ||
args args | ||
want string | ||
wantErr bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of want error, can you instead validate the error you are getting? it is possible to get into situations where you get another error and not the expected one
var selectorValues []string | ||
selectorValues = append(selectorValues, vmSelectors...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var selectorValues []string | |
selectorValues = append(selectorValues, vmSelectors...) | |
selectorValues := append([]string(nil), vmSelectors...) |
| Configuration | Required | Description | Default | | ||
|-----------------------|----------|-------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------| | ||
| `tenants` | Required | A map of tenants, keyed by tenant ID, that are authorized for attestation. Tokens for unspecified tenants are rejected. | | | ||
| `agent_path_template` | Optional | A URL path portion format of Agent's SPIFFE ID. Describe in text/template format. | `"/{{ .PluginName }}/{{ .TenantID }}/{{ .PrincipalID }}"` | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you update server_full.conf, with this new configuration?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure!
Signed-off-by: Guilherme Carvalho <guilhermbrsp@gmail.com>
Signed-off-by: Guilherme Carvalho <guilhermbrsp@gmail.com>
Signed-off-by: Guilherme Carvalho <guilhermbrsp@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!!!
…plugin (spiffe#3488) Signed-off-by: Guilherme Carvalho <guilhermbrsp@gmail.com>
Pull Request check list
Affected functionality
Description of change
agent_path_template
that is used for building the agent's SPIFFE ID.Which issue this PR fixes
fixes #3420