Compare commits
19 Commits
Author | SHA1 | Date | |
---|---|---|---|
dd4c97393e | |||
07b8ff25a7 | |||
0d5c3c5080 | |||
75b4429f73 | |||
34ef6bd18d | |||
c915313ec9 | |||
12a095a1d6 | |||
dc000f640a | |||
aa1c5b2be3 | |||
1d4ec3c50d | |||
ebfeef52f4 | |||
c595fd7f94 | |||
421052f88a | |||
603681fbe6 | |||
f442185aa5 | |||
ca9e739465 | |||
53a1c4283b | |||
93dd768234 | |||
c9c4d6bc7e |
2
.github/workflows/auto_lang.yml
vendored
2
.github/workflows/auto_lang.yml
vendored
@ -54,7 +54,7 @@ jobs:
|
|||||||
cd alist-web
|
cd alist-web
|
||||||
git add .
|
git add .
|
||||||
git config --local user.email "i@nn.ci"
|
git config --local user.email "i@nn.ci"
|
||||||
git config --local user.name "Noah Hsu"
|
git config --local user.name "Andy Hsu"
|
||||||
git commit -m "chore: auto update i18n file" -a 2>/dev/null || :
|
git commit -m "chore: auto update i18n file" -a 2>/dev/null || :
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
|
29
.github/workflows/release.yml
vendored
29
.github/workflows/release.yml
vendored
@ -51,4 +51,31 @@ jobs:
|
|||||||
- name: Release
|
- name: Release
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
with:
|
with:
|
||||||
files: build/compress/*
|
files: build/compress/*
|
||||||
|
|
||||||
|
release_desktop:
|
||||||
|
needs: release
|
||||||
|
name: Release desktop
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout repo
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
repository: alist-org/desktop-release
|
||||||
|
ref: main
|
||||||
|
persist-credentials: false
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Add tag
|
||||||
|
run: |
|
||||||
|
git config --local user.email "i@nn.ci"
|
||||||
|
git config --local user.name "Andy Hsu"
|
||||||
|
version=$(wget -qO- -t1 -T2 "https://api.github.com/repos/alist-org/alist/releases/latest" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g')
|
||||||
|
git tag -a $version -m "release $version"
|
||||||
|
|
||||||
|
- name: Push tags
|
||||||
|
uses: ad-m/github-push-action@master
|
||||||
|
with:
|
||||||
|
github_token: ${{ secrets.MY_TOKEN }}
|
||||||
|
branch: main
|
||||||
|
repository: alist-org/desktop-release
|
2
.github/workflows/release_docker.yml
vendored
2
.github/workflows/release_docker.yml
vendored
@ -57,7 +57,7 @@ jobs:
|
|||||||
- name: Add tag
|
- name: Add tag
|
||||||
run: |
|
run: |
|
||||||
git config --local user.email "i@nn.ci"
|
git config --local user.email "i@nn.ci"
|
||||||
git config --local user.name "Noah Hsu"
|
git config --local user.name "Andy Hsu"
|
||||||
git tag -a ${{ github.ref_name }} -m "release ${{ github.ref_name }}"
|
git tag -a ${{ github.ref_name }} -m "release ${{ github.ref_name }}"
|
||||||
|
|
||||||
- name: Push tags
|
- name: Push tags
|
||||||
|
@ -6,4 +6,5 @@ var (
|
|||||||
NoPrefix bool
|
NoPrefix bool
|
||||||
Dev bool
|
Dev bool
|
||||||
ForceBinDir bool
|
ForceBinDir bool
|
||||||
|
LogStd bool
|
||||||
)
|
)
|
||||||
|
@ -29,4 +29,5 @@ func init() {
|
|||||||
RootCmd.PersistentFlags().BoolVar(&flags.NoPrefix, "no-prefix", false, "disable env prefix")
|
RootCmd.PersistentFlags().BoolVar(&flags.NoPrefix, "no-prefix", false, "disable env prefix")
|
||||||
RootCmd.PersistentFlags().BoolVar(&flags.Dev, "dev", false, "start with dev mode")
|
RootCmd.PersistentFlags().BoolVar(&flags.Dev, "dev", false, "start with dev mode")
|
||||||
RootCmd.PersistentFlags().BoolVar(&flags.ForceBinDir, "force-bin-dir", false, "Force to use the directory where the binary file is located as data directory")
|
RootCmd.PersistentFlags().BoolVar(&flags.ForceBinDir, "force-bin-dir", false, "Force to use the directory where the binary file is located as data directory")
|
||||||
|
RootCmd.PersistentFlags().BoolVar(&flags.LogStd, "log-std", false, "Force to log to std")
|
||||||
}
|
}
|
||||||
|
@ -12,10 +12,11 @@ type Addition struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var config = driver.Config{
|
var config = driver.Config{
|
||||||
Name: "115 Cloud",
|
Name: "115 Cloud",
|
||||||
DefaultRoot: "0",
|
DefaultRoot: "0",
|
||||||
OnlyProxy: true,
|
OnlyProxy: true,
|
||||||
OnlyLocal: true,
|
OnlyLocal: true,
|
||||||
|
NoOverwriteUpload: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -7,18 +7,6 @@ import (
|
|||||||
"github.com/alist-org/alist/v3/internal/model"
|
"github.com/alist-org/alist/v3/internal/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
//type BaseResp struct {
|
|
||||||
// Code interface{} `json:"code"`
|
|
||||||
// Message string `json:"message"`
|
|
||||||
//}
|
|
||||||
|
|
||||||
type TokenResp struct {
|
|
||||||
//BaseResp
|
|
||||||
Data struct {
|
|
||||||
Token string `json:"token"`
|
|
||||||
} `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type File struct {
|
type File struct {
|
||||||
FileName string `json:"FileName"`
|
FileName string `json:"FileName"`
|
||||||
Size int64 `json:"Size"`
|
Size int64 `json:"Size"`
|
||||||
|
@ -29,9 +29,7 @@ func (d *Pan123) login() error {
|
|||||||
"password": d.Password,
|
"password": d.Password,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var resp TokenResp
|
|
||||||
res, err := base.RestyClient.R().
|
res, err := base.RestyClient.R().
|
||||||
SetResult(&resp).
|
|
||||||
SetBody(body).Post(url)
|
SetBody(body).Post(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -39,7 +37,7 @@ func (d *Pan123) login() error {
|
|||||||
if utils.Json.Get(res.Body(), "code").ToInt() != 200 {
|
if utils.Json.Get(res.Body(), "code").ToInt() != 200 {
|
||||||
err = fmt.Errorf(utils.Json.Get(res.Body(), "message").ToString())
|
err = fmt.Errorf(utils.Json.Get(res.Body(), "message").ToString())
|
||||||
} else {
|
} else {
|
||||||
d.AccessToken = resp.Data.Token
|
d.AccessToken = utils.Json.Get(res.Body(), "data", "token").ToString()
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -16,14 +16,15 @@ type Addition struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var config = driver.Config{
|
var config = driver.Config{
|
||||||
Name: "AliyundriveOpen",
|
Name: "AliyundriveOpen",
|
||||||
LocalSort: false,
|
LocalSort: false,
|
||||||
OnlyLocal: false,
|
OnlyLocal: false,
|
||||||
OnlyProxy: false,
|
OnlyProxy: false,
|
||||||
NoCache: false,
|
NoCache: false,
|
||||||
NoUpload: false,
|
NoUpload: false,
|
||||||
NeedMs: false,
|
NeedMs: false,
|
||||||
DefaultRoot: "root",
|
DefaultRoot: "root",
|
||||||
|
NoOverwriteUpload: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -154,7 +154,7 @@ func (d *BaiduNetdisk) linkCrack(file model.Obj, args model.LinkArgs) (*model.Li
|
|||||||
"target": fmt.Sprintf("[\"%s\"]", file.GetPath()),
|
"target": fmt.Sprintf("[\"%s\"]", file.GetPath()),
|
||||||
"dlink": "1",
|
"dlink": "1",
|
||||||
"web": "5",
|
"web": "5",
|
||||||
"origin": "dlna",
|
//"origin": "dlna",
|
||||||
}
|
}
|
||||||
_, err := d.request("https://pan.baidu.com/api/filemetas", http.MethodGet, func(req *resty.Request) {
|
_, err := d.request("https://pan.baidu.com/api/filemetas", http.MethodGet, func(req *resty.Request) {
|
||||||
req.SetQueryParams(param)
|
req.SetQueryParams(param)
|
||||||
@ -165,7 +165,7 @@ func (d *BaiduNetdisk) linkCrack(file model.Obj, args model.LinkArgs) (*model.Li
|
|||||||
return &model.Link{
|
return &model.Link{
|
||||||
URL: resp.Info[0].Dlink,
|
URL: resp.Info[0].Dlink,
|
||||||
Header: http.Header{
|
Header: http.Header{
|
||||||
"User-Agent": []string{"pan.baidu.com"},
|
"User-Agent": []string{"netdisk"},
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/alist-org/alist/v3/server/common"
|
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -21,6 +20,7 @@ import (
|
|||||||
"github.com/alist-org/alist/v3/internal/model"
|
"github.com/alist-org/alist/v3/internal/model"
|
||||||
"github.com/alist-org/alist/v3/internal/sign"
|
"github.com/alist-org/alist/v3/internal/sign"
|
||||||
"github.com/alist-org/alist/v3/pkg/utils"
|
"github.com/alist-org/alist/v3/pkg/utils"
|
||||||
|
"github.com/alist-org/alist/v3/server/common"
|
||||||
"github.com/disintegration/imaging"
|
"github.com/disintegration/imaging"
|
||||||
_ "golang.org/x/image/webp"
|
_ "golang.org/x/image/webp"
|
||||||
)
|
)
|
||||||
@ -28,6 +28,7 @@ import (
|
|||||||
type Local struct {
|
type Local struct {
|
||||||
model.Storage
|
model.Storage
|
||||||
Addition
|
Addition
|
||||||
|
mkdirPerm int32
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Local) Config() driver.Config {
|
func (d *Local) Config() driver.Config {
|
||||||
@ -35,8 +36,14 @@ func (d *Local) Config() driver.Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *Local) Init(ctx context.Context) error {
|
func (d *Local) Init(ctx context.Context) error {
|
||||||
if d.MkdirPerm == 0 {
|
if d.MkdirPerm == "" {
|
||||||
d.MkdirPerm = 777
|
d.mkdirPerm = 0777
|
||||||
|
} else {
|
||||||
|
v, err := strconv.ParseUint(d.MkdirPerm, 8, 32)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
d.mkdirPerm = int32(v)
|
||||||
}
|
}
|
||||||
if !utils.Exists(d.GetRootPath()) {
|
if !utils.Exists(d.GetRootPath()) {
|
||||||
return fmt.Errorf("root folder %s not exists", d.GetRootPath())
|
return fmt.Errorf("root folder %s not exists", d.GetRootPath())
|
||||||
@ -168,7 +175,7 @@ func (d *Local) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (
|
|||||||
|
|
||||||
func (d *Local) MakeDir(ctx context.Context, parentDir model.Obj, dirName string) error {
|
func (d *Local) MakeDir(ctx context.Context, parentDir model.Obj, dirName string) error {
|
||||||
fullPath := filepath.Join(parentDir.GetPath(), dirName)
|
fullPath := filepath.Join(parentDir.GetPath(), dirName)
|
||||||
err := os.MkdirAll(fullPath, os.FileMode(d.MkdirPerm))
|
err := os.MkdirAll(fullPath, os.FileMode(d.mkdirPerm))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ type Addition struct {
|
|||||||
driver.RootPath
|
driver.RootPath
|
||||||
Thumbnail bool `json:"thumbnail" required:"true" help:"enable thumbnail"`
|
Thumbnail bool `json:"thumbnail" required:"true" help:"enable thumbnail"`
|
||||||
ShowHidden bool `json:"show_hidden" default:"true" required:"false" help:"show hidden directories and files"`
|
ShowHidden bool `json:"show_hidden" default:"true" required:"false" help:"show hidden directories and files"`
|
||||||
MkdirPerm uint32 `json:"mkdir_perm" type:"number" default:"777"`
|
MkdirPerm string `json:"mkdir_perm" default:"777"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var config = driver.Config{
|
var config = driver.Config{
|
||||||
|
@ -16,6 +16,7 @@ var config = driver.Config{
|
|||||||
Name: "Quark",
|
Name: "Quark",
|
||||||
OnlyProxy: true,
|
OnlyProxy: true,
|
||||||
DefaultRoot: "0",
|
DefaultRoot: "0",
|
||||||
|
NoOverwriteUpload: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
16
go.mod
16
go.mod
@ -8,7 +8,7 @@ require (
|
|||||||
github.com/aws/aws-sdk-go v1.44.194
|
github.com/aws/aws-sdk-go v1.44.194
|
||||||
github.com/blevesearch/bleve/v2 v2.3.6
|
github.com/blevesearch/bleve/v2 v2.3.6
|
||||||
github.com/caarlos0/env/v7 v7.0.0
|
github.com/caarlos0/env/v7 v7.0.0
|
||||||
github.com/deckarep/golang-set/v2 v2.1.0
|
github.com/deckarep/golang-set/v2 v2.2.0
|
||||||
github.com/disintegration/imaging v1.6.2
|
github.com/disintegration/imaging v1.6.2
|
||||||
github.com/dustinxie/ecc v0.0.0-20210511000915-959544187564
|
github.com/dustinxie/ecc v0.0.0-20210511000915-959544187564
|
||||||
github.com/gin-contrib/cors v1.4.0
|
github.com/gin-contrib/cors v1.4.0
|
||||||
@ -27,17 +27,17 @@ require (
|
|||||||
github.com/pquerna/otp v1.4.0
|
github.com/pquerna/otp v1.4.0
|
||||||
github.com/sirupsen/logrus v1.9.0
|
github.com/sirupsen/logrus v1.9.0
|
||||||
github.com/spf13/cobra v1.6.1
|
github.com/spf13/cobra v1.6.1
|
||||||
github.com/t3rm1n4l/go-mega v0.0.0-20230220145126-b87ebf5801d8
|
github.com/t3rm1n4l/go-mega v0.0.0-20230228171823-a01a2cda13ca
|
||||||
github.com/u2takey/ffmpeg-go v0.4.1
|
github.com/u2takey/ffmpeg-go v0.4.1
|
||||||
github.com/upyun/go-sdk/v3 v3.0.3
|
github.com/upyun/go-sdk/v3 v3.0.3
|
||||||
github.com/winfsp/cgofuse v1.5.0
|
github.com/winfsp/cgofuse v1.5.0
|
||||||
golang.org/x/crypto v0.6.0
|
golang.org/x/crypto v0.7.0
|
||||||
golang.org/x/image v0.5.0
|
golang.org/x/image v0.6.0
|
||||||
golang.org/x/net v0.7.0
|
golang.org/x/net v0.8.0
|
||||||
gorm.io/driver/mysql v1.4.7
|
gorm.io/driver/mysql v1.4.7
|
||||||
gorm.io/driver/postgres v1.4.8
|
gorm.io/driver/postgres v1.4.8
|
||||||
gorm.io/driver/sqlite v1.4.4
|
gorm.io/driver/sqlite v1.4.4
|
||||||
gorm.io/gorm v1.24.5
|
gorm.io/gorm v1.24.6
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
@ -104,8 +104,8 @@ require (
|
|||||||
github.com/ugorji/go/codec v1.2.9 // indirect
|
github.com/ugorji/go/codec v1.2.9 // indirect
|
||||||
go.etcd.io/bbolt v1.3.5 // indirect
|
go.etcd.io/bbolt v1.3.5 // indirect
|
||||||
golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect
|
golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect
|
||||||
golang.org/x/sys v0.5.0 // indirect
|
golang.org/x/sys v0.6.0 // indirect
|
||||||
golang.org/x/text v0.7.0 // indirect
|
golang.org/x/text v0.8.0 // indirect
|
||||||
golang.org/x/time v0.0.0-20220922220347-f3bd1da661af // indirect
|
golang.org/x/time v0.0.0-20220922220347-f3bd1da661af // indirect
|
||||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
|
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
|
||||||
google.golang.org/protobuf v1.28.1 // indirect
|
google.golang.org/protobuf v1.28.1 // indirect
|
||||||
|
19
go.sum
19
go.sum
@ -68,6 +68,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/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/deckarep/golang-set/v2 v2.1.0 h1:g47V4Or+DUdzbs8FxCCmgb6VYd+ptPAngjM6dtGktsI=
|
github.com/deckarep/golang-set/v2 v2.1.0 h1:g47V4Or+DUdzbs8FxCCmgb6VYd+ptPAngjM6dtGktsI=
|
||||||
github.com/deckarep/golang-set/v2 v2.1.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4=
|
github.com/deckarep/golang-set/v2 v2.1.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4=
|
||||||
|
github.com/deckarep/golang-set/v2 v2.2.0 h1:2pMQd3Soi6qfw7E5MMKaEh5W5ES18bW3AbFFnGl6LgQ=
|
||||||
|
github.com/deckarep/golang-set/v2 v2.2.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4=
|
||||||
github.com/disintegration/imaging v1.6.2 h1:w1LecBlG2Lnp8B3jk5zSuNqd7b4DXhcjwek1ei82L+c=
|
github.com/disintegration/imaging v1.6.2 h1:w1LecBlG2Lnp8B3jk5zSuNqd7b4DXhcjwek1ei82L+c=
|
||||||
github.com/disintegration/imaging v1.6.2/go.mod h1:44/5580QXChDfwIclfc/PCwrr44amcmDAg8hxG0Ewe4=
|
github.com/disintegration/imaging v1.6.2/go.mod h1:44/5580QXChDfwIclfc/PCwrr44amcmDAg8hxG0Ewe4=
|
||||||
github.com/dustinxie/ecc v0.0.0-20210511000915-959544187564 h1:I6KUy4CI6hHjqnyJLNCEi7YHVMkwwtfSr2k9splgdSM=
|
github.com/dustinxie/ecc v0.0.0-20210511000915-959544187564 h1:I6KUy4CI6hHjqnyJLNCEi7YHVMkwwtfSr2k9splgdSM=
|
||||||
@ -248,6 +250,8 @@ github.com/t3rm1n4l/go-mega v0.0.0-20220725095014-c4e0c2b5debf h1:Y43S3e9P1NPs/Q
|
|||||||
github.com/t3rm1n4l/go-mega v0.0.0-20220725095014-c4e0c2b5debf/go.mod h1:c+cGNU1qi9bO7ZF4IRMYk+KaZTNiQ/gQrSbyMmGFq1Q=
|
github.com/t3rm1n4l/go-mega v0.0.0-20220725095014-c4e0c2b5debf/go.mod h1:c+cGNU1qi9bO7ZF4IRMYk+KaZTNiQ/gQrSbyMmGFq1Q=
|
||||||
github.com/t3rm1n4l/go-mega v0.0.0-20230220145126-b87ebf5801d8 h1:Jg3qJLX/qhwrh4MdB75+Z9l/JkCODVHG8nXY187qa1E=
|
github.com/t3rm1n4l/go-mega v0.0.0-20230220145126-b87ebf5801d8 h1:Jg3qJLX/qhwrh4MdB75+Z9l/JkCODVHG8nXY187qa1E=
|
||||||
github.com/t3rm1n4l/go-mega v0.0.0-20230220145126-b87ebf5801d8/go.mod h1:c+cGNU1qi9bO7ZF4IRMYk+KaZTNiQ/gQrSbyMmGFq1Q=
|
github.com/t3rm1n4l/go-mega v0.0.0-20230220145126-b87ebf5801d8/go.mod h1:c+cGNU1qi9bO7ZF4IRMYk+KaZTNiQ/gQrSbyMmGFq1Q=
|
||||||
|
github.com/t3rm1n4l/go-mega v0.0.0-20230228171823-a01a2cda13ca h1:I9rVnNXdIkij4UvMT7OmKhH9sOIvS8iXkxfPdnn9wQA=
|
||||||
|
github.com/t3rm1n4l/go-mega v0.0.0-20230228171823-a01a2cda13ca/go.mod h1:suDIky6yrK07NnaBadCB4sS0CqFOvUK91lH7CR+JlDA=
|
||||||
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
||||||
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
||||||
github.com/u2takey/ffmpeg-go v0.4.1 h1:l5ClIwL3N2LaH1zF3xivb3kP2HW95eyG5xhHE1JdZ9Y=
|
github.com/u2takey/ffmpeg-go v0.4.1 h1:l5ClIwL3N2LaH1zF3xivb3kP2HW95eyG5xhHE1JdZ9Y=
|
||||||
@ -279,12 +283,18 @@ golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5y
|
|||||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||||
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||||
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||||
|
golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw=
|
||||||
golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc=
|
golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc=
|
||||||
golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
|
golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
|
||||||
|
golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A=
|
||||||
|
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
|
||||||
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||||
golang.org/x/image v0.5.0 h1:5JMiNunQeQw++mMOz48/ISeNu3Iweh/JaZU8ZLqHRrI=
|
golang.org/x/image v0.5.0 h1:5JMiNunQeQw++mMOz48/ISeNu3Iweh/JaZU8ZLqHRrI=
|
||||||
golang.org/x/image v0.5.0/go.mod h1:FVC7BI/5Ym8R25iw5OLsgshdUBbT1h5jZTpA+mvAdZ4=
|
golang.org/x/image v0.5.0/go.mod h1:FVC7BI/5Ym8R25iw5OLsgshdUBbT1h5jZTpA+mvAdZ4=
|
||||||
|
golang.org/x/image v0.6.0 h1:bR8b5okrPI3g/gyZakLZHeWxAR8Dn5CyxXv1hLH5g/4=
|
||||||
|
golang.org/x/image v0.6.0/go.mod h1:MXLdDR43H7cDJq5GEGXEVeeNhPgi+YYEQ2pC1byI1x0=
|
||||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||||
|
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||||
@ -296,6 +306,8 @@ golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
|
|||||||
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||||
golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g=
|
golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g=
|
||||||
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||||
|
golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=
|
||||||
|
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
|
||||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
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/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
@ -319,6 +331,8 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
|
|||||||
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
|
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
|
||||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
|
||||||
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||||
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||||
@ -332,6 +346,8 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
|||||||
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||||
golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo=
|
golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo=
|
||||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||||
|
golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68=
|
||||||
|
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
golang.org/x/time v0.0.0-20220722155302-e5dcc9cfc0b9/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
golang.org/x/time v0.0.0-20220722155302-e5dcc9cfc0b9/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
golang.org/x/time v0.0.0-20220922220347-f3bd1da661af h1:Yx9k8YCG3dvF87UAn2tu2HQLf2dt/eR1bXxpLMWeH+Y=
|
golang.org/x/time v0.0.0-20220922220347-f3bd1da661af h1:Yx9k8YCG3dvF87UAn2tu2HQLf2dt/eR1bXxpLMWeH+Y=
|
||||||
@ -340,6 +356,7 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm
|
|||||||
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||||
|
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
|
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
|
||||||
@ -375,5 +392,7 @@ gorm.io/gorm v1.24.0/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA=
|
|||||||
gorm.io/gorm v1.24.2/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA=
|
gorm.io/gorm v1.24.2/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA=
|
||||||
gorm.io/gorm v1.24.5 h1:g6OPREKqqlWq4kh/3MCQbZKImeB9e6Xgc4zD+JgNZGE=
|
gorm.io/gorm v1.24.5 h1:g6OPREKqqlWq4kh/3MCQbZKImeB9e6Xgc4zD+JgNZGE=
|
||||||
gorm.io/gorm v1.24.5/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA=
|
gorm.io/gorm v1.24.5/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA=
|
||||||
|
gorm.io/gorm v1.24.6 h1:wy98aq9oFEetsc4CAbKD2SoBCdMzsbSIvSUUFJuHi5s=
|
||||||
|
gorm.io/gorm v1.24.6/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k=
|
||||||
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
|
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
|
||||||
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
|
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
|
||||||
|
@ -150,10 +150,11 @@ func InitialSettings() []model.SettingItem {
|
|||||||
{Key: conf.MaxIndexDepth, Value: "20", Type: conf.TypeNumber, Group: model.INDEX, Flag: model.PRIVATE, Help: `max depth of index`},
|
{Key: conf.MaxIndexDepth, Value: "20", Type: conf.TypeNumber, Group: model.INDEX, Flag: model.PRIVATE, Help: `max depth of index`},
|
||||||
{Key: conf.IndexProgress, Value: "{}", Type: conf.TypeText, Group: model.SINGLE, Flag: model.PRIVATE},
|
{Key: conf.IndexProgress, Value: "{}", Type: conf.TypeText, Group: model.SINGLE, Flag: model.PRIVATE},
|
||||||
|
|
||||||
// GitHub settings
|
// SSO settings
|
||||||
{Key: conf.GithubClientId, Value: "", Type: conf.TypeString, Group: model.GITHUB, Flag: model.PRIVATE},
|
{Key: conf.SSOLoginEnabled, Value: "false", Type: conf.TypeBool, Group: model.SSO, Flag: model.PUBLIC},
|
||||||
{Key: conf.GithubClientSecrets, Value: "", Type: conf.TypeString, Group: model.GITHUB, Flag: model.PRIVATE},
|
{Key: conf.SSOLoginplatform, Type: conf.TypeSelect, Options: "Github,Microsoft,Google,Dingtalk", Group: model.SSO, Flag: model.PUBLIC},
|
||||||
{Key: conf.GithubLoginEnabled, Value: "false", Type: conf.TypeBool, Group: model.GITHUB, Flag: model.PUBLIC},
|
{Key: conf.SSOClientId, Value: "", Type: conf.TypeString, Group: model.SSO, Flag: model.PRIVATE},
|
||||||
|
{Key: conf.SSOClientSecret, Value: "", Type: conf.TypeString, Group: model.SSO, Flag: model.PRIVATE},
|
||||||
|
|
||||||
// qbittorrent settings
|
// qbittorrent settings
|
||||||
{Key: conf.QbittorrentUrl, Value: "http://admin:adminadmin@localhost:8080/", Type: conf.TypeString, Group: model.SINGLE, Flag: model.PRIVATE},
|
{Key: conf.QbittorrentUrl, Value: "http://admin:adminadmin@localhost:8080/", Type: conf.TypeString, Group: model.SINGLE, Flag: model.PRIVATE},
|
||||||
|
@ -46,7 +46,7 @@ func Log() {
|
|||||||
MaxAge: logConfig.MaxAge, //days
|
MaxAge: logConfig.MaxAge, //days
|
||||||
Compress: logConfig.Compress, // disabled by default
|
Compress: logConfig.Compress, // disabled by default
|
||||||
}
|
}
|
||||||
if flags.Debug || flags.Dev {
|
if flags.Debug || flags.Dev || flags.LogStd {
|
||||||
w = io.MultiWriter(os.Stdout, w)
|
w = io.MultiWriter(os.Stdout, w)
|
||||||
}
|
}
|
||||||
logrus.SetOutput(w)
|
logrus.SetOutput(w)
|
||||||
|
@ -1,33 +1,33 @@
|
|||||||
package conf
|
package conf
|
||||||
|
|
||||||
const (
|
const (
|
||||||
TypeString = "string"
|
TypeString = "string"
|
||||||
TypeSelect = "select"
|
TypeSelect = "select"
|
||||||
TypeBool = "bool"
|
TypeBool = "bool"
|
||||||
TypeText = "text"
|
TypeText = "text"
|
||||||
TypeNumber = "number"
|
TypeNumber = "number"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// site
|
// site
|
||||||
VERSION = "version"
|
VERSION = "version"
|
||||||
SiteTitle = "site_title"
|
SiteTitle = "site_title"
|
||||||
Announcement = "announcement"
|
Announcement = "announcement"
|
||||||
AllowIndexed = "allow_indexed"
|
AllowIndexed = "allow_indexed"
|
||||||
|
|
||||||
Logo = "logo"
|
Logo = "logo"
|
||||||
Favicon = "favicon"
|
Favicon = "favicon"
|
||||||
MainColor = "main_color"
|
MainColor = "main_color"
|
||||||
|
|
||||||
// preview
|
// preview
|
||||||
TextTypes = "text_types"
|
TextTypes = "text_types"
|
||||||
AudioTypes = "audio_types"
|
AudioTypes = "audio_types"
|
||||||
VideoTypes = "video_types"
|
VideoTypes = "video_types"
|
||||||
ImageTypes = "image_types"
|
ImageTypes = "image_types"
|
||||||
ProxyTypes = "proxy_types"
|
ProxyTypes = "proxy_types"
|
||||||
ProxyIgnoreHeaders = "proxy_ignore_headers"
|
ProxyIgnoreHeaders = "proxy_ignore_headers"
|
||||||
AudioAutoplay = "audio_autoplay"
|
AudioAutoplay = "audio_autoplay"
|
||||||
VideoAutoplay = "video_autoplay"
|
VideoAutoplay = "video_autoplay"
|
||||||
|
|
||||||
// global
|
// global
|
||||||
HideFiles = "hide_files"
|
HideFiles = "hide_files"
|
||||||
@ -39,36 +39,37 @@ const (
|
|||||||
OcrApi = "ocr_api"
|
OcrApi = "ocr_api"
|
||||||
FilenameCharMapping = "filename_char_mapping"
|
FilenameCharMapping = "filename_char_mapping"
|
||||||
ForwardDirectLinkParams = "forward_direct_link_params"
|
ForwardDirectLinkParams = "forward_direct_link_params"
|
||||||
|
|
||||||
// index
|
// index
|
||||||
SearchIndex = "search_index"
|
SearchIndex = "search_index"
|
||||||
AutoUpdateIndex = "auto_update_index"
|
AutoUpdateIndex = "auto_update_index"
|
||||||
IgnorePaths = "ignore_paths"
|
IgnorePaths = "ignore_paths"
|
||||||
MaxIndexDepth = "max_index_depth"
|
MaxIndexDepth = "max_index_depth"
|
||||||
|
|
||||||
// aria2
|
// aria2
|
||||||
Aria2Uri = "aria2_uri"
|
Aria2Uri = "aria2_uri"
|
||||||
Aria2Secret = "aria2_secret"
|
Aria2Secret = "aria2_secret"
|
||||||
|
|
||||||
// single
|
// single
|
||||||
Token = "token"
|
Token = "token"
|
||||||
IndexProgress = "index_progress"
|
IndexProgress = "index_progress"
|
||||||
|
|
||||||
//Github
|
//SSO
|
||||||
GithubClientId = "github_client_id"
|
SSOClientId = "sso_client_id"
|
||||||
GithubClientSecrets = "github_client_secrets"
|
SSOClientSecret = "sso_client_secret"
|
||||||
GithubLoginEnabled = "github_login_enabled"
|
SSOLoginEnabled = "sso_login_enabled"
|
||||||
|
SSOLoginplatform = "sso_login_platform"
|
||||||
|
|
||||||
// qbittorrent
|
// qbittorrent
|
||||||
QbittorrentUrl = "qbittorrent_url"
|
QbittorrentUrl = "qbittorrent_url"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
UNKNOWN = iota
|
UNKNOWN = iota
|
||||||
FOLDER
|
FOLDER
|
||||||
//OFFICE
|
//OFFICE
|
||||||
VIDEO
|
VIDEO
|
||||||
AUDIO
|
AUDIO
|
||||||
TEXT
|
TEXT
|
||||||
IMAGE
|
IMAGE
|
||||||
)
|
)
|
||||||
|
@ -21,10 +21,10 @@ func GetUserByName(username string) (*model.User, error) {
|
|||||||
return &user, nil
|
return &user, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetUserByGithubID(githubID int) (*model.User, error) {
|
func GetUserBySSOID(ssoID string) (*model.User, error) {
|
||||||
user := model.User{GithubID: githubID}
|
user := model.User{SsoID: ssoID}
|
||||||
if err := db.Where(user).First(&user).Error; err != nil {
|
if err := db.Where(user).First(&user).Error; err != nil {
|
||||||
return nil, errors.Wrapf(err, "The Github ID is not associated with a user")
|
return nil, errors.Wrapf(err, "The single sign on platform is not bound to any users")
|
||||||
}
|
}
|
||||||
return &user, nil
|
return &user, nil
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,17 @@
|
|||||||
package driver
|
package driver
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
LocalSort bool `json:"local_sort"`
|
LocalSort bool `json:"local_sort"`
|
||||||
OnlyLocal bool `json:"only_local"`
|
OnlyLocal bool `json:"only_local"`
|
||||||
OnlyProxy bool `json:"only_proxy"`
|
OnlyProxy bool `json:"only_proxy"`
|
||||||
NoCache bool `json:"no_cache"`
|
NoCache bool `json:"no_cache"`
|
||||||
NoUpload bool `json:"no_upload"`
|
NoUpload bool `json:"no_upload"`
|
||||||
NeedMs bool `json:"need_ms"` // if need get message from user, such as validate code
|
NeedMs bool `json:"need_ms"` // if need get message from user, such as validate code
|
||||||
DefaultRoot string `json:"default_root"`
|
DefaultRoot string `json:"default_root"`
|
||||||
CheckStatus bool `json:"-"`
|
CheckStatus bool `json:"-"`
|
||||||
Alert string `json:"alert"` //info,success,warning,danger
|
Alert string `json:"alert"` //info,success,warning,danger
|
||||||
|
NoOverwriteUpload bool `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Config) MustProxy() bool {
|
func (c Config) MustProxy() bool {
|
||||||
|
@ -8,7 +8,7 @@ const (
|
|||||||
GLOBAL
|
GLOBAL
|
||||||
ARIA2
|
ARIA2
|
||||||
INDEX
|
INDEX
|
||||||
GITHUB
|
SSO
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -33,7 +33,7 @@ type User struct {
|
|||||||
// 10: can add qbittorrent tasks
|
// 10: can add qbittorrent tasks
|
||||||
Permission int32 `json:"permission"`
|
Permission int32 `json:"permission"`
|
||||||
OtpSecret string `json:"-"`
|
OtpSecret string `json:"-"`
|
||||||
GithubID int `json:"github_id"`
|
SsoID string `json:"sso_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u User) IsGuest() bool {
|
func (u User) IsGuest() bool {
|
||||||
|
@ -459,6 +459,7 @@ func Remove(ctx context.Context, storage driver.Driver, path string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
// if object not found, it's ok
|
// if object not found, it's ok
|
||||||
if errs.IsObjectNotFound(err) {
|
if errs.IsObjectNotFound(err) {
|
||||||
|
log.Debugf("%s have been removed", path)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return errors.WithMessage(err, "failed to get object")
|
return errors.WithMessage(err, "failed to get object")
|
||||||
@ -497,6 +498,8 @@ func Put(ctx context.Context, storage driver.Driver, dstDirPath string, file *mo
|
|||||||
// if file exist and size = 0, delete it
|
// if file exist and size = 0, delete it
|
||||||
dstDirPath = utils.FixAndCleanPath(dstDirPath)
|
dstDirPath = utils.FixAndCleanPath(dstDirPath)
|
||||||
dstPath := stdpath.Join(dstDirPath, file.GetName())
|
dstPath := stdpath.Join(dstDirPath, file.GetName())
|
||||||
|
tempName := file.GetName() + ".alist_to_delete"
|
||||||
|
tempPath := stdpath.Join(dstDirPath, tempName)
|
||||||
fi, err := GetUnwrap(ctx, storage, dstPath)
|
fi, err := GetUnwrap(ctx, storage, dstPath)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if fi.GetSize() == 0 {
|
if fi.GetSize() == 0 {
|
||||||
@ -504,6 +507,12 @@ func Put(ctx context.Context, storage driver.Driver, dstDirPath string, file *mo
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessagef(err, "failed remove file that exist and have size 0")
|
return errors.WithMessagef(err, "failed remove file that exist and have size 0")
|
||||||
}
|
}
|
||||||
|
} else if storage.Config().NoOverwriteUpload {
|
||||||
|
// try to rename old obj
|
||||||
|
err = Rename(ctx, storage, dstPath, tempName)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
file.Old = fi
|
file.Old = fi
|
||||||
}
|
}
|
||||||
@ -542,10 +551,20 @@ func Put(ctx context.Context, storage driver.Driver, dstDirPath string, file *mo
|
|||||||
return errs.NotImplement
|
return errs.NotImplement
|
||||||
}
|
}
|
||||||
log.Debugf("put file [%s] done", file.GetName())
|
log.Debugf("put file [%s] done", file.GetName())
|
||||||
//if err == nil {
|
if storage.Config().NoOverwriteUpload && fi != nil && fi.GetSize() > 0 {
|
||||||
// //clear cache
|
if err != nil {
|
||||||
// key := stdpath.Join(storage.GetStorage().MountPath, dstDirPath)
|
// upload failed, recover old obj
|
||||||
// listCache.Del(key)
|
err := Rename(ctx, storage, tempPath, file.GetName())
|
||||||
//}
|
if err != nil {
|
||||||
|
log.Errorf("failed recover old obj: %+v", err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// upload success, remove old obj
|
||||||
|
err := Remove(ctx, storage, tempPath)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return errors.WithStack(err)
|
return errors.WithStack(err)
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package common
|
package common
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"path"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -15,12 +16,20 @@ func CanWrite(meta *model.Meta, path string) bool {
|
|||||||
return meta.WSub || meta.Path == path
|
return meta.WSub || meta.Path == path
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func IsApply(metaPath, reqPath string, applySub bool) bool {
|
||||||
|
if utils.PathEqual(metaPath, reqPath) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return utils.IsSubPath(reqPath, metaPath) && applySub
|
||||||
|
}
|
||||||
|
|
||||||
func CanAccess(user *model.User, meta *model.Meta, reqPath string, password string) bool {
|
func CanAccess(user *model.User, meta *model.Meta, reqPath string, password string) bool {
|
||||||
// if the reqPath is in hide (only can check the nearest meta) and user can't see hides, can't access
|
// if the reqPath is in hide (only can check the nearest meta) and user can't see hides, can't access
|
||||||
if meta != nil && !user.CanSeeHides() && meta.Hide != "" && !utils.PathEqual(meta.Path, reqPath) {
|
if meta != nil && !user.CanSeeHides() && meta.Hide != "" &&
|
||||||
|
IsApply(meta.Path, path.Dir(reqPath), meta.HSub) { // the meta should apply to the parent of current path
|
||||||
for _, hide := range strings.Split(meta.Hide, "\n") {
|
for _, hide := range strings.Split(meta.Hide, "\n") {
|
||||||
re := regexp.MustCompile(hide)
|
re := regexp.MustCompile(hide)
|
||||||
if re.MatchString(reqPath[len(meta.Path)+1:]) {
|
if re.MatchString(path.Base(reqPath)) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ func UpdateCurrent(c *gin.Context) {
|
|||||||
if req.Password != "" {
|
if req.Password != "" {
|
||||||
user.Password = req.Password
|
user.Password = req.Password
|
||||||
}
|
}
|
||||||
user.GithubID = req.GithubID
|
user.SsoID = req.SsoID
|
||||||
if err := op.UpdateUser(user); err != nil {
|
if err := op.UpdateUser(user); err != nil {
|
||||||
common.ErrorResp(c, err, 500)
|
common.ErrorResp(c, err, 500)
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,101 +0,0 @@
|
|||||||
package handles
|
|
||||||
|
|
||||||
import (
|
|
||||||
"errors"
|
|
||||||
"net/url"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"github.com/alist-org/alist/v3/internal/db"
|
|
||||||
"github.com/alist-org/alist/v3/pkg/utils"
|
|
||||||
"github.com/alist-org/alist/v3/server/common"
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
)
|
|
||||||
|
|
||||||
func GithubLoginRedirect(c *gin.Context) {
|
|
||||||
method := c.Query("method")
|
|
||||||
callbackURL := c.Query("callback_url")
|
|
||||||
withParams := c.Query("with_params")
|
|
||||||
enabled, err := db.GetSettingItemByKey("github_login_enabled")
|
|
||||||
clientId, err := db.GetSettingItemByKey("github_client_id")
|
|
||||||
if err != nil {
|
|
||||||
common.ErrorResp(c, err, 400)
|
|
||||||
return
|
|
||||||
} else if enabled.Value == "true" {
|
|
||||||
urlValues := url.Values{}
|
|
||||||
urlValues.Add("client_id", clientId.Value)
|
|
||||||
if method == "get_github_id" {
|
|
||||||
urlValues.Add("allow_signup", "true")
|
|
||||||
} else if method == "github_callback_login" {
|
|
||||||
urlValues.Add("allow_signup", "false")
|
|
||||||
}
|
|
||||||
if method == "" {
|
|
||||||
common.ErrorStrResp(c, "no method provided", 400)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if withParams != "" {
|
|
||||||
urlValues.Add("redirect_uri", common.GetApiUrl(c.Request)+"/api/auth/github_callback"+"?method="+method+"&callback_url="+callbackURL+"&with_params="+withParams)
|
|
||||||
} else {
|
|
||||||
urlValues.Add("redirect_uri", common.GetApiUrl(c.Request)+"/api/auth/github_callback"+"?method="+method+"&callback_url="+callbackURL)
|
|
||||||
}
|
|
||||||
c.Redirect(302, "https://github.com/login/oauth/authorize?"+urlValues.Encode())
|
|
||||||
} else {
|
|
||||||
common.ErrorStrResp(c, "github Login not enabled", 403)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var githubClient = resty.New().SetRetryCount(3)
|
|
||||||
|
|
||||||
func GithubLoginCallback(c *gin.Context) {
|
|
||||||
argument := c.Query("method")
|
|
||||||
callbackUrl := c.Query("callback_url")
|
|
||||||
if argument == "get_github_id" || argument == "github_login" {
|
|
||||||
enabled, err := db.GetSettingItemByKey("github_login_enabled")
|
|
||||||
clientId, err := db.GetSettingItemByKey("github_client_id")
|
|
||||||
clientSecret, err := db.GetSettingItemByKey("github_client_secrets")
|
|
||||||
if err != nil {
|
|
||||||
common.ErrorResp(c, err, 400)
|
|
||||||
return
|
|
||||||
} else if enabled.Value == "true" {
|
|
||||||
callbackCode := c.Query("code")
|
|
||||||
if callbackCode == "" {
|
|
||||||
common.ErrorStrResp(c, "No code provided", 400)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp, err := githubClient.R().SetHeader("content-type", "application/json").
|
|
||||||
SetBody(map[string]string{
|
|
||||||
"client_id": clientId.Value,
|
|
||||||
"client_secret": clientSecret.Value,
|
|
||||||
"code": callbackCode,
|
|
||||||
"redirect_uri": common.GetApiUrl(c.Request) + "/api/auth/github_callback",
|
|
||||||
}).Post("https://github.com/login/oauth/access_token")
|
|
||||||
if err != nil {
|
|
||||||
common.ErrorResp(c, err, 400)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
accessToken := utils.Json.Get(resp.Body(), "access_token").ToString()
|
|
||||||
resp, err = githubClient.R().SetHeader("Authorization", "Bearer "+accessToken).
|
|
||||||
Get("https://api.github.com/user")
|
|
||||||
ghUserID := utils.Json.Get(resp.Body(), "id").ToInt()
|
|
||||||
if argument == "get_github_id" {
|
|
||||||
c.Redirect(302, callbackUrl+"?githubID="+strconv.Itoa(ghUserID))
|
|
||||||
}
|
|
||||||
if argument == "github_login" {
|
|
||||||
user, err := db.GetUserByGithubID(ghUserID)
|
|
||||||
if err != nil {
|
|
||||||
common.ErrorResp(c, err, 400)
|
|
||||||
}
|
|
||||||
token, err := common.GenerateToken(user.Username)
|
|
||||||
withParams := c.Query("with_params")
|
|
||||||
if withParams == "true" {
|
|
||||||
c.Redirect(302, callbackUrl+"&token="+token)
|
|
||||||
} else if withParams == "false" {
|
|
||||||
c.Redirect(302, callbackUrl+"?token="+token)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
common.ErrorResp(c, errors.New("invalid request"), 500)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
181
server/handles/ssologin.go
Normal file
181
server/handles/ssologin.go
Normal file
@ -0,0 +1,181 @@
|
|||||||
|
package handles
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"net/url"
|
||||||
|
|
||||||
|
"github.com/alist-org/alist/v3/internal/conf"
|
||||||
|
"github.com/alist-org/alist/v3/internal/db"
|
||||||
|
"github.com/alist-org/alist/v3/internal/setting"
|
||||||
|
"github.com/alist-org/alist/v3/pkg/utils"
|
||||||
|
"github.com/alist-org/alist/v3/server/common"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/go-resty/resty/v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
func SSOLoginRedirect(c *gin.Context) {
|
||||||
|
method := c.Query("method")
|
||||||
|
enabled := setting.GetBool(conf.SSOLoginEnabled)
|
||||||
|
clientId := setting.GetStr(conf.SSOClientId)
|
||||||
|
platform := setting.GetStr(conf.SSOLoginplatform)
|
||||||
|
var r_url string
|
||||||
|
var redirect_uri string
|
||||||
|
if enabled {
|
||||||
|
urlValues := url.Values{}
|
||||||
|
if method == "" {
|
||||||
|
common.ErrorStrResp(c, "no method provided", 400)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
redirect_uri = common.GetApiUrl(c.Request) + "/api/auth/sso_callback" + "?method=" + method
|
||||||
|
urlValues.Add("response_type", "code")
|
||||||
|
urlValues.Add("redirect_uri", redirect_uri)
|
||||||
|
urlValues.Add("client_id", clientId)
|
||||||
|
switch platform {
|
||||||
|
case "Github":
|
||||||
|
r_url = "https://github.com/login/oauth/authorize?"
|
||||||
|
urlValues.Add("scope", "read:user")
|
||||||
|
case "Microsoft":
|
||||||
|
r_url = "https://login.microsoftonline.com/common/oauth2/v2.0/authorize?"
|
||||||
|
urlValues.Add("scope", "user.read")
|
||||||
|
urlValues.Add("response_mode", "query")
|
||||||
|
case "Google":
|
||||||
|
r_url = "https://accounts.google.com/o/oauth2/v2/auth?"
|
||||||
|
urlValues.Add("scope", "https://www.googleapis.com/auth/userinfo.profile")
|
||||||
|
case "Dingtalk":
|
||||||
|
r_url = "https://login.dingtalk.com/oauth2/auth?"
|
||||||
|
urlValues.Add("scope", "openid")
|
||||||
|
urlValues.Add("prompt", "consent")
|
||||||
|
urlValues.Add("response_type", "code")
|
||||||
|
default:
|
||||||
|
common.ErrorStrResp(c, "invalid platform", 400)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.Redirect(302, r_url+urlValues.Encode())
|
||||||
|
} else {
|
||||||
|
common.ErrorStrResp(c, "Single sign-on is not enabled", 403)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var ssoClient = resty.New().SetRetryCount(3)
|
||||||
|
|
||||||
|
func SSOLoginCallback(c *gin.Context) {
|
||||||
|
argument := c.Query("method")
|
||||||
|
if argument == "get_sso_id" || argument == "sso_get_token" {
|
||||||
|
enabled := setting.GetBool(conf.SSOLoginEnabled)
|
||||||
|
clientId := setting.GetStr(conf.SSOClientId)
|
||||||
|
platform := setting.GetStr(conf.SSOLoginplatform)
|
||||||
|
clientSecret := setting.GetStr(conf.SSOClientSecret)
|
||||||
|
var url1, url2, additionalbody, scope, authstring, idstring string
|
||||||
|
switch platform {
|
||||||
|
case "Github":
|
||||||
|
url1 = "https://github.com/login/oauth/access_token"
|
||||||
|
url2 = "https://api.github.com/user"
|
||||||
|
additionalbody = ""
|
||||||
|
authstring = "code"
|
||||||
|
scope = "read:user"
|
||||||
|
idstring = "id"
|
||||||
|
case "Microsoft":
|
||||||
|
url1 = "https://login.microsoftonline.com/common/oauth2/v2.0/token"
|
||||||
|
url2 = "https://graph.microsoft.com/v1.0/me"
|
||||||
|
additionalbody = "&grant_type=authorization_code"
|
||||||
|
scope = "user.read"
|
||||||
|
authstring = "code"
|
||||||
|
idstring = "id"
|
||||||
|
case "Google":
|
||||||
|
url1 = "https://oauth2.googleapis.com/token"
|
||||||
|
url2 = "https://www.googleapis.com/oauth2/v1/userinfo"
|
||||||
|
additionalbody = "&grant_type=authorization_code"
|
||||||
|
scope = "https://www.googleapis.com/auth/userinfo.profile"
|
||||||
|
authstring = "code"
|
||||||
|
idstring = "id"
|
||||||
|
case "Dingtalk":
|
||||||
|
url1 = "https://api.dingtalk.com/v1.0/oauth2/userAccessToken"
|
||||||
|
url2 = "https://api.dingtalk.com/v1.0/contact/users/me"
|
||||||
|
authstring = "authCode"
|
||||||
|
idstring = "unionId"
|
||||||
|
default:
|
||||||
|
common.ErrorStrResp(c, "invalid platform", 400)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if enabled {
|
||||||
|
callbackCode := c.Query(authstring)
|
||||||
|
if callbackCode == "" {
|
||||||
|
common.ErrorStrResp(c, "No code provided", 400)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var resp *resty.Response
|
||||||
|
var err error
|
||||||
|
if platform == "Dingtalk" {
|
||||||
|
resp, err = ssoClient.R().SetHeader("content-type", "application/json").SetHeader("Accept", "application/json").
|
||||||
|
SetBody(map[string]string{
|
||||||
|
"clientId": clientId,
|
||||||
|
"clientSecret": clientSecret,
|
||||||
|
"code": callbackCode,
|
||||||
|
"grantType": "authorization_code",
|
||||||
|
}).
|
||||||
|
Post(url1)
|
||||||
|
} else {
|
||||||
|
resp, err = ssoClient.R().SetHeader("content-type", "application/x-www-form-urlencoded").SetHeader("Accept", "application/json").
|
||||||
|
SetBody("client_id=" + clientId + "&client_secret=" + clientSecret + "&code=" + callbackCode + "&redirect_uri=" + common.GetApiUrl(c.Request) + "/api/auth/sso_callback?method=" + argument + "&scope=" + scope + additionalbody).
|
||||||
|
Post(url1)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
common.ErrorResp(c, err, 400)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if platform == "Dingtalk" {
|
||||||
|
accessToken := utils.Json.Get(resp.Body(), "accessToken").ToString()
|
||||||
|
resp, err = ssoClient.R().SetHeader("x-acs-dingtalk-access-token", accessToken).
|
||||||
|
Get(url2)
|
||||||
|
} else {
|
||||||
|
accessToken := utils.Json.Get(resp.Body(), "access_token").ToString()
|
||||||
|
resp, err = ssoClient.R().SetHeader("Authorization", "Bearer "+accessToken).
|
||||||
|
Get(url2)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
common.ErrorResp(c, err, 400)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
UserID := utils.Json.Get(resp.Body(), idstring).ToString()
|
||||||
|
if UserID == "0" {
|
||||||
|
common.ErrorResp(c, errors.New("error occured"), 400)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if argument == "get_sso_id" {
|
||||||
|
html := fmt.Sprintf(`<!DOCTYPE html>
|
||||||
|
<head></head>
|
||||||
|
<body>
|
||||||
|
<script>
|
||||||
|
window.opener.postMessage({"sso_id": "%s"}, "*")
|
||||||
|
window.close()
|
||||||
|
</script>
|
||||||
|
</body>`, UserID)
|
||||||
|
c.Data(200, "text/html; charset=utf-8", []byte(html))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if argument == "sso_get_token" {
|
||||||
|
user, err := db.GetUserBySSOID(UserID)
|
||||||
|
if err != nil {
|
||||||
|
common.ErrorResp(c, err, 400)
|
||||||
|
}
|
||||||
|
token, err := common.GenerateToken(user.Username)
|
||||||
|
if err != nil {
|
||||||
|
common.ErrorResp(c, err, 400)
|
||||||
|
}
|
||||||
|
html := fmt.Sprintf(`<!DOCTYPE html>
|
||||||
|
<head></head>
|
||||||
|
<body>
|
||||||
|
<script>
|
||||||
|
window.opener.postMessage({"token":"%s"}, "*")
|
||||||
|
window.close()
|
||||||
|
</script>
|
||||||
|
</body>`, token)
|
||||||
|
c.Data(200, "text/html; charset=utf-8", []byte(html))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
common.ErrorResp(c, errors.New("invalid request"), 500)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -43,8 +43,8 @@ func Init(e *gin.Engine) {
|
|||||||
auth.POST("/auth/2fa/verify", handles.Verify2FA)
|
auth.POST("/auth/2fa/verify", handles.Verify2FA)
|
||||||
|
|
||||||
// github auth
|
// github auth
|
||||||
api.GET("/auth/github", handles.GithubLoginRedirect)
|
api.GET("/auth/sso", handles.SSOLoginRedirect)
|
||||||
api.GET("/auth/github_callback", handles.GithubLoginCallback)
|
api.GET("/auth/sso_callback", handles.SSOLoginCallback)
|
||||||
|
|
||||||
// no need auth
|
// no need auth
|
||||||
public := api.Group("/public")
|
public := api.Group("/public")
|
||||||
|
@ -68,7 +68,7 @@ func WebDAVAuth(c *gin.Context) {
|
|||||||
c.Abort()
|
c.Abort()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !user.CanWebdavRead() {
|
if user.Disabled || !user.CanWebdavRead() {
|
||||||
if c.Request.Method == "OPTIONS" {
|
if c.Request.Method == "OPTIONS" {
|
||||||
c.Set("user", guest)
|
c.Set("user", guest)
|
||||||
c.Next()
|
c.Next()
|
||||||
|
Reference in New Issue
Block a user