syntax = "proto3";

package gosdn.rbac;

import "google/api/annotations.proto";
import "google/protobuf/descriptor.proto";
import "protoc-gen-openapiv2/options/annotations.proto";

option go_package = "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/rbac";

service AuthService {

    // Allows a user to login creating a session for further actions.
    rpc Login(LoginRequest) returns (LoginResponse) {
        option (google.api.http) = {
            post: "/login"
            body: "*"
        };
    }

    // Allows a user to log out from an existing session.
    rpc Logout(LogoutRequest) returns (LogoutResponse) {
        option (google.api.http) = {
            post: "/logout/{username}"
        };
    }
}

enum Status {
    STATUS_UNSPECIFIED = 0;
    STATUS_OK = 1;
    STATUS_ERROR = 2;
}

// Login
message LoginRequest {
    int64 timestamp = 1;
    string username = 2;
    string pwd = 3;
}

message LoginResponse {
    int64 timestamp = 1;
    Status status = 2;
    string token = 3;
}

// Logout
message LogoutRequest {
    int64 timestamp = 1;
    string username = 2;
}

message LogoutResponse {
    int64 timestamp = 1;
    Status status = 2;
}
