syntax = "proto3";

message OauthProviderInfo {
  int64 ID = 1;
  string created_at = 2;
  string updated_at = 3;
  string name = 4;
  string client_id = 5;
  string client_secret = 6; // secret
  string redirect_url = 7;
  string scopes = 8;
  string auth_url = 9;
  string token_url = 10;
  string info_url = 11;
  string description = 12;
  bool system = 13;
  bool init = 14;
}

message OauthProviderReq {
  int64 ID = 1;
  string name = 2;
  string client_id = 3;
  optional bool system = 4;
  optional bool init = 5;

  optional Pagination page = 10;
}

message OauthProviderListResp {
  optional Pagination page = 1;
  repeated OauthProviderInfo data = 2;
}

message CallbackReq {
  string state = 1;
  string code = 2;
}

message OauthLoginReq {
  string state = 1;
  string provider = 2;
}

message OauthRedirectResp {
  string url = 1;
}


service Core {
  // OauthProvider management
  // group: oauth_provider
  rpc createOauthProvider (OauthProviderInfo) returns (BaseIDResp);
  // group: oauth_provider
  rpc updateOauthProvider (OauthProviderInfo) returns (BaseResp);
  // group: oauth_provider
  rpc getOauthProviderList (OauthProviderReq) returns (OauthProviderListResp);
  // group: oauth_provider
  rpc getOauthProvider (OauthProviderReq) returns (OauthProviderInfo);
  // group: oauth_provider
  rpc deleteOauthProvider (IDsReq) returns (BaseResp);
  // group: oauth_provider
  rpc oauthLogin (OauthLoginReq) returns (OauthRedirectResp);
  // group: oauth_provider
  rpc oauthCallback (CallbackReq) returns (UserInfo);

}