Feat: oauth2 provider plugins

pull/21/head
zijiren233 2 years ago
parent 6a50fa596e
commit 83843d3c3c

@ -14,6 +14,8 @@ require (
github.com/google/go-github/v56 v56.0.0
github.com/google/uuid v1.3.1
github.com/gorilla/websocket v1.5.0
github.com/hashicorp/go-hclog v0.14.1
github.com/hashicorp/go-plugin v1.5.2
github.com/json-iterator/go v1.1.12
github.com/mitchellh/go-homedir v1.1.0
github.com/natefinch/lumberjack v2.0.0+incompatible
@ -30,6 +32,7 @@ require (
golang.org/x/crypto v0.14.0
golang.org/x/exp v0.0.0-20231006140011-7918f672742d
golang.org/x/oauth2 v0.13.0
google.golang.org/grpc v1.56.1
google.golang.org/protobuf v1.31.0
gopkg.in/yaml.v3 v3.0.1
gorm.io/driver/mysql v1.5.2
@ -45,6 +48,7 @@ require (
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
github.com/chenzhuoyu/iasm v0.9.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/fatih/color v1.7.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/glebarez/go-sqlite v1.21.2 // indirect
@ -57,6 +61,7 @@ require (
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/pprof v0.0.0-20230926050212-f7f687d19a98 // indirect
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
@ -66,9 +71,12 @@ require (
github.com/klauspost/cpuid/v2 v2.2.5 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/maruel/natural v1.1.0 // indirect
github.com/mattn/go-colorable v0.1.4 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/oklog/run v1.0.0 // indirect
github.com/onsi/ginkgo/v2 v2.13.0 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
@ -86,6 +94,7 @@ require (
golang.org/x/text v0.13.0 // indirect
golang.org/x/tools v0.14.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
modernc.org/libc v1.24.1 // indirect
modernc.org/mathutil v1.6.0 // indirect

@ -6,6 +6,7 @@ github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/bluele/gcache v0.0.2 h1:WcbfdXICg7G/DGBh1PFfcirkWOQV+v077yF1pSy3DGw=
github.com/bluele/gcache v0.0.2/go.mod h1:m15KV+ECjptwSPxKhOhQoAFQVtUFjTVkc3H8o0t/fp0=
github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA=
github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
github.com/bytedance/sonic v1.10.0-rc/go.mod h1:ElCzW+ufi8qKqNW0FY314xriJhyJhuoJ3gFZdAHF7NM=
github.com/bytedance/sonic v1.10.2 h1:GQebETVBxYB7JGWJtLBi07OVzWwt+8dWA00gEVW2ZFE=
@ -27,6 +28,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
github.com/gin-contrib/cors v1.4.0 h1:oJ6gwtUl3lqV0WEIwM/LxPF1QZ5qe2lGWdY2+bz7y0g=
@ -82,6 +85,12 @@ github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4=
github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/hashicorp/go-hclog v0.14.1 h1:nQcJDQwIAGnmoUWp8ubocEX40cCml/17YkF6csQLReU=
github.com/hashicorp/go-hclog v0.14.1/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ=
github.com/hashicorp/go-plugin v1.5.2 h1:aWv8eimFqWlsEiMrYZdPYl+FdHaBJSN4AWwGWfT1G2Y=
github.com/hashicorp/go-plugin v1.5.2/go.mod h1:w1sAEES3g3PuV/RzUrgow20W2uErMly84hhD3um1WL4=
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb h1:b5rjCoWHc7eqmAS4/qyk21ZsHyb6Mxv/jykxvNTkU4M=
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
@ -90,6 +99,7 @@ github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
github.com/jackc/pgx/v5 v5.4.3 h1:cxFyXhxlvAifxnkKKdlxv8XqUf59tDlYjnV5YYfsJJY=
github.com/jackc/pgx/v5 v5.4.3/go.mod h1:Ig06C2Vu0t5qXC60W8sqIthScaEnFvojjj9dSljmHRA=
github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgfCL6c=
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
@ -113,11 +123,17 @@ github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q=
github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4=
github.com/maruel/natural v1.1.0 h1:2z1NgP/Vae+gYrtC0VuvrTJ6U35OuyUqDdfluLqMWuQ=
github.com/maruel/natural v1.1.0/go.mod h1:eFVhYCcUOfZFxXoDZam8Ktya72wa79fNC3lc/leA0DQ=
github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA=
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77 h1:7GoSOOW2jpsfkntVKaS2rAr1TJqfcxotyaUcuxoZSzg=
github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
@ -125,6 +141,8 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/natefinch/lumberjack v2.0.0+incompatible h1:4QJd3OLAMgj7ph+yZTuX13Ld4UpgHp07nNdFX7mqFfM=
github.com/natefinch/lumberjack v2.0.0+incompatible/go.mod h1:Wi9p2TTF5DG5oU+6YfsmYQpsTIOm0B1VNzQg9Mw6nPk=
github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw=
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
github.com/onsi/ginkgo/v2 v2.13.0 h1:0jY9lJquiL8fcf3M4LAXN5aMlS/b2BV86HFFPCPMgE4=
github.com/onsi/ginkgo/v2 v2.13.0/go.mod h1:TE309ZR8s5FsKKpuB1YAQYBzCaAfUgatB/xlT/ETL/o=
github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI=
@ -159,6 +177,7 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
@ -181,8 +200,6 @@ github.com/zijiren233/gencontainer v0.0.0-20230930135658-e410015e13cc h1:qEYdClJ
github.com/zijiren233/gencontainer v0.0.0-20230930135658-e410015e13cc/go.mod h1:V5oL7PrZxgisuLCblFWd89Jg99O8vM1n58llcxZ2hDY=
github.com/zijiren233/go-colorable v0.0.0-20230930131441-997304c961cb h1:0DyOxf/TbbGodHhOVHNoPk+7v/YBJACs22gKpKlatWw=
github.com/zijiren233/go-colorable v0.0.0-20230930131441-997304c961cb/go.mod h1:6TCzjDiQ8+5gWZiwsC3pnA5M0vUy2jV2Y7ciHJh729g=
github.com/zijiren233/livelib v0.2.1 h1:7a+R/yiq3WJXM+1kwez9w//uWpRDrQN4hT+TC1hqkpI=
github.com/zijiren233/livelib v0.2.1/go.mod h1:2wrAAqNIdMZjQrdbO7ERQfqK4VS5fzgUj2xXwrJ8/uo=
github.com/zijiren233/livelib v0.2.2-0.20231021080243-c5097432686c h1:sQtkWQi+QWdmx4Jx2MA/Ib9pYPmnVw5Qd/xOB8K5zs0=
github.com/zijiren233/livelib v0.2.2-0.20231021080243-c5097432686c/go.mod h1:2wrAAqNIdMZjQrdbO7ERQfqK4VS5fzgUj2xXwrJ8/uo=
github.com/zijiren233/stream v0.5.1 h1:9SUwM/fpET6frtBRT5WZBHnan0Hyzkezk/P8N78cgZQ=
@ -221,7 +238,9 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
@ -261,6 +280,10 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM=
google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds=
google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc h1:XSJ8Vk1SWuNr8S18z1NZSziL0CPIXLCCMDOEFtHBOFc=
google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc/go.mod h1:66JfowdXAEgad5O9NnYcsNPLCPZJD++2L9X0PCMODrA=
google.golang.org/grpc v1.56.1 h1:z0dNfjIl0VpaZ9iSVjA6daGatAYwPGstTjt5vkRMFkQ=
google.golang.org/grpc v1.56.1/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=

@ -2,14 +2,36 @@ package bootstrap
import (
"context"
"os"
"path/filepath"
log "github.com/sirupsen/logrus"
"github.com/synctv-org/synctv/internal/conf"
"github.com/synctv-org/synctv/internal/provider"
"github.com/synctv-org/synctv/utils"
)
func InitProvider(ctx context.Context) error {
for op, v := range conf.Conf.OAuth2 {
err := provider.InitProvider(op, v.ClientID, v.ClientSecret, provider.WithRedirectURL(v.RedirectURL))
for _, op := range conf.Conf.OAuth2.Plugins {
utils.OptFilePath(&op.PluginFile)
log.Infof("load oauth2 plugin: %s", op.PluginFile)
err := os.MkdirAll(filepath.Dir(op.PluginFile), 0755)
if err != nil {
log.Errorf("create plugin dir: %s failed: %s", filepath.Dir(op.PluginFile), err)
return err
}
err = provider.InitProviderPlugins(op.PluginFile, op.Arges...)
if err != nil {
log.Errorf("load oauth2 plugin: %s failed: %s", op.PluginFile, err)
return err
}
}
for op, v := range conf.Conf.OAuth2.Providers {
err := provider.InitProvider(op, provider.Oauth2Option{
ClientID: v.ClientID,
ClientSecret: v.ClientSecret,
RedirectURL: v.RedirectURL,
})
if err != nil {
return err
}

@ -1,10 +1,16 @@
package conf
import (
"github.com/synctv-org/synctv/internal/provider"
)
import "github.com/synctv-org/synctv/internal/provider"
type OAuth2Config map[provider.OAuth2Provider]OAuth2ProviderConfig
type OAuth2Config struct {
Providers map[provider.OAuth2Provider]OAuth2ProviderConfig `yaml:"providers"`
Plugins []Oauth2Plugin `yaml:"plugins"`
}
type Oauth2Plugin struct {
PluginFile string `yaml:"plugin_file"`
Arges []string `yaml:"arges"`
}
type OAuth2ProviderConfig struct {
ClientID string `yaml:"client_id"`
@ -14,10 +20,12 @@ type OAuth2ProviderConfig struct {
func DefaultOAuth2Config() OAuth2Config {
return OAuth2Config{
(&provider.GithubProvider{}).Provider(): {
ClientID: "",
ClientSecret: "",
RedirectURL: "",
Providers: map[provider.OAuth2Provider]OAuth2ProviderConfig{
(&provider.GithubProvider{}).Provider(): {
ClientID: "",
ClientSecret: "",
RedirectURL: "",
},
},
}
}

@ -5,7 +5,7 @@ import (
"time"
"github.com/synctv-org/synctv/internal/model"
pb "github.com/synctv-org/synctv/proto"
pb "github.com/synctv-org/synctv/proto/message"
)
type current struct {

@ -9,7 +9,7 @@ import (
"github.com/gorilla/websocket"
log "github.com/sirupsen/logrus"
pb "github.com/synctv-org/synctv/proto"
pb "github.com/synctv-org/synctv/proto/message"
"github.com/synctv-org/synctv/utils"
"github.com/zijiren233/gencontainer/rwmap"
)

@ -6,7 +6,7 @@ import (
json "github.com/json-iterator/go"
"github.com/gorilla/websocket"
pb "github.com/synctv-org/synctv/proto"
pb "github.com/synctv-org/synctv/proto/message"
"google.golang.org/protobuf/proto"
)

@ -14,38 +14,31 @@ type BaiduNetDiskProvider struct {
config oauth2.Config
}
func (p *BaiduNetDiskProvider) Init(ClientID, ClientSecret string, options ...Oauth2Option) {
p.config.ClientID = ClientID
p.config.ClientSecret = ClientSecret
func (p *BaiduNetDiskProvider) Init(c Oauth2Option) {
p.config.Scopes = []string{"basic", "netdisk"}
p.config.Endpoint = oauth2.Endpoint{
AuthURL: "https://openapi.baidu.com/oauth/2.0/authorize",
TokenURL: "https://openapi.baidu.com/oauth/2.0/token",
}
for _, o := range options {
o(&p.config)
}
p.config.ClientID = c.ClientID
p.config.ClientSecret = c.ClientSecret
p.config.RedirectURL = c.RedirectURL
}
func (p *BaiduNetDiskProvider) Provider() OAuth2Provider {
return "baidu-netdisk"
}
func (p *BaiduNetDiskProvider) NewConfig(options ...Oauth2Option) *oauth2.Config {
c := p.config
for _, o := range options {
o(&c)
}
return &c
func (p *BaiduNetDiskProvider) NewAuthURL(state string) string {
return p.config.AuthCodeURL(state, oauth2.AccessTypeOnline)
}
func (p *BaiduNetDiskProvider) GetUserInfo(ctx context.Context, config *oauth2.Config, code string) (*UserInfo, error) {
oauth2Token, err := config.Exchange(ctx, code)
if err != nil {
return nil, err
}
client := config.Client(ctx, oauth2Token)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, fmt.Sprintf("https://pan.baidu.com/rest/2.0/xpan/nas?method=uinfo&access_token=%s", oauth2Token.AccessToken), nil)
func (p *BaiduNetDiskProvider) GetToken(ctx context.Context, code string) (*oauth2.Token, error) {
return p.config.Exchange(ctx, code)
}
func (p *BaiduNetDiskProvider) GetUserInfo(ctx context.Context, tk *oauth2.Token) (*UserInfo, error) {
client := p.config.Client(ctx, tk)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, fmt.Sprintf("https://pan.baidu.com/rest/2.0/xpan/nas?method=uinfo&access_token=%s", tk.AccessToken), nil)
if err != nil {
return nil, err
}

@ -16,38 +16,32 @@ type BaiduProvider struct {
config oauth2.Config
}
func (p *BaiduProvider) Init(ClientID, ClientSecret string, options ...Oauth2Option) {
p.config.ClientID = ClientID
p.config.ClientSecret = ClientSecret
func (p *BaiduProvider) Init(c Oauth2Option) {
p.config.Scopes = []string{"basic"}
p.config.Endpoint = oauth2.Endpoint{
AuthURL: "https://openapi.baidu.com/oauth/2.0/authorize",
TokenURL: "https://openapi.baidu.com/oauth/2.0/token",
}
for _, o := range options {
o(&p.config)
}
p.config.ClientID = c.ClientID
p.config.ClientSecret = c.ClientSecret
p.config.RedirectURL = c.RedirectURL
}
func (p *BaiduProvider) Provider() OAuth2Provider {
return "baidu"
}
func (p *BaiduProvider) NewConfig(options ...Oauth2Option) *oauth2.Config {
c := p.config
for _, o := range options {
o(&c)
}
return &c
func (p *BaiduProvider) NewAuthURL(state string) string {
return p.config.AuthCodeURL(state, oauth2.AccessTypeOnline)
}
func (p *BaiduProvider) GetUserInfo(ctx context.Context, config *oauth2.Config, code string) (*UserInfo, error) {
oauth2Token, err := config.Exchange(ctx, code)
if err != nil {
return nil, err
}
client := config.Client(ctx, oauth2Token)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, fmt.Sprintf("https://openapi.baidu.com/rest/2.0/passport/users/getLoggedInUser?access_token=%s", oauth2Token.AccessToken), nil)
func (p *BaiduProvider) GetToken(ctx context.Context, code string) (*oauth2.Token, error) {
return p.config.Exchange(ctx, code)
}
func (p *BaiduProvider) GetUserInfo(ctx context.Context, tk *oauth2.Token) (*UserInfo, error) {
client := p.config.Client(ctx, tk)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, fmt.Sprintf("https://openapi.baidu.com/rest/2.0/passport/users/getLoggedInUser?access_token=%s", tk.AccessToken), nil)
if err != nil {
return nil, err
}

@ -12,40 +12,31 @@ type GiteeProvider struct {
config oauth2.Config
}
func (p *GiteeProvider) Init(ClientID, ClientSecret string, options ...Oauth2Option) {
p.config.ClientID = ClientID
p.config.ClientSecret = ClientSecret
func (p *GiteeProvider) Init(c Oauth2Option) {
p.config.Scopes = []string{"user_info"}
p.config.Endpoint = oauth2.Endpoint{
AuthURL: "https://gitee.com/oauth/authorize",
TokenURL: "https://gitee.com/oauth/token",
}
for _, o := range options {
o(&p.config)
}
p.config.ClientID = c.ClientID
p.config.ClientSecret = c.ClientSecret
p.config.RedirectURL = c.RedirectURL
}
func (p *GiteeProvider) Provider() OAuth2Provider {
return "gitee"
}
func (p *GiteeProvider) NewConfig(options ...Oauth2Option) *oauth2.Config {
c := p.config
for _, o := range options {
o(&c)
}
if c.RedirectURL == "" {
panic("gitee oauth2 redirect url is empty")
}
return &c
func (p *GiteeProvider) NewAuthURL(state string) string {
return p.config.AuthCodeURL(state, oauth2.AccessTypeOnline)
}
func (p *GiteeProvider) GetUserInfo(ctx context.Context, config *oauth2.Config, code string) (*UserInfo, error) {
oauth2Token, err := config.Exchange(ctx, code)
if err != nil {
return nil, err
}
client := config.Client(ctx, oauth2Token)
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) (*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

@ -13,34 +13,28 @@ type GithubProvider struct {
config oauth2.Config
}
func (p *GithubProvider) Init(ClientID, ClientSecret string, options ...Oauth2Option) {
p.config.ClientID = ClientID
p.config.ClientSecret = ClientSecret
func (p *GithubProvider) Init(c Oauth2Option) {
p.config.Scopes = []string{"user"}
p.config.Endpoint = github.Endpoint
for _, o := range options {
o(&p.config)
}
p.config.ClientID = c.ClientID
p.config.ClientSecret = c.ClientSecret
p.config.RedirectURL = c.RedirectURL
}
func (p *GithubProvider) Provider() OAuth2Provider {
return "github"
}
func (p *GithubProvider) NewConfig(options ...Oauth2Option) *oauth2.Config {
c := p.config
for _, o := range options {
o(&c)
}
return &c
func (p *GithubProvider) NewAuthURL(state string) string {
return p.config.AuthCodeURL(state, oauth2.AccessTypeOnline)
}
func (p *GithubProvider) GetUserInfo(ctx context.Context, config *oauth2.Config, code string) (*UserInfo, error) {
oauth2Token, err := config.Exchange(ctx, code)
if err != nil {
return nil, err
}
client := config.Client(ctx, oauth2Token)
func (p *GithubProvider) GetToken(ctx context.Context, code string) (*oauth2.Token, error) {
return p.config.Exchange(ctx, code)
}
func (p *GithubProvider) GetUserInfo(ctx context.Context, tk *oauth2.Token) (*UserInfo, error) {
client := p.config.Client(ctx, tk)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, "https://api.github.com/user", nil)
if err != nil {
return nil, err

@ -12,34 +12,28 @@ type GitlabProvider struct {
config oauth2.Config
}
func (g *GitlabProvider) Init(ClientID, ClientSecret string, options ...Oauth2Option) {
g.config.ClientID = ClientID
g.config.ClientSecret = ClientSecret
func (g *GitlabProvider) Init(c Oauth2Option) {
g.config.Scopes = []string{"read_user"}
g.config.Endpoint = gitlab.Endpoint
for _, o := range options {
o(&g.config)
}
g.config.ClientID = c.ClientID
g.config.ClientSecret = c.ClientSecret
g.config.RedirectURL = c.RedirectURL
}
func (g *GitlabProvider) Provider() OAuth2Provider {
return "gitlab"
}
func (g *GitlabProvider) NewConfig(options ...Oauth2Option) *oauth2.Config {
c := g.config
for _, o := range options {
o(&c)
}
return &c
func (g *GitlabProvider) NewAuthURL(state string) string {
return g.config.AuthCodeURL(state, oauth2.AccessTypeOnline)
}
func (g *GitlabProvider) GetUserInfo(ctx context.Context, config *oauth2.Config, code string) (*UserInfo, error) {
oauth2Token, err := config.Exchange(ctx, code)
if err != nil {
return nil, err
}
client := config.Client(ctx, oauth2Token)
func (g *GitlabProvider) GetToken(ctx context.Context, code string) (*oauth2.Token, error) {
return g.config.Exchange(ctx, code)
}
func (g *GitlabProvider) GetUserInfo(ctx context.Context, tk *oauth2.Token) (*UserInfo, error) {
client := g.config.Client(ctx, tk)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, "https://gitlab.com/api/v4/user", nil)
if err != nil {
return nil, err

@ -13,37 +13,28 @@ type GoogleProvider struct {
config oauth2.Config
}
func (g *GoogleProvider) Init(ClientID, ClientSecret string, options ...Oauth2Option) {
g.config.ClientID = ClientID
g.config.ClientSecret = ClientSecret
func (g *GoogleProvider) Init(c Oauth2Option) {
g.config.Scopes = []string{"profile"}
g.config.Endpoint = google.Endpoint
for _, o := range options {
o(&g.config)
}
g.config.ClientID = c.ClientID
g.config.ClientSecret = c.ClientSecret
g.config.RedirectURL = c.RedirectURL
}
func (g *GoogleProvider) Provider() OAuth2Provider {
return "google"
}
func (g *GoogleProvider) NewConfig(options ...Oauth2Option) *oauth2.Config {
c := g.config
for _, o := range options {
o(&c)
}
if c.RedirectURL == "" {
panic("google oauth2 redirect url is empty")
}
return &c
func (g *GoogleProvider) NewAuthURL(state string) string {
return g.config.AuthCodeURL(state, oauth2.AccessTypeOnline)
}
func (g *GoogleProvider) GetUserInfo(ctx context.Context, config *oauth2.Config, code string) (*UserInfo, error) {
oauth2Token, err := config.Exchange(ctx, code)
if err != nil {
return nil, err
}
client := config.Client(ctx, oauth2Token)
func (g *GoogleProvider) GetToken(ctx context.Context, code string) (*oauth2.Token, error) {
return g.config.Exchange(ctx, code)
}
func (g *GoogleProvider) GetUserInfo(ctx context.Context, tk *oauth2.Token) (*UserInfo, error) {
client := g.config.Client(ctx, tk)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, "https://www.googleapis.com/oauth2/v2/userinfo", nil)
if err != nil {
return nil, err

@ -15,34 +15,28 @@ type MicrosoftProvider struct {
config oauth2.Config
}
func (p *MicrosoftProvider) Init(ClientID, ClientSecret string, options ...Oauth2Option) {
p.config.ClientID = ClientID
p.config.ClientSecret = ClientSecret
func (p *MicrosoftProvider) Init(c Oauth2Option) {
p.config.Scopes = []string{"user.read"}
p.config.Endpoint = microsoft.LiveConnectEndpoint
for _, o := range options {
o(&p.config)
}
p.config.ClientID = c.ClientID
p.config.ClientSecret = c.ClientSecret
p.config.RedirectURL = c.RedirectURL
}
func (p *MicrosoftProvider) Provider() OAuth2Provider {
return "microsoft"
}
func (p *MicrosoftProvider) NewConfig(options ...Oauth2Option) *oauth2.Config {
c := p.config
for _, o := range options {
o(&c)
}
return &c
func (p *MicrosoftProvider) NewAuthURL(state string) string {
return p.config.AuthCodeURL(state, oauth2.AccessTypeOnline)
}
func (p *MicrosoftProvider) GetUserInfo(ctx context.Context, config *oauth2.Config, code string) (*UserInfo, error) {
oauth2Token, err := config.Exchange(ctx, code)
if err != nil {
return nil, err
}
client := config.Client(ctx, oauth2Token)
func (p *MicrosoftProvider) GetToken(ctx context.Context, code string) (*oauth2.Token, error) {
return p.config.Exchange(ctx, code)
}
func (p *MicrosoftProvider) GetUserInfo(ctx context.Context, tk *oauth2.Token) (*UserInfo, error) {
client := p.config.Client(ctx, tk)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, "https://graph.microsoft.com/v1.0/me", nil)
if err != nil {
return nil, err

@ -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,
})
}

@ -14,32 +14,37 @@ var (
allowedProviders = make(map[OAuth2Provider]ProviderInterface)
)
type TokenRefreshed struct {
Refreshed bool
Token *oauth2.Token
}
type UserInfo struct {
Username string
ProviderUserID uint
TokenRefreshed *TokenRefreshed
}
type Oauth2Option func(*oauth2.Config)
func WithRedirectURL(url string) Oauth2Option {
return func(c *oauth2.Config) {
c.RedirectURL = url
}
type Oauth2Option struct {
ClientID string
ClientSecret string
RedirectURL string
}
type ProviderInterface interface {
Init(ClientID, ClientSecret string, options ...Oauth2Option)
Init(Oauth2Option)
Provider() OAuth2Provider
NewConfig(options ...Oauth2Option) *oauth2.Config
GetUserInfo(ctx context.Context, config *oauth2.Config, code string) (*UserInfo, error)
NewAuthURL(string) string
GetToken(context.Context, string) (*oauth2.Token, error)
GetUserInfo(context.Context, *oauth2.Token) (*UserInfo, error)
}
func InitProvider(p OAuth2Provider, ClientID, ClientSecret string, options ...Oauth2Option) error {
func InitProvider(p OAuth2Provider, c Oauth2Option) error {
pi, ok := allowedProviders[p]
if !ok {
return FormatErrNotImplemented(p)
}
pi.Init(ClientID, ClientSecret, options...)
pi.Init(c)
if enabledProviders == nil {
enabledProviders = make(map[OAuth2Provider]ProviderInterface)
}

@ -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

@ -2,7 +2,7 @@
// versions:
// protoc-gen-go v1.31.0
// protoc v4.24.4
// source: proto/message.proto
// source: proto/message/message.proto
package pb
@ -83,11 +83,11 @@ func (x ElementMessageType) String() string {
}
func (ElementMessageType) Descriptor() protoreflect.EnumDescriptor {
return file_proto_message_proto_enumTypes[0].Descriptor()
return file_proto_message_message_proto_enumTypes[0].Descriptor()
}
func (ElementMessageType) Type() protoreflect.EnumType {
return &file_proto_message_proto_enumTypes[0]
return &file_proto_message_message_proto_enumTypes[0]
}
func (x ElementMessageType) Number() protoreflect.EnumNumber {
@ -96,7 +96,7 @@ func (x ElementMessageType) Number() protoreflect.EnumNumber {
// Deprecated: Use ElementMessageType.Descriptor instead.
func (ElementMessageType) EnumDescriptor() ([]byte, []int) {
return file_proto_message_proto_rawDescGZIP(), []int{0}
return file_proto_message_message_proto_rawDescGZIP(), []int{0}
}
type BaseMovieInfo struct {
@ -116,7 +116,7 @@ type BaseMovieInfo struct {
func (x *BaseMovieInfo) Reset() {
*x = BaseMovieInfo{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_message_proto_msgTypes[0]
mi := &file_proto_message_message_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -129,7 +129,7 @@ func (x *BaseMovieInfo) String() string {
func (*BaseMovieInfo) ProtoMessage() {}
func (x *BaseMovieInfo) ProtoReflect() protoreflect.Message {
mi := &file_proto_message_proto_msgTypes[0]
mi := &file_proto_message_message_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -142,7 +142,7 @@ func (x *BaseMovieInfo) ProtoReflect() protoreflect.Message {
// Deprecated: Use BaseMovieInfo.ProtoReflect.Descriptor instead.
func (*BaseMovieInfo) Descriptor() ([]byte, []int) {
return file_proto_message_proto_rawDescGZIP(), []int{0}
return file_proto_message_message_proto_rawDescGZIP(), []int{0}
}
func (x *BaseMovieInfo) GetUrl() string {
@ -209,7 +209,7 @@ type MovieInfo struct {
func (x *MovieInfo) Reset() {
*x = MovieInfo{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_message_proto_msgTypes[1]
mi := &file_proto_message_message_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -222,7 +222,7 @@ func (x *MovieInfo) String() string {
func (*MovieInfo) ProtoMessage() {}
func (x *MovieInfo) ProtoReflect() protoreflect.Message {
mi := &file_proto_message_proto_msgTypes[1]
mi := &file_proto_message_message_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -235,7 +235,7 @@ func (x *MovieInfo) ProtoReflect() protoreflect.Message {
// Deprecated: Use MovieInfo.ProtoReflect.Descriptor instead.
func (*MovieInfo) Descriptor() ([]byte, []int) {
return file_proto_message_proto_rawDescGZIP(), []int{1}
return file_proto_message_message_proto_rawDescGZIP(), []int{1}
}
func (x *MovieInfo) GetId() uint64 {
@ -286,7 +286,7 @@ type Status struct {
func (x *Status) Reset() {
*x = Status{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_message_proto_msgTypes[2]
mi := &file_proto_message_message_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -299,7 +299,7 @@ func (x *Status) String() string {
func (*Status) ProtoMessage() {}
func (x *Status) ProtoReflect() protoreflect.Message {
mi := &file_proto_message_proto_msgTypes[2]
mi := &file_proto_message_message_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -312,7 +312,7 @@ func (x *Status) ProtoReflect() protoreflect.Message {
// Deprecated: Use Status.ProtoReflect.Descriptor instead.
func (*Status) Descriptor() ([]byte, []int) {
return file_proto_message_proto_rawDescGZIP(), []int{2}
return file_proto_message_message_proto_rawDescGZIP(), []int{2}
}
func (x *Status) GetSeek() float64 {
@ -348,7 +348,7 @@ type Current struct {
func (x *Current) Reset() {
*x = Current{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_message_proto_msgTypes[3]
mi := &file_proto_message_message_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -361,7 +361,7 @@ func (x *Current) String() string {
func (*Current) ProtoMessage() {}
func (x *Current) ProtoReflect() protoreflect.Message {
mi := &file_proto_message_proto_msgTypes[3]
mi := &file_proto_message_message_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -374,7 +374,7 @@ func (x *Current) ProtoReflect() protoreflect.Message {
// Deprecated: Use Current.ProtoReflect.Descriptor instead.
func (*Current) Descriptor() ([]byte, []int) {
return file_proto_message_proto_rawDescGZIP(), []int{3}
return file_proto_message_message_proto_rawDescGZIP(), []int{3}
}
func (x *Current) GetMovie() *MovieInfo {
@ -401,7 +401,7 @@ type ElementMessage struct {
Message string `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"`
Rate float64 `protobuf:"fixed64,4,opt,name=rate,proto3" json:"rate,omitempty"`
Seek float64 `protobuf:"fixed64,5,opt,name=seek,proto3" json:"seek,omitempty"`
Current *Current `protobuf:"bytes,6,opt,name=current,proto3" json:"current,omitempty"`
Current *Current `protobuf:"bytes,6,opt,name=current,proto3,oneof" json:"current,omitempty"`
PeopleNum int64 `protobuf:"varint,7,opt,name=peopleNum,proto3" json:"peopleNum,omitempty"`
Time int64 `protobuf:"varint,8,opt,name=time,proto3" json:"time,omitempty"`
}
@ -409,7 +409,7 @@ type ElementMessage struct {
func (x *ElementMessage) Reset() {
*x = ElementMessage{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_message_proto_msgTypes[4]
mi := &file_proto_message_message_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -422,7 +422,7 @@ func (x *ElementMessage) String() string {
func (*ElementMessage) ProtoMessage() {}
func (x *ElementMessage) ProtoReflect() protoreflect.Message {
mi := &file_proto_message_proto_msgTypes[4]
mi := &file_proto_message_message_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -435,7 +435,7 @@ func (x *ElementMessage) ProtoReflect() protoreflect.Message {
// Deprecated: Use ElementMessage.ProtoReflect.Descriptor instead.
func (*ElementMessage) Descriptor() ([]byte, []int) {
return file_proto_message_proto_rawDescGZIP(), []int{4}
return file_proto_message_message_proto_rawDescGZIP(), []int{4}
}
func (x *ElementMessage) GetType() ElementMessageType {
@ -494,96 +494,97 @@ func (x *ElementMessage) GetTime() int64 {
return 0
}
var File_proto_message_proto protoreflect.FileDescriptor
var file_proto_message_proto_rawDesc = []byte{
0x0a, 0x13, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x8c, 0x02, 0x0a,
0x0d, 0x42, 0x61, 0x73, 0x65, 0x4d, 0x6f, 0x76, 0x69, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x10,
0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c,
0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04,
0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6c, 0x69, 0x76, 0x65, 0x18, 0x03, 0x20, 0x01,
0x28, 0x08, 0x52, 0x04, 0x6c, 0x69, 0x76, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x72, 0x6f, 0x78,
0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x12, 0x1e,
0x0a, 0x0a, 0x72, 0x74, 0x6d, 0x70, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x05, 0x20, 0x01,
0x28, 0x08, 0x52, 0x0a, 0x72, 0x74, 0x6d, 0x70, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x12,
0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79,
0x70, 0x65, 0x12, 0x3b, 0x0a, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x18, 0x07, 0x20,
0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x42, 0x61, 0x73, 0x65,
0x4d, 0x6f, 0x76, 0x69, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72,
0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x1a,
0x3a, 0x0a, 0x0c, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12,
0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65,
0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x97, 0x01, 0x0a, 0x09,
0x4d, 0x6f, 0x76, 0x69, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18,
0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x02, 0x69, 0x64, 0x12, 0x28, 0x0a, 0x04, 0x62, 0x61, 0x73,
0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e,
0x42, 0x61, 0x73, 0x65, 0x4d, 0x6f, 0x76, 0x69, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x04, 0x62,
0x61, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x75, 0x6c, 0x6c, 0x4b, 0x65, 0x79, 0x18, 0x03,
0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x75, 0x6c, 0x6c, 0x4b, 0x65, 0x79, 0x12, 0x1c, 0x0a,
0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03,
0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x63,
0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x72,
0x65, 0x61, 0x74, 0x6f, 0x72, 0x22, 0x4a, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12,
0x12, 0x0a, 0x04, 0x73, 0x65, 0x65, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x01, 0x52, 0x04, 0x73,
0x65, 0x65, 0x6b, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
0x01, 0x52, 0x04, 0x72, 0x61, 0x74, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x6c, 0x61, 0x79, 0x69,
0x6e, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x70, 0x6c, 0x61, 0x79, 0x69, 0x6e,
0x67, 0x22, 0x58, 0x0a, 0x07, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x12, 0x26, 0x0a, 0x05,
0x6d, 0x6f, 0x76, 0x69, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x2e, 0x4d, 0x6f, 0x76, 0x69, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x6d,
0x6f, 0x76, 0x69, 0x65, 0x12, 0x25, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02,
0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x53, 0x74, 0x61,
0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0xf5, 0x01, 0x0a, 0x0e,
0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x2d,
0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x19, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x4d, 0x65, 0x73, 0x73,
0x61, 0x67, 0x65, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a,
0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73,
0x65, 0x6e, 0x64, 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12,
0x12, 0x0a, 0x04, 0x72, 0x61, 0x74, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x01, 0x52, 0x04, 0x72,
0x61, 0x74, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x65, 0x65, 0x6b, 0x18, 0x05, 0x20, 0x01, 0x28,
0x01, 0x52, 0x04, 0x73, 0x65, 0x65, 0x6b, 0x12, 0x28, 0x0a, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65,
0x6e, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x2e, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x52, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e,
0x74, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x65, 0x6f, 0x70, 0x6c, 0x65, 0x4e, 0x75, 0x6d, 0x18, 0x07,
0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x70, 0x65, 0x6f, 0x70, 0x6c, 0x65, 0x4e, 0x75, 0x6d, 0x12,
0x12, 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x74,
0x69, 0x6d, 0x65, 0x2a, 0xdb, 0x01, 0x0a, 0x12, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x4d,
0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e,
0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x45, 0x52, 0x52, 0x4f, 0x52,
0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x43, 0x48, 0x41, 0x54, 0x5f, 0x4d, 0x45, 0x53, 0x53, 0x41,
0x47, 0x45, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x50, 0x4c, 0x41, 0x59, 0x10, 0x03, 0x12, 0x09,
0x0a, 0x05, 0x50, 0x41, 0x55, 0x53, 0x45, 0x10, 0x04, 0x12, 0x0e, 0x0a, 0x0a, 0x43, 0x48, 0x45,
0x43, 0x4b, 0x5f, 0x53, 0x45, 0x45, 0x4b, 0x10, 0x05, 0x12, 0x0c, 0x0a, 0x08, 0x54, 0x4f, 0x4f,
0x5f, 0x46, 0x41, 0x53, 0x54, 0x10, 0x06, 0x12, 0x0c, 0x0a, 0x08, 0x54, 0x4f, 0x4f, 0x5f, 0x53,
0x4c, 0x4f, 0x57, 0x10, 0x07, 0x12, 0x0f, 0x0a, 0x0b, 0x43, 0x48, 0x41, 0x4e, 0x47, 0x45, 0x5f,
0x52, 0x41, 0x54, 0x45, 0x10, 0x08, 0x12, 0x0f, 0x0a, 0x0b, 0x43, 0x48, 0x41, 0x4e, 0x47, 0x45,
0x5f, 0x53, 0x45, 0x45, 0x4b, 0x10, 0x09, 0x12, 0x12, 0x0a, 0x0e, 0x43, 0x48, 0x41, 0x4e, 0x47,
0x45, 0x5f, 0x43, 0x55, 0x52, 0x52, 0x45, 0x4e, 0x54, 0x10, 0x0a, 0x12, 0x11, 0x0a, 0x0d, 0x43,
0x48, 0x41, 0x4e, 0x47, 0x45, 0x5f, 0x4d, 0x4f, 0x56, 0x49, 0x45, 0x53, 0x10, 0x0b, 0x12, 0x11,
0x0a, 0x0d, 0x43, 0x48, 0x41, 0x4e, 0x47, 0x45, 0x5f, 0x50, 0x45, 0x4f, 0x50, 0x4c, 0x45, 0x10,
0x0c, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x33,
var File_proto_message_message_proto protoreflect.FileDescriptor
var file_proto_message_message_proto_rawDesc = []byte{
0x0a, 0x1b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2f,
0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x22, 0x8c, 0x02, 0x0a, 0x0d, 0x42, 0x61, 0x73, 0x65, 0x4d, 0x6f, 0x76,
0x69, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20,
0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65,
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04,
0x6c, 0x69, 0x76, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x6c, 0x69, 0x76, 0x65,
0x12, 0x14, 0x0a, 0x05, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52,
0x05, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x12, 0x1e, 0x0a, 0x0a, 0x72, 0x74, 0x6d, 0x70, 0x53, 0x6f,
0x75, 0x72, 0x63, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x72, 0x74, 0x6d, 0x70,
0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x06,
0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x3b, 0x0a, 0x07, 0x68, 0x65,
0x61, 0x64, 0x65, 0x72, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x4d, 0x6f, 0x76, 0x69, 0x65, 0x49, 0x6e, 0x66,
0x6f, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07,
0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x1a, 0x3a, 0x0a, 0x0c, 0x48, 0x65, 0x61, 0x64, 0x65,
0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01,
0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c,
0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a,
0x02, 0x38, 0x01, 0x22, 0x97, 0x01, 0x0a, 0x09, 0x4d, 0x6f, 0x76, 0x69, 0x65, 0x49, 0x6e, 0x66,
0x6f, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x02, 0x69,
0x64, 0x12, 0x28, 0x0a, 0x04, 0x62, 0x61, 0x73, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32,
0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x4d, 0x6f, 0x76, 0x69,
0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x04, 0x62, 0x61, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x70,
0x75, 0x6c, 0x6c, 0x4b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x75,
0x6c, 0x6c, 0x4b, 0x65, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64,
0x41, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65,
0x64, 0x41, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x18, 0x05,
0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x22, 0x4a, 0x0a,
0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x65, 0x65, 0x6b, 0x18,
0x01, 0x20, 0x01, 0x28, 0x01, 0x52, 0x04, 0x73, 0x65, 0x65, 0x6b, 0x12, 0x12, 0x0a, 0x04, 0x72,
0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x01, 0x52, 0x04, 0x72, 0x61, 0x74, 0x65, 0x12,
0x18, 0x0a, 0x07, 0x70, 0x6c, 0x61, 0x79, 0x69, 0x6e, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08,
0x52, 0x07, 0x70, 0x6c, 0x61, 0x79, 0x69, 0x6e, 0x67, 0x22, 0x58, 0x0a, 0x07, 0x43, 0x75, 0x72,
0x72, 0x65, 0x6e, 0x74, 0x12, 0x26, 0x0a, 0x05, 0x6d, 0x6f, 0x76, 0x69, 0x65, 0x18, 0x01, 0x20,
0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4d, 0x6f, 0x76, 0x69,
0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x6d, 0x6f, 0x76, 0x69, 0x65, 0x12, 0x25, 0x0a, 0x06,
0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61,
0x74, 0x75, 0x73, 0x22, 0x86, 0x02, 0x0a, 0x0e, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x4d,
0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x2d, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01,
0x20, 0x01, 0x28, 0x0e, 0x32, 0x19, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x45, 0x6c, 0x65,
0x6d, 0x65, 0x6e, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x54, 0x79, 0x70, 0x65, 0x52,
0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x18,
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x12, 0x18, 0x0a,
0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07,
0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x61, 0x74, 0x65, 0x18,
0x04, 0x20, 0x01, 0x28, 0x01, 0x52, 0x04, 0x72, 0x61, 0x74, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x73,
0x65, 0x65, 0x6b, 0x18, 0x05, 0x20, 0x01, 0x28, 0x01, 0x52, 0x04, 0x73, 0x65, 0x65, 0x6b, 0x12,
0x2d, 0x0a, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b,
0x32, 0x0e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74,
0x48, 0x00, 0x52, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x88, 0x01, 0x01, 0x12, 0x1c,
0x0a, 0x09, 0x70, 0x65, 0x6f, 0x70, 0x6c, 0x65, 0x4e, 0x75, 0x6d, 0x18, 0x07, 0x20, 0x01, 0x28,
0x03, 0x52, 0x09, 0x70, 0x65, 0x6f, 0x70, 0x6c, 0x65, 0x4e, 0x75, 0x6d, 0x12, 0x12, 0x0a, 0x04,
0x74, 0x69, 0x6d, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x74, 0x69, 0x6d, 0x65,
0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x2a, 0xdb, 0x01, 0x0a,
0x12, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x54,
0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00,
0x12, 0x09, 0x0a, 0x05, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x43,
0x48, 0x41, 0x54, 0x5f, 0x4d, 0x45, 0x53, 0x53, 0x41, 0x47, 0x45, 0x10, 0x02, 0x12, 0x08, 0x0a,
0x04, 0x50, 0x4c, 0x41, 0x59, 0x10, 0x03, 0x12, 0x09, 0x0a, 0x05, 0x50, 0x41, 0x55, 0x53, 0x45,
0x10, 0x04, 0x12, 0x0e, 0x0a, 0x0a, 0x43, 0x48, 0x45, 0x43, 0x4b, 0x5f, 0x53, 0x45, 0x45, 0x4b,
0x10, 0x05, 0x12, 0x0c, 0x0a, 0x08, 0x54, 0x4f, 0x4f, 0x5f, 0x46, 0x41, 0x53, 0x54, 0x10, 0x06,
0x12, 0x0c, 0x0a, 0x08, 0x54, 0x4f, 0x4f, 0x5f, 0x53, 0x4c, 0x4f, 0x57, 0x10, 0x07, 0x12, 0x0f,
0x0a, 0x0b, 0x43, 0x48, 0x41, 0x4e, 0x47, 0x45, 0x5f, 0x52, 0x41, 0x54, 0x45, 0x10, 0x08, 0x12,
0x0f, 0x0a, 0x0b, 0x43, 0x48, 0x41, 0x4e, 0x47, 0x45, 0x5f, 0x53, 0x45, 0x45, 0x4b, 0x10, 0x09,
0x12, 0x12, 0x0a, 0x0e, 0x43, 0x48, 0x41, 0x4e, 0x47, 0x45, 0x5f, 0x43, 0x55, 0x52, 0x52, 0x45,
0x4e, 0x54, 0x10, 0x0a, 0x12, 0x11, 0x0a, 0x0d, 0x43, 0x48, 0x41, 0x4e, 0x47, 0x45, 0x5f, 0x4d,
0x4f, 0x56, 0x49, 0x45, 0x53, 0x10, 0x0b, 0x12, 0x11, 0x0a, 0x0d, 0x43, 0x48, 0x41, 0x4e, 0x47,
0x45, 0x5f, 0x50, 0x45, 0x4f, 0x50, 0x4c, 0x45, 0x10, 0x0c, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b,
0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_proto_message_proto_rawDescOnce sync.Once
file_proto_message_proto_rawDescData = file_proto_message_proto_rawDesc
file_proto_message_message_proto_rawDescOnce sync.Once
file_proto_message_message_proto_rawDescData = file_proto_message_message_proto_rawDesc
)
func file_proto_message_proto_rawDescGZIP() []byte {
file_proto_message_proto_rawDescOnce.Do(func() {
file_proto_message_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_message_proto_rawDescData)
func file_proto_message_message_proto_rawDescGZIP() []byte {
file_proto_message_message_proto_rawDescOnce.Do(func() {
file_proto_message_message_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_message_message_proto_rawDescData)
})
return file_proto_message_proto_rawDescData
return file_proto_message_message_proto_rawDescData
}
var file_proto_message_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_proto_message_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
var file_proto_message_proto_goTypes = []interface{}{
var file_proto_message_message_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_proto_message_message_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
var file_proto_message_message_proto_goTypes = []interface{}{
(ElementMessageType)(0), // 0: proto.ElementMessageType
(*BaseMovieInfo)(nil), // 1: proto.BaseMovieInfo
(*MovieInfo)(nil), // 2: proto.MovieInfo
@ -592,7 +593,7 @@ var file_proto_message_proto_goTypes = []interface{}{
(*ElementMessage)(nil), // 5: proto.ElementMessage
nil, // 6: proto.BaseMovieInfo.HeadersEntry
}
var file_proto_message_proto_depIdxs = []int32{
var file_proto_message_message_proto_depIdxs = []int32{
6, // 0: proto.BaseMovieInfo.headers:type_name -> proto.BaseMovieInfo.HeadersEntry
1, // 1: proto.MovieInfo.base:type_name -> proto.BaseMovieInfo
2, // 2: proto.Current.movie:type_name -> proto.MovieInfo
@ -606,13 +607,13 @@ var file_proto_message_proto_depIdxs = []int32{
0, // [0:6] is the sub-list for field type_name
}
func init() { file_proto_message_proto_init() }
func file_proto_message_proto_init() {
if File_proto_message_proto != nil {
func init() { file_proto_message_message_proto_init() }
func file_proto_message_message_proto_init() {
if File_proto_message_message_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_proto_message_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
file_proto_message_message_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*BaseMovieInfo); i {
case 0:
return &v.state
@ -624,7 +625,7 @@ func file_proto_message_proto_init() {
return nil
}
}
file_proto_message_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
file_proto_message_message_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*MovieInfo); i {
case 0:
return &v.state
@ -636,7 +637,7 @@ func file_proto_message_proto_init() {
return nil
}
}
file_proto_message_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
file_proto_message_message_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Status); i {
case 0:
return &v.state
@ -648,7 +649,7 @@ func file_proto_message_proto_init() {
return nil
}
}
file_proto_message_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
file_proto_message_message_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Current); i {
case 0:
return &v.state
@ -660,7 +661,7 @@ func file_proto_message_proto_init() {
return nil
}
}
file_proto_message_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
file_proto_message_message_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ElementMessage); i {
case 0:
return &v.state
@ -673,23 +674,24 @@ func file_proto_message_proto_init() {
}
}
}
file_proto_message_message_proto_msgTypes[4].OneofWrappers = []interface{}{}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_proto_message_proto_rawDesc,
RawDescriptor: file_proto_message_message_proto_rawDesc,
NumEnums: 1,
NumMessages: 6,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_proto_message_proto_goTypes,
DependencyIndexes: file_proto_message_proto_depIdxs,
EnumInfos: file_proto_message_proto_enumTypes,
MessageInfos: file_proto_message_proto_msgTypes,
GoTypes: file_proto_message_message_proto_goTypes,
DependencyIndexes: file_proto_message_message_proto_depIdxs,
EnumInfos: file_proto_message_message_proto_enumTypes,
MessageInfos: file_proto_message_message_proto_msgTypes,
}.Build()
File_proto_message_proto = out.File
file_proto_message_proto_rawDesc = nil
file_proto_message_proto_goTypes = nil
file_proto_message_proto_depIdxs = nil
File_proto_message_message_proto = out.File
file_proto_message_message_proto_rawDesc = nil
file_proto_message_message_proto_goTypes = nil
file_proto_message_message_proto_depIdxs = nil
}

@ -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",
}

@ -16,7 +16,7 @@ import (
dbModel "github.com/synctv-org/synctv/internal/model"
"github.com/synctv-org/synctv/internal/op"
"github.com/synctv-org/synctv/internal/rtmp"
pb "github.com/synctv-org/synctv/proto"
pb "github.com/synctv-org/synctv/proto/message"
"github.com/synctv-org/synctv/proxy"
"github.com/synctv-org/synctv/server/model"
"github.com/synctv-org/synctv/utils"

@ -10,7 +10,7 @@ import (
json "github.com/json-iterator/go"
log "github.com/sirupsen/logrus"
"github.com/synctv-org/synctv/internal/op"
pb "github.com/synctv-org/synctv/proto"
pb "github.com/synctv-org/synctv/proto/message"
"github.com/synctv-org/synctv/server/middlewares"
"github.com/synctv-org/synctv/server/model"
"github.com/synctv-org/synctv/utils"

@ -10,7 +10,6 @@ import (
"github.com/synctv-org/synctv/server/middlewares"
"github.com/synctv-org/synctv/server/model"
"github.com/synctv-org/synctv/utils"
"golang.org/x/oauth2"
)
// /oauth2/login/:type
@ -26,7 +25,7 @@ func OAuth2(ctx *gin.Context) {
state := utils.RandString(16)
states.Store(state, struct{}{}, time.Minute*5)
RenderRedirect(ctx, pi.NewConfig().AuthCodeURL(state, oauth2.AccessTypeOnline))
RenderRedirect(ctx, pi.NewAuthURL(state))
}
func OAuth2Api(ctx *gin.Context) {
@ -40,7 +39,7 @@ func OAuth2Api(ctx *gin.Context) {
states.Store(state, struct{}{}, time.Minute*5)
ctx.JSON(http.StatusOK, model.NewApiDataResp(gin.H{
"url": pi.NewConfig().AuthCodeURL(state, oauth2.AccessTypeOnline),
"url": pi.NewAuthURL(state),
}))
}
@ -71,7 +70,13 @@ func OAuth2Callback(ctx *gin.Context) {
return
}
ui, err := pi.GetUserInfo(ctx, pi.NewConfig(), code)
t, err := pi.GetToken(ctx, code)
if err != nil {
ctx.AbortWithStatusJSON(http.StatusBadRequest, model.NewApiErrorResp(err))
return
}
ui, err := pi.GetUserInfo(ctx, t)
if err != nil {
ctx.AbortWithStatusJSON(http.StatusBadRequest, model.NewApiErrorResp(err))
return
@ -112,7 +117,13 @@ func OAuth2CallbackApi(ctx *gin.Context) {
ctx.AbortWithStatusJSON(http.StatusBadRequest, model.NewApiErrorResp(err))
}
ui, err := pi.GetUserInfo(ctx, pi.NewConfig(), req.Code)
t, err := pi.GetToken(ctx, req.Code)
if err != nil {
ctx.AbortWithStatusJSON(http.StatusBadRequest, model.NewApiErrorResp(err))
return
}
ui, err := pi.GetUserInfo(ctx, t)
if err != nil {
ctx.AbortWithStatusJSON(http.StatusBadRequest, model.NewApiErrorResp(err))
return

Loading…
Cancel
Save