syntax = "proto3";
package foxtrot;

import "ft_error.proto";
import "ft_types.proto";
import "google/protobuf/timestamp.proto";

message auth_data
{
   string userid = 1;
   bytes token = 2;
   int32 authlevel = 3;
   int32 authflags = 4;
   google.protobuf.Timestamp expiry = 5;
}

message auth_request
{
    string userid = 1;
}

message auth_challenge
{
    errstatus err = 1;
    uint32 challengeid = 2;
    bytes challenge = 3;
}

message auth_response
{
    uint32 challengeid = 1;
    string userid = 2;
    bytes sig = 3;
}

message auth_confirm
{
    errstatus err = 1;
    bytes sessionkey = 2;
    uint64 expiry = 3;
    int32 authlevel = 4;
}


message sasl_auth_data
{
    errstatus err = 1;
    bytes sasl_data = 2;
    auth_data authdat = 3;
}

message auth_type_list
{
    errstatus err = 1;
    repeated string mechanism_name = 2;
}

service auth
{
    rpc RequestAuthChallenge (auth_request) returns (auth_challenge);
    rpc RespondAuthChallenge (auth_response) returns (auth_confirm);

    rpc GetSupportedAuthMechanisms (empty) returns (auth_type_list);
    rpc SaslAuthProcess (stream sasl_auth_data) returns (stream sasl_auth_data);
    rpc VerifyToken(sasl_auth_data) returns (sasl_auth_data);
}
