Created
August 3, 2022 17:13
-
-
Save sumanthkumarc/538c5b1d0c565e3369fd287d78d6ad01 to your computer and use it in GitHub Desktop.
Function responsible for authenticating data plane token
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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