Skip to content

Instantly share code, notes, and snippets.

@sumanthkumarc
Created August 3, 2022 17:13
Show Gist options
  • Save sumanthkumarc/538c5b1d0c565e3369fd287d78d6ad01 to your computer and use it in GitHub Desktop.
Save sumanthkumarc/538c5b1d0c565e3369fd287d78d6ad01 to your computer and use it in GitHub Desktop.
Function responsible for authenticating data plane token
// Copied from https://github.com/kumahq/kuma/blob/master/pkg/xds/auth/universal/authenticator.go
func (u *universalAuthenticator) authDataplane(ctx context.Context, dataplane *core_mesh.DataplaneResource, credential auth.Credential) error {
dpIdentity, err := u.dataplaneValidator.Validate(ctx, credential, dataplane.Meta.GetMesh())
if err != nil {
return err
}
if dpIdentity.Name != "" && dataplane.Meta.GetName() != dpIdentity.Name {
return errors.Errorf("proxy name from requestor: %s is different than in token: %s", dataplane.Meta.GetName(), dpIdentity.Name)
}
if dpIdentity.Mesh != "" && dataplane.Meta.GetMesh() != dpIdentity.Mesh {
return errors.Errorf("proxy mesh from requestor: %s is different than in token: %s", dataplane.Meta.GetMesh(), dpIdentity.Mesh)
}
if err := validateTags(dpIdentity.Tags, dataplane.Spec.TagSet()); err != nil {
return err
}
return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment