mirror of https://github.com/synctv-org/synctv
Feat: oauth2 provider plugins
parent
6a50fa596e
commit
83843d3c3c
@ -0,0 +1,192 @@
|
||||
package provider
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/go-hclog"
|
||||
plugin "github.com/hashicorp/go-plugin"
|
||||
log "github.com/sirupsen/logrus"
|
||||
sysnotify "github.com/synctv-org/synctv/internal/sysNotify"
|
||||
providerpb "github.com/synctv-org/synctv/proto/provider"
|
||||
"golang.org/x/oauth2"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
type ProviderPlugin struct {
|
||||
plugin.Plugin
|
||||
Impl ProviderInterface
|
||||
}
|
||||
|
||||
func (p *ProviderPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error {
|
||||
providerpb.RegisterOauth2PluginServer(s, &GRPCServer{Impl: p.Impl})
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *ProviderPlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error) {
|
||||
return &GRPCClient{client: providerpb.NewOauth2PluginClient(c)}, nil
|
||||
}
|
||||
|
||||
type GRPCServer struct {
|
||||
providerpb.UnimplementedOauth2PluginServer
|
||||
Impl ProviderInterface
|
||||
}
|
||||
|
||||
func (s *GRPCServer) Init(ctx context.Context, req *providerpb.InitReq) (*providerpb.Enpty, error) {
|
||||
s.Impl.Init(Oauth2Option{
|
||||
ClientID: req.ClientId,
|
||||
ClientSecret: req.ClientSecret,
|
||||
RedirectURL: req.RedirectUrl,
|
||||
})
|
||||
return &providerpb.Enpty{}, nil
|
||||
}
|
||||
|
||||
func (s *GRPCServer) Provider(ctx context.Context, req *providerpb.Enpty) (*providerpb.ProviderResp, error) {
|
||||
return &providerpb.ProviderResp{Name: string(s.Impl.Provider())}, nil
|
||||
}
|
||||
|
||||
func (s *GRPCServer) NewAuthURL(ctx context.Context, req *providerpb.NewAuthURLReq) (*providerpb.NewAuthURLResp, error) {
|
||||
return &providerpb.NewAuthURLResp{Url: s.Impl.NewAuthURL(req.State)}, nil
|
||||
}
|
||||
|
||||
func (s *GRPCServer) GetToken(ctx context.Context, req *providerpb.GetTokenReq) (*providerpb.Token, error) {
|
||||
token, err := s.Impl.GetToken(ctx, req.Code)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &providerpb.Token{
|
||||
AccessToken: token.AccessToken,
|
||||
TokenType: token.TokenType,
|
||||
RefreshToken: token.RefreshToken,
|
||||
Expiry: token.Expiry.Unix(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *GRPCServer) GetUserInfo(ctx context.Context, req *providerpb.GetUserInfoReq) (*providerpb.GetUserInfoResp, error) {
|
||||
userInfo, err := s.Impl.GetUserInfo(ctx, &oauth2.Token{
|
||||
AccessToken: req.Token.AccessToken,
|
||||
TokenType: req.Token.TokenType,
|
||||
Expiry: time.Unix(req.Token.Expiry, 0),
|
||||
RefreshToken: req.Token.RefreshToken,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp := &providerpb.GetUserInfoResp{
|
||||
Username: userInfo.Username,
|
||||
ProviderUserId: uint64(userInfo.ProviderUserID),
|
||||
}
|
||||
if userInfo.TokenRefreshed != nil {
|
||||
resp.TokenRefreshed = &providerpb.Token{
|
||||
AccessToken: userInfo.TokenRefreshed.Token.AccessToken,
|
||||
TokenType: userInfo.TokenRefreshed.Token.TokenType,
|
||||
RefreshToken: userInfo.TokenRefreshed.Token.RefreshToken,
|
||||
Expiry: userInfo.TokenRefreshed.Token.Expiry.Unix(),
|
||||
}
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
type GRPCClient struct{ client providerpb.Oauth2PluginClient }
|
||||
|
||||
var _ ProviderInterface = (*GRPCClient)(nil)
|
||||
|
||||
func (c *GRPCClient) Init(o Oauth2Option) {
|
||||
c.client.Init(context.Background(), &providerpb.InitReq{
|
||||
ClientId: o.ClientID,
|
||||
ClientSecret: o.ClientSecret,
|
||||
RedirectUrl: o.RedirectURL,
|
||||
})
|
||||
}
|
||||
|
||||
func (c *GRPCClient) Provider() OAuth2Provider {
|
||||
resp, err := c.client.Provider(context.Background(), &providerpb.Enpty{})
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
return OAuth2Provider(resp.Name)
|
||||
}
|
||||
|
||||
func (c *GRPCClient) NewAuthURL(state string) string {
|
||||
resp, err := c.client.NewAuthURL(context.Background(), &providerpb.NewAuthURLReq{State: state})
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
return resp.Url
|
||||
}
|
||||
|
||||
func (c *GRPCClient) GetToken(ctx context.Context, code string) (*oauth2.Token, error) {
|
||||
resp, err := c.client.GetToken(ctx, &providerpb.GetTokenReq{Code: code})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &oauth2.Token{
|
||||
AccessToken: resp.AccessToken,
|
||||
TokenType: resp.TokenType,
|
||||
RefreshToken: resp.RefreshToken,
|
||||
Expiry: time.Unix(resp.Expiry, 0),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *GRPCClient) GetUserInfo(ctx context.Context, tk *oauth2.Token) (*UserInfo, error) {
|
||||
resp, err := c.client.GetUserInfo(ctx, &providerpb.GetUserInfoReq{
|
||||
Token: &providerpb.Token{
|
||||
AccessToken: tk.AccessToken,
|
||||
TokenType: tk.TokenType,
|
||||
RefreshToken: tk.RefreshToken,
|
||||
Expiry: tk.Expiry.Unix(),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &UserInfo{
|
||||
Username: resp.Username,
|
||||
ProviderUserID: uint(resp.ProviderUserId),
|
||||
}, nil
|
||||
}
|
||||
|
||||
var HandshakeConfig = plugin.HandshakeConfig{
|
||||
ProtocolVersion: 1,
|
||||
MagicCookieKey: "BASIC_PLUGIN",
|
||||
MagicCookieValue: "hello",
|
||||
}
|
||||
|
||||
var pluginMap = map[string]plugin.Plugin{
|
||||
"Provider": &ProviderPlugin{},
|
||||
}
|
||||
|
||||
func InitProviderPlugins(name string, arg ...string) error {
|
||||
client := plugin.NewClient(&plugin.ClientConfig{
|
||||
HandshakeConfig: HandshakeConfig,
|
||||
Plugins: pluginMap,
|
||||
Cmd: exec.Command(name, arg...),
|
||||
AllowedProtocols: []plugin.Protocol{
|
||||
plugin.ProtocolGRPC},
|
||||
Logger: hclog.New(&hclog.LoggerOptions{
|
||||
Name: "plugin",
|
||||
Output: log.StandardLogger().Writer(),
|
||||
Level: hclog.Debug,
|
||||
}),
|
||||
})
|
||||
sysnotify.RegisterSysNotifyTask(0, sysnotify.NewSysNotifyTask("plugin", sysnotify.NotifyTypeEXIT, func() error {
|
||||
client.Kill()
|
||||
return nil
|
||||
}))
|
||||
c, err := client.Client()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
i, err := c.Dispense("Provider")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
provider, ok := i.(ProviderInterface)
|
||||
if !ok {
|
||||
return fmt.Errorf("%s not implement ProviderInterface", name)
|
||||
}
|
||||
registerProvider(provider)
|
||||
return nil
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
plugin "github.com/hashicorp/go-plugin"
|
||||
"github.com/synctv-org/synctv/internal/provider"
|
||||
"golang.org/x/oauth2"
|
||||
)
|
||||
|
||||
type GiteeProvider struct {
|
||||
config oauth2.Config
|
||||
}
|
||||
|
||||
func (p *GiteeProvider) Init(c provider.Oauth2Option) {
|
||||
p.config.Scopes = []string{"user_info"}
|
||||
p.config.Endpoint = oauth2.Endpoint{
|
||||
AuthURL: "https://gitee.com/oauth/authorize",
|
||||
TokenURL: "https://gitee.com/oauth/token",
|
||||
}
|
||||
p.config.ClientID = c.ClientID
|
||||
p.config.ClientSecret = c.ClientSecret
|
||||
p.config.RedirectURL = c.RedirectURL
|
||||
}
|
||||
|
||||
func (p *GiteeProvider) Provider() provider.OAuth2Provider {
|
||||
return "gitee"
|
||||
}
|
||||
|
||||
func (p *GiteeProvider) NewAuthURL(state string) string {
|
||||
return p.config.AuthCodeURL(state, oauth2.AccessTypeOnline)
|
||||
}
|
||||
|
||||
func (p *GiteeProvider) GetToken(ctx context.Context, code string) (*oauth2.Token, error) {
|
||||
return p.config.Exchange(ctx, code)
|
||||
}
|
||||
|
||||
func (p *GiteeProvider) GetUserInfo(ctx context.Context, tk *oauth2.Token) (*provider.UserInfo, error) {
|
||||
client := p.config.Client(ctx, tk)
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, "https://gitee.com/api/v5/user", nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
ui := giteeUserInfo{}
|
||||
err = json.NewDecoder(resp.Body).Decode(&ui)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &provider.UserInfo{
|
||||
Username: ui.Login,
|
||||
ProviderUserID: ui.ID,
|
||||
}, nil
|
||||
}
|
||||
|
||||
type giteeUserInfo struct {
|
||||
ID uint `json:"id"`
|
||||
Login string `json:"login"`
|
||||
}
|
||||
|
||||
func main() {
|
||||
var pluginMap = map[string]plugin.Plugin{
|
||||
"Provider": &provider.ProviderPlugin{Impl: &GiteeProvider{}},
|
||||
}
|
||||
plugin.Serve(&plugin.ServeConfig{
|
||||
HandshakeConfig: provider.HandshakeConfig,
|
||||
Plugins: pluginMap,
|
||||
GRPCServer: plugin.DefaultGRPCServer,
|
||||
})
|
||||
}
|
@ -1,2 +1,3 @@
|
||||
#!/bin/bash
|
||||
protoc --go_out=./proto ./proto/*.proto
|
||||
protoc --go_out=./proto/message ./proto/message/*.proto
|
||||
protoc --go_out=./proto/provider --go-grpc_out=./proto/provider ./proto/provider/*.proto
|
||||
|
@ -0,0 +1,734 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.31.0
|
||||
// protoc v4.24.4
|
||||
// source: proto/provider/plugin.proto
|
||||
|
||||
package providerpb
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type InitReq struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"`
|
||||
ClientSecret string `protobuf:"bytes,2,opt,name=client_secret,json=clientSecret,proto3" json:"client_secret,omitempty"`
|
||||
RedirectUrl string `protobuf:"bytes,3,opt,name=redirect_url,json=redirectUrl,proto3" json:"redirect_url,omitempty"`
|
||||
}
|
||||
|
||||
func (x *InitReq) Reset() {
|
||||
*x = InitReq{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_provider_plugin_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *InitReq) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*InitReq) ProtoMessage() {}
|
||||
|
||||
func (x *InitReq) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_provider_plugin_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use InitReq.ProtoReflect.Descriptor instead.
|
||||
func (*InitReq) Descriptor() ([]byte, []int) {
|
||||
return file_proto_provider_plugin_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *InitReq) GetClientId() string {
|
||||
if x != nil {
|
||||
return x.ClientId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *InitReq) GetClientSecret() string {
|
||||
if x != nil {
|
||||
return x.ClientSecret
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *InitReq) GetRedirectUrl() string {
|
||||
if x != nil {
|
||||
return x.RedirectUrl
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type GetTokenReq struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Code string `protobuf:"bytes,1,opt,name=code,proto3" json:"code,omitempty"`
|
||||
}
|
||||
|
||||
func (x *GetTokenReq) Reset() {
|
||||
*x = GetTokenReq{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_provider_plugin_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *GetTokenReq) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetTokenReq) ProtoMessage() {}
|
||||
|
||||
func (x *GetTokenReq) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_provider_plugin_proto_msgTypes[1]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetTokenReq.ProtoReflect.Descriptor instead.
|
||||
func (*GetTokenReq) Descriptor() ([]byte, []int) {
|
||||
return file_proto_provider_plugin_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *GetTokenReq) GetCode() string {
|
||||
if x != nil {
|
||||
return x.Code
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type Token struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
AccessToken string `protobuf:"bytes,1,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"`
|
||||
TokenType string `protobuf:"bytes,2,opt,name=token_type,json=tokenType,proto3" json:"token_type,omitempty"`
|
||||
RefreshToken string `protobuf:"bytes,3,opt,name=refresh_token,json=refreshToken,proto3" json:"refresh_token,omitempty"`
|
||||
Expiry int64 `protobuf:"varint,4,opt,name=expiry,proto3" json:"expiry,omitempty"`
|
||||
}
|
||||
|
||||
func (x *Token) Reset() {
|
||||
*x = Token{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_provider_plugin_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Token) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Token) ProtoMessage() {}
|
||||
|
||||
func (x *Token) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_provider_plugin_proto_msgTypes[2]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Token.ProtoReflect.Descriptor instead.
|
||||
func (*Token) Descriptor() ([]byte, []int) {
|
||||
return file_proto_provider_plugin_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *Token) GetAccessToken() string {
|
||||
if x != nil {
|
||||
return x.AccessToken
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Token) GetTokenType() string {
|
||||
if x != nil {
|
||||
return x.TokenType
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Token) GetRefreshToken() string {
|
||||
if x != nil {
|
||||
return x.RefreshToken
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Token) GetExpiry() int64 {
|
||||
if x != nil {
|
||||
return x.Expiry
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type ProviderResp struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
|
||||
}
|
||||
|
||||
func (x *ProviderResp) Reset() {
|
||||
*x = ProviderResp{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_provider_plugin_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *ProviderResp) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ProviderResp) ProtoMessage() {}
|
||||
|
||||
func (x *ProviderResp) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_provider_plugin_proto_msgTypes[3]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ProviderResp.ProtoReflect.Descriptor instead.
|
||||
func (*ProviderResp) Descriptor() ([]byte, []int) {
|
||||
return file_proto_provider_plugin_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *ProviderResp) GetName() string {
|
||||
if x != nil {
|
||||
return x.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type NewAuthURLReq struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
State string `protobuf:"bytes,1,opt,name=state,proto3" json:"state,omitempty"`
|
||||
}
|
||||
|
||||
func (x *NewAuthURLReq) Reset() {
|
||||
*x = NewAuthURLReq{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_provider_plugin_proto_msgTypes[4]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *NewAuthURLReq) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*NewAuthURLReq) ProtoMessage() {}
|
||||
|
||||
func (x *NewAuthURLReq) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_provider_plugin_proto_msgTypes[4]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use NewAuthURLReq.ProtoReflect.Descriptor instead.
|
||||
func (*NewAuthURLReq) Descriptor() ([]byte, []int) {
|
||||
return file_proto_provider_plugin_proto_rawDescGZIP(), []int{4}
|
||||
}
|
||||
|
||||
func (x *NewAuthURLReq) GetState() string {
|
||||
if x != nil {
|
||||
return x.State
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type NewAuthURLResp struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Url string `protobuf:"bytes,1,opt,name=url,proto3" json:"url,omitempty"`
|
||||
}
|
||||
|
||||
func (x *NewAuthURLResp) Reset() {
|
||||
*x = NewAuthURLResp{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_provider_plugin_proto_msgTypes[5]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *NewAuthURLResp) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*NewAuthURLResp) ProtoMessage() {}
|
||||
|
||||
func (x *NewAuthURLResp) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_provider_plugin_proto_msgTypes[5]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use NewAuthURLResp.ProtoReflect.Descriptor instead.
|
||||
func (*NewAuthURLResp) Descriptor() ([]byte, []int) {
|
||||
return file_proto_provider_plugin_proto_rawDescGZIP(), []int{5}
|
||||
}
|
||||
|
||||
func (x *NewAuthURLResp) GetUrl() string {
|
||||
if x != nil {
|
||||
return x.Url
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type GetUserInfoReq struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Token *Token `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"`
|
||||
}
|
||||
|
||||
func (x *GetUserInfoReq) Reset() {
|
||||
*x = GetUserInfoReq{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_provider_plugin_proto_msgTypes[6]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *GetUserInfoReq) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetUserInfoReq) ProtoMessage() {}
|
||||
|
||||
func (x *GetUserInfoReq) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_provider_plugin_proto_msgTypes[6]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetUserInfoReq.ProtoReflect.Descriptor instead.
|
||||
func (*GetUserInfoReq) Descriptor() ([]byte, []int) {
|
||||
return file_proto_provider_plugin_proto_rawDescGZIP(), []int{6}
|
||||
}
|
||||
|
||||
func (x *GetUserInfoReq) GetToken() *Token {
|
||||
if x != nil {
|
||||
return x.Token
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type GetUserInfoResp struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"`
|
||||
ProviderUserId uint64 `protobuf:"varint,2,opt,name=provider_user_id,json=providerUserId,proto3" json:"provider_user_id,omitempty"`
|
||||
TokenRefreshed *Token `protobuf:"bytes,3,opt,name=token_refreshed,json=tokenRefreshed,proto3" json:"token_refreshed,omitempty"`
|
||||
}
|
||||
|
||||
func (x *GetUserInfoResp) Reset() {
|
||||
*x = GetUserInfoResp{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_provider_plugin_proto_msgTypes[7]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *GetUserInfoResp) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetUserInfoResp) ProtoMessage() {}
|
||||
|
||||
func (x *GetUserInfoResp) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_provider_plugin_proto_msgTypes[7]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetUserInfoResp.ProtoReflect.Descriptor instead.
|
||||
func (*GetUserInfoResp) Descriptor() ([]byte, []int) {
|
||||
return file_proto_provider_plugin_proto_rawDescGZIP(), []int{7}
|
||||
}
|
||||
|
||||
func (x *GetUserInfoResp) GetUsername() string {
|
||||
if x != nil {
|
||||
return x.Username
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *GetUserInfoResp) GetProviderUserId() uint64 {
|
||||
if x != nil {
|
||||
return x.ProviderUserId
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *GetUserInfoResp) GetTokenRefreshed() *Token {
|
||||
if x != nil {
|
||||
return x.TokenRefreshed
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Enpty struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
}
|
||||
|
||||
func (x *Enpty) Reset() {
|
||||
*x = Enpty{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_provider_plugin_proto_msgTypes[8]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Enpty) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Enpty) ProtoMessage() {}
|
||||
|
||||
func (x *Enpty) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_provider_plugin_proto_msgTypes[8]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Enpty.ProtoReflect.Descriptor instead.
|
||||
func (*Enpty) Descriptor() ([]byte, []int) {
|
||||
return file_proto_provider_plugin_proto_rawDescGZIP(), []int{8}
|
||||
}
|
||||
|
||||
var File_proto_provider_plugin_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_proto_provider_plugin_proto_rawDesc = []byte{
|
||||
0x0a, 0x1b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72,
|
||||
0x2f, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x70,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x22, 0x6e, 0x0a, 0x07, 0x49, 0x6e, 0x69, 0x74, 0x52, 0x65, 0x71, 0x12,
|
||||
0x1b, 0x0a, 0x09, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01,
|
||||
0x28, 0x09, 0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x23, 0x0a, 0x0d,
|
||||
0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x18, 0x02, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x0c, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x63, 0x72, 0x65,
|
||||
0x74, 0x12, 0x21, 0x0a, 0x0c, 0x72, 0x65, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x5f, 0x75, 0x72,
|
||||
0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x72, 0x65, 0x64, 0x69, 0x72, 0x65, 0x63,
|
||||
0x74, 0x55, 0x72, 0x6c, 0x22, 0x21, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x54, 0x6f, 0x6b, 0x65, 0x6e,
|
||||
0x52, 0x65, 0x71, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x22, 0x86, 0x01, 0x0a, 0x05, 0x54, 0x6f, 0x6b, 0x65,
|
||||
0x6e, 0x12, 0x21, 0x0a, 0x0c, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x74, 0x6f, 0x6b, 0x65,
|
||||
0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54,
|
||||
0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x5f, 0x74, 0x79,
|
||||
0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x54,
|
||||
0x79, 0x70, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x72, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x5f, 0x74,
|
||||
0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x72, 0x65, 0x66, 0x72,
|
||||
0x65, 0x73, 0x68, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x65, 0x78, 0x70, 0x69,
|
||||
0x72, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x65, 0x78, 0x70, 0x69, 0x72, 0x79,
|
||||
0x22, 0x22, 0x0a, 0x0c, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70,
|
||||
0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04,
|
||||
0x6e, 0x61, 0x6d, 0x65, 0x22, 0x25, 0x0a, 0x0d, 0x4e, 0x65, 0x77, 0x41, 0x75, 0x74, 0x68, 0x55,
|
||||
0x52, 0x4c, 0x52, 0x65, 0x71, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x01,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x22, 0x22, 0x0a, 0x0e, 0x4e,
|
||||
0x65, 0x77, 0x41, 0x75, 0x74, 0x68, 0x55, 0x52, 0x4c, 0x52, 0x65, 0x73, 0x70, 0x12, 0x10, 0x0a,
|
||||
0x03, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x22,
|
||||
0x34, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65,
|
||||
0x71, 0x12, 0x22, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b,
|
||||
0x32, 0x0c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x05,
|
||||
0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x8e, 0x01, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65,
|
||||
0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65,
|
||||
0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65,
|
||||
0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x28, 0x0a, 0x10, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65,
|
||||
0x72, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52,
|
||||
0x0e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12,
|
||||
0x35, 0x0a, 0x0f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x5f, 0x72, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68,
|
||||
0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x2e, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x0e, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x66,
|
||||
0x72, 0x65, 0x73, 0x68, 0x65, 0x64, 0x22, 0x07, 0x0a, 0x05, 0x45, 0x6e, 0x70, 0x74, 0x79, 0x32,
|
||||
0x94, 0x02, 0x0a, 0x0c, 0x4f, 0x61, 0x75, 0x74, 0x68, 0x32, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e,
|
||||
0x12, 0x26, 0x0a, 0x04, 0x49, 0x6e, 0x69, 0x74, 0x12, 0x0e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x2e, 0x49, 0x6e, 0x69, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x0c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x2e, 0x45, 0x6e, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x2f, 0x0a, 0x08, 0x50, 0x72, 0x6f, 0x76,
|
||||
0x69, 0x64, 0x65, 0x72, 0x12, 0x0c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x45, 0x6e, 0x70,
|
||||
0x74, 0x79, 0x1a, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x76, 0x69,
|
||||
0x64, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x12, 0x3b, 0x0a, 0x0a, 0x4e, 0x65, 0x77,
|
||||
0x41, 0x75, 0x74, 0x68, 0x55, 0x52, 0x4c, 0x12, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e,
|
||||
0x4e, 0x65, 0x77, 0x41, 0x75, 0x74, 0x68, 0x55, 0x52, 0x4c, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4e, 0x65, 0x77, 0x41, 0x75, 0x74, 0x68, 0x55, 0x52, 0x4c,
|
||||
0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x12, 0x2e, 0x0a, 0x08, 0x47, 0x65, 0x74, 0x54, 0x6f, 0x6b,
|
||||
0x65, 0x6e, 0x12, 0x12, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x47, 0x65, 0x74, 0x54, 0x6f,
|
||||
0x6b, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x1a, 0x0c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x54,
|
||||
0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x00, 0x12, 0x3e, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65,
|
||||
0x72, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x47, 0x65,
|
||||
0x74, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x1a, 0x16, 0x2e, 0x70,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f,
|
||||
0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x42, 0x0e, 0x5a, 0x0c, 0x2e, 0x3b, 0x70, 0x72, 0x6f, 0x76,
|
||||
0x69, 0x64, 0x65, 0x72, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_proto_provider_plugin_proto_rawDescOnce sync.Once
|
||||
file_proto_provider_plugin_proto_rawDescData = file_proto_provider_plugin_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_proto_provider_plugin_proto_rawDescGZIP() []byte {
|
||||
file_proto_provider_plugin_proto_rawDescOnce.Do(func() {
|
||||
file_proto_provider_plugin_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_provider_plugin_proto_rawDescData)
|
||||
})
|
||||
return file_proto_provider_plugin_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_proto_provider_plugin_proto_msgTypes = make([]protoimpl.MessageInfo, 9)
|
||||
var file_proto_provider_plugin_proto_goTypes = []interface{}{
|
||||
(*InitReq)(nil), // 0: proto.InitReq
|
||||
(*GetTokenReq)(nil), // 1: proto.GetTokenReq
|
||||
(*Token)(nil), // 2: proto.Token
|
||||
(*ProviderResp)(nil), // 3: proto.ProviderResp
|
||||
(*NewAuthURLReq)(nil), // 4: proto.NewAuthURLReq
|
||||
(*NewAuthURLResp)(nil), // 5: proto.NewAuthURLResp
|
||||
(*GetUserInfoReq)(nil), // 6: proto.GetUserInfoReq
|
||||
(*GetUserInfoResp)(nil), // 7: proto.GetUserInfoResp
|
||||
(*Enpty)(nil), // 8: proto.Enpty
|
||||
}
|
||||
var file_proto_provider_plugin_proto_depIdxs = []int32{
|
||||
2, // 0: proto.GetUserInfoReq.token:type_name -> proto.Token
|
||||
2, // 1: proto.GetUserInfoResp.token_refreshed:type_name -> proto.Token
|
||||
0, // 2: proto.Oauth2Plugin.Init:input_type -> proto.InitReq
|
||||
8, // 3: proto.Oauth2Plugin.Provider:input_type -> proto.Enpty
|
||||
4, // 4: proto.Oauth2Plugin.NewAuthURL:input_type -> proto.NewAuthURLReq
|
||||
1, // 5: proto.Oauth2Plugin.GetToken:input_type -> proto.GetTokenReq
|
||||
6, // 6: proto.Oauth2Plugin.GetUserInfo:input_type -> proto.GetUserInfoReq
|
||||
8, // 7: proto.Oauth2Plugin.Init:output_type -> proto.Enpty
|
||||
3, // 8: proto.Oauth2Plugin.Provider:output_type -> proto.ProviderResp
|
||||
5, // 9: proto.Oauth2Plugin.NewAuthURL:output_type -> proto.NewAuthURLResp
|
||||
2, // 10: proto.Oauth2Plugin.GetToken:output_type -> proto.Token
|
||||
7, // 11: proto.Oauth2Plugin.GetUserInfo:output_type -> proto.GetUserInfoResp
|
||||
7, // [7:12] is the sub-list for method output_type
|
||||
2, // [2:7] is the sub-list for method input_type
|
||||
2, // [2:2] is the sub-list for extension type_name
|
||||
2, // [2:2] is the sub-list for extension extendee
|
||||
0, // [0:2] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_proto_provider_plugin_proto_init() }
|
||||
func file_proto_provider_plugin_proto_init() {
|
||||
if File_proto_provider_plugin_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_proto_provider_plugin_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*InitReq); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proto_provider_plugin_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*GetTokenReq); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proto_provider_plugin_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Token); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proto_provider_plugin_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*ProviderResp); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proto_provider_plugin_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*NewAuthURLReq); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proto_provider_plugin_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*NewAuthURLResp); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proto_provider_plugin_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*GetUserInfoReq); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proto_provider_plugin_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*GetUserInfoResp); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proto_provider_plugin_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Enpty); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_proto_provider_plugin_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 9,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_proto_provider_plugin_proto_goTypes,
|
||||
DependencyIndexes: file_proto_provider_plugin_proto_depIdxs,
|
||||
MessageInfos: file_proto_provider_plugin_proto_msgTypes,
|
||||
}.Build()
|
||||
File_proto_provider_plugin_proto = out.File
|
||||
file_proto_provider_plugin_proto_rawDesc = nil
|
||||
file_proto_provider_plugin_proto_goTypes = nil
|
||||
file_proto_provider_plugin_proto_depIdxs = nil
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
syntax = "proto3";
|
||||
option go_package = ".;providerpb";
|
||||
|
||||
package proto;
|
||||
|
||||
message InitReq {
|
||||
string client_id = 1;
|
||||
string client_secret = 2;
|
||||
string redirect_url = 3;
|
||||
}
|
||||
|
||||
message GetTokenReq { string code = 1; }
|
||||
|
||||
message Token {
|
||||
string access_token = 1;
|
||||
string token_type = 2;
|
||||
string refresh_token = 3;
|
||||
int64 expiry = 4;
|
||||
}
|
||||
|
||||
message ProviderResp { string name = 1; }
|
||||
|
||||
message NewAuthURLReq { string state = 1; }
|
||||
|
||||
message NewAuthURLResp { string url = 1; }
|
||||
|
||||
message GetUserInfoReq { Token token = 1; }
|
||||
|
||||
message GetUserInfoResp {
|
||||
string username = 1;
|
||||
uint64 provider_user_id = 2;
|
||||
Token token_refreshed = 3;
|
||||
}
|
||||
|
||||
message Enpty {}
|
||||
|
||||
service Oauth2Plugin {
|
||||
rpc Init(InitReq) returns (Enpty) {}
|
||||
rpc Provider(Enpty) returns (ProviderResp) {}
|
||||
rpc NewAuthURL(NewAuthURLReq) returns (NewAuthURLResp) {}
|
||||
rpc GetToken(GetTokenReq) returns (Token) {}
|
||||
rpc GetUserInfo(GetUserInfoReq) returns (GetUserInfoResp) {}
|
||||
}
|
@ -0,0 +1,257 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.3.0
|
||||
// - protoc v4.24.4
|
||||
// source: proto/provider/plugin.proto
|
||||
|
||||
package providerpb
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.32.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion7
|
||||
|
||||
const (
|
||||
Oauth2Plugin_Init_FullMethodName = "/proto.Oauth2Plugin/Init"
|
||||
Oauth2Plugin_Provider_FullMethodName = "/proto.Oauth2Plugin/Provider"
|
||||
Oauth2Plugin_NewAuthURL_FullMethodName = "/proto.Oauth2Plugin/NewAuthURL"
|
||||
Oauth2Plugin_GetToken_FullMethodName = "/proto.Oauth2Plugin/GetToken"
|
||||
Oauth2Plugin_GetUserInfo_FullMethodName = "/proto.Oauth2Plugin/GetUserInfo"
|
||||
)
|
||||
|
||||
// Oauth2PluginClient is the client API for Oauth2Plugin service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type Oauth2PluginClient interface {
|
||||
Init(ctx context.Context, in *InitReq, opts ...grpc.CallOption) (*Enpty, error)
|
||||
Provider(ctx context.Context, in *Enpty, opts ...grpc.CallOption) (*ProviderResp, error)
|
||||
NewAuthURL(ctx context.Context, in *NewAuthURLReq, opts ...grpc.CallOption) (*NewAuthURLResp, error)
|
||||
GetToken(ctx context.Context, in *GetTokenReq, opts ...grpc.CallOption) (*Token, error)
|
||||
GetUserInfo(ctx context.Context, in *GetUserInfoReq, opts ...grpc.CallOption) (*GetUserInfoResp, error)
|
||||
}
|
||||
|
||||
type oauth2PluginClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewOauth2PluginClient(cc grpc.ClientConnInterface) Oauth2PluginClient {
|
||||
return &oauth2PluginClient{cc}
|
||||
}
|
||||
|
||||
func (c *oauth2PluginClient) Init(ctx context.Context, in *InitReq, opts ...grpc.CallOption) (*Enpty, error) {
|
||||
out := new(Enpty)
|
||||
err := c.cc.Invoke(ctx, Oauth2Plugin_Init_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *oauth2PluginClient) Provider(ctx context.Context, in *Enpty, opts ...grpc.CallOption) (*ProviderResp, error) {
|
||||
out := new(ProviderResp)
|
||||
err := c.cc.Invoke(ctx, Oauth2Plugin_Provider_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *oauth2PluginClient) NewAuthURL(ctx context.Context, in *NewAuthURLReq, opts ...grpc.CallOption) (*NewAuthURLResp, error) {
|
||||
out := new(NewAuthURLResp)
|
||||
err := c.cc.Invoke(ctx, Oauth2Plugin_NewAuthURL_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *oauth2PluginClient) GetToken(ctx context.Context, in *GetTokenReq, opts ...grpc.CallOption) (*Token, error) {
|
||||
out := new(Token)
|
||||
err := c.cc.Invoke(ctx, Oauth2Plugin_GetToken_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *oauth2PluginClient) GetUserInfo(ctx context.Context, in *GetUserInfoReq, opts ...grpc.CallOption) (*GetUserInfoResp, error) {
|
||||
out := new(GetUserInfoResp)
|
||||
err := c.cc.Invoke(ctx, Oauth2Plugin_GetUserInfo_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// Oauth2PluginServer is the server API for Oauth2Plugin service.
|
||||
// All implementations must embed UnimplementedOauth2PluginServer
|
||||
// for forward compatibility
|
||||
type Oauth2PluginServer interface {
|
||||
Init(context.Context, *InitReq) (*Enpty, error)
|
||||
Provider(context.Context, *Enpty) (*ProviderResp, error)
|
||||
NewAuthURL(context.Context, *NewAuthURLReq) (*NewAuthURLResp, error)
|
||||
GetToken(context.Context, *GetTokenReq) (*Token, error)
|
||||
GetUserInfo(context.Context, *GetUserInfoReq) (*GetUserInfoResp, error)
|
||||
mustEmbedUnimplementedOauth2PluginServer()
|
||||
}
|
||||
|
||||
// UnimplementedOauth2PluginServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedOauth2PluginServer struct {
|
||||
}
|
||||
|
||||
func (UnimplementedOauth2PluginServer) Init(context.Context, *InitReq) (*Enpty, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Init not implemented")
|
||||
}
|
||||
func (UnimplementedOauth2PluginServer) Provider(context.Context, *Enpty) (*ProviderResp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Provider not implemented")
|
||||
}
|
||||
func (UnimplementedOauth2PluginServer) NewAuthURL(context.Context, *NewAuthURLReq) (*NewAuthURLResp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method NewAuthURL not implemented")
|
||||
}
|
||||
func (UnimplementedOauth2PluginServer) GetToken(context.Context, *GetTokenReq) (*Token, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetToken not implemented")
|
||||
}
|
||||
func (UnimplementedOauth2PluginServer) GetUserInfo(context.Context, *GetUserInfoReq) (*GetUserInfoResp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetUserInfo not implemented")
|
||||
}
|
||||
func (UnimplementedOauth2PluginServer) mustEmbedUnimplementedOauth2PluginServer() {}
|
||||
|
||||
// UnsafeOauth2PluginServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to Oauth2PluginServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeOauth2PluginServer interface {
|
||||
mustEmbedUnimplementedOauth2PluginServer()
|
||||
}
|
||||
|
||||
func RegisterOauth2PluginServer(s grpc.ServiceRegistrar, srv Oauth2PluginServer) {
|
||||
s.RegisterService(&Oauth2Plugin_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _Oauth2Plugin_Init_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(InitReq)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(Oauth2PluginServer).Init(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Oauth2Plugin_Init_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(Oauth2PluginServer).Init(ctx, req.(*InitReq))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Oauth2Plugin_Provider_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(Enpty)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(Oauth2PluginServer).Provider(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Oauth2Plugin_Provider_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(Oauth2PluginServer).Provider(ctx, req.(*Enpty))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Oauth2Plugin_NewAuthURL_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(NewAuthURLReq)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(Oauth2PluginServer).NewAuthURL(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Oauth2Plugin_NewAuthURL_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(Oauth2PluginServer).NewAuthURL(ctx, req.(*NewAuthURLReq))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Oauth2Plugin_GetToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetTokenReq)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(Oauth2PluginServer).GetToken(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Oauth2Plugin_GetToken_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(Oauth2PluginServer).GetToken(ctx, req.(*GetTokenReq))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Oauth2Plugin_GetUserInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetUserInfoReq)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(Oauth2PluginServer).GetUserInfo(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Oauth2Plugin_GetUserInfo_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(Oauth2PluginServer).GetUserInfo(ctx, req.(*GetUserInfoReq))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// Oauth2Plugin_ServiceDesc is the grpc.ServiceDesc for Oauth2Plugin service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var Oauth2Plugin_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "proto.Oauth2Plugin",
|
||||
HandlerType: (*Oauth2PluginServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "Init",
|
||||
Handler: _Oauth2Plugin_Init_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "Provider",
|
||||
Handler: _Oauth2Plugin_Provider_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "NewAuthURL",
|
||||
Handler: _Oauth2Plugin_NewAuthURL_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetToken",
|
||||
Handler: _Oauth2Plugin_GetToken_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetUserInfo",
|
||||
Handler: _Oauth2Plugin_GetUserInfo_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "proto/provider/plugin.proto",
|
||||
}
|
Loading…
Reference in New Issue