protoc-gen-redact

command module
v2.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 13, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

README

protoc-gen-redact (PGR)

Build Go Report Card Go Reference License GitHub release

protoc-gen-redact (PGR) is a protoc plugin to redact field values in GRPC client calls from the server. This plugin adds support to protoc-generated code to redact certain fields in the GRPC calls.

Developers only need import the PGR extension and annotate the messages or fields in their proto files to redact:

syntax = "proto3";

package user;

import "redact/redact.proto";
import "google/protobuf/empty.proto";

option go_package = "github.com/arrakis-digital/protoc-gen-redact/v2/examples/user/pb;user";

message User {
    // User credentials
    string username = 1;
    string password = 2 [(redact.redact) = true]; // default redaction

    // User information
    string email = 3 [(redact.custom).string = "r*d@ct*d"];
    string name = 4;
    Location home = 5;
    message Location {
        double lat = 1;
        double lng = 2;
    }
}

service Chat {
    rpc GetUser(GetUserRequest) returns (User);
    rpc GetUserInternal(GetUserRequest) returns (User) {
        option (redact.method_skip) = true;
    }
    rpc ListUsers (google.protobuf.Empty) returns (ListUsersResponse) {
        option (redact.internal_method) = true;
    }
}

message GetUserRequest {
    string username = 1;
}

message ListUsersResponse {
    repeated User users = 1;
}

Request for Contribution

Contributors are more than welcome and much appreciated. Please feel free to open a PR to improve anything you don't like, or would like to add.

Please make your changes in a specific branch and create a pull request into master! If you can, please make sure all the changes work properly and does not affect the existing functioning.

No PR is too small! Even the smallest effort is countable.

License

This project is licensed under the Apache License 2.0

Documentation

Overview

Package main implements generator for protoc-gen-redact

Directories

Path Synopsis
examples
Package redact provides interfaces and methods to help implement redaction.
Package redact provides interfaces and methods to help implement redaction.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL