Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
e72719f6b0 | |||
34bcc3d603 | |||
31556d3a6b | |||
5244119ffe | |||
03bbf440c7 |
@ -2,6 +2,7 @@ pipeline:
|
|||||||
build:
|
build:
|
||||||
when:
|
when:
|
||||||
event: [push, pull_request, tag, deployment]
|
event: [push, pull_request, tag, deployment]
|
||||||
|
|
||||||
image: golang:latest
|
image: golang:latest
|
||||||
commands:
|
commands:
|
||||||
- go build -o segfautils
|
- go build -o segfautils
|
||||||
|
15
api/oauth.go
Normal file
15
api/oauth.go
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package api
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/ProjectSegfault/segfautils/config"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
clientID = config.OAuthClientID()
|
||||||
|
clientSecret = config.OAuthClientSecret()
|
||||||
|
redirectURL = config.OAuthRedirectURL()
|
||||||
|
authURL = config.OAuthURL()
|
||||||
|
)
|
||||||
|
|
||||||
|
func LoginOAuth() {
|
||||||
|
}
|
18
config/oauthclientid.go
Normal file
18
config/oauthclientid.go
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
package config
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
|
||||||
|
"github.com/spf13/viper"
|
||||||
|
)
|
||||||
|
|
||||||
|
func OAuthClientID() string {
|
||||||
|
viper.SetConfigName("config")
|
||||||
|
viper.AddConfigPath("./data")
|
||||||
|
err := viper.ReadInConfig()
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error reading config for getting oauth.client_id", err.Error())
|
||||||
|
}
|
||||||
|
result := viper.GetString("oauth.client_id")
|
||||||
|
return result
|
||||||
|
}
|
18
config/oauthclientsecret.go
Normal file
18
config/oauthclientsecret.go
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
package config
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
|
||||||
|
"github.com/spf13/viper"
|
||||||
|
)
|
||||||
|
|
||||||
|
func OAuthClientSecret() string {
|
||||||
|
viper.SetConfigName("config")
|
||||||
|
viper.AddConfigPath("./data")
|
||||||
|
err := viper.ReadInConfig()
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error reading config for getting oauth.client_secret", err.Error())
|
||||||
|
}
|
||||||
|
result := viper.GetString("oauth.client_secret")
|
||||||
|
return result
|
||||||
|
}
|
18
config/oauthredirect.go
Normal file
18
config/oauthredirect.go
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
package config
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
|
||||||
|
"github.com/spf13/viper"
|
||||||
|
)
|
||||||
|
|
||||||
|
func OAuthRedirectURL() string {
|
||||||
|
viper.SetConfigName("config")
|
||||||
|
viper.AddConfigPath("./data")
|
||||||
|
err := viper.ReadInConfig()
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error reading config for getting oauth.redirect_url", err.Error())
|
||||||
|
}
|
||||||
|
result := viper.GetString("oauth.redirect_url")
|
||||||
|
return result
|
||||||
|
}
|
18
config/oauthurl.go
Normal file
18
config/oauthurl.go
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
package config
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
|
||||||
|
"github.com/spf13/viper"
|
||||||
|
)
|
||||||
|
|
||||||
|
func OAuthURL() string {
|
||||||
|
viper.SetConfigName("config")
|
||||||
|
viper.AddConfigPath("./data")
|
||||||
|
err := viper.ReadInConfig()
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error reading config for getting oauth.auth_url", err.Error())
|
||||||
|
}
|
||||||
|
result := viper.GetString("oauth.auth_url")
|
||||||
|
return result
|
||||||
|
}
|
@ -7,6 +7,12 @@ auth_token = "YOURAUTHTOKEN"
|
|||||||
site_key = "YOURSITEKEY"
|
site_key = "YOURSITEKEY"
|
||||||
secret_key = "YOURSECRETKEY"
|
secret_key = "YOURSECRETKEY"
|
||||||
|
|
||||||
|
[oauth]
|
||||||
|
client_id = "YOURCLIENTID"
|
||||||
|
client_secret = "YOURCLIENTSECRET"
|
||||||
|
redirect_url = "YOURREDIRECTURL"
|
||||||
|
auth_url = "YOURAUTHURL"
|
||||||
|
|
||||||
[options]
|
[options]
|
||||||
announce = true
|
announce = true
|
||||||
form = false
|
form = false
|
||||||
|
8
data/lol.toml
Normal file
8
data/lol.toml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
[segfautils]
|
||||||
|
port = 6893
|
||||||
|
webhook_url = "https://127.0.0.1:8080/segfautils"
|
||||||
|
auth_token = "121212"
|
||||||
|
|
||||||
|
[hcaptcha]
|
||||||
|
site_key = "lol"
|
||||||
|
secret_key = "lol2"
|
5
go.mod
5
go.mod
@ -5,6 +5,7 @@ go 1.18
|
|||||||
require (
|
require (
|
||||||
github.com/fsnotify/fsnotify v1.5.4 // indirect
|
github.com/fsnotify/fsnotify v1.5.4 // indirect
|
||||||
github.com/goccy/go-json v0.9.10 // indirect
|
github.com/goccy/go-json v0.9.10 // indirect
|
||||||
|
github.com/golang/protobuf v1.5.2 // indirect
|
||||||
github.com/gorilla/feeds v1.1.1 // indirect
|
github.com/gorilla/feeds v1.1.1 // indirect
|
||||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||||
github.com/kataras/hcaptcha v0.0.0-20200711031247-2927d4faf32f // indirect
|
github.com/kataras/hcaptcha v0.0.0-20200711031247-2927d4faf32f // indirect
|
||||||
@ -18,8 +19,12 @@ require (
|
|||||||
github.com/spf13/pflag v1.0.5 // indirect
|
github.com/spf13/pflag v1.0.5 // indirect
|
||||||
github.com/spf13/viper v1.12.0 // indirect
|
github.com/spf13/viper v1.12.0 // indirect
|
||||||
github.com/subosito/gotenv v1.3.0 // indirect
|
github.com/subosito/gotenv v1.3.0 // indirect
|
||||||
|
golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e // indirect
|
||||||
|
golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1 //indirect
|
||||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
|
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
|
||||||
golang.org/x/text v0.3.7 // indirect
|
golang.org/x/text v0.3.7 // indirect
|
||||||
|
google.golang.org/appengine v1.6.7 // indirect
|
||||||
|
google.golang.org/protobuf v1.28.0 // indirect
|
||||||
gopkg.in/ini.v1 v1.66.4 // indirect
|
gopkg.in/ini.v1 v1.66.4 // indirect
|
||||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
|
13
go.sum
13
go.sum
@ -86,6 +86,9 @@ github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvq
|
|||||||
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
|
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
|
||||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||||
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||||
|
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||||
|
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
|
||||||
|
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||||
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||||
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||||
@ -97,6 +100,7 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
|
|||||||
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
|
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
||||||
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
|
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
|
||||||
github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
|
github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
|
||||||
@ -244,6 +248,8 @@ golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwY
|
|||||||
golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||||
golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||||
|
golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e h1:TsQ7F31D3bUCLeqPT0u+yjp1guoArKaNKmCr22PYgTQ=
|
||||||
|
golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
@ -253,6 +259,8 @@ golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ
|
|||||||
golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||||
golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||||
golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||||
|
golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1 h1:lxqLZaMad/dJHMFZH0NiNpiEZI/nhgWhe4wgzpE+MuA=
|
||||||
|
golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg=
|
||||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
@ -388,6 +396,7 @@ google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7
|
|||||||
google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
|
google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
|
||||||
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||||
google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||||
|
google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=
|
||||||
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||||
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||||
@ -451,6 +460,10 @@ google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2
|
|||||||
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||||
google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4=
|
google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4=
|
||||||
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
||||||
|
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 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
|
||||||
|
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
Web utilities for Project Segfault
|
Web utilities for Project Segfault
|
||||||
|
|
||||||
## What does it do?
|
## What does it do?
|
||||||
For now it powers our contact form. In the future we will expand our APIs so you can do more cool things.
|
For now it powers our contact form and our announcements page. In the future we will expand our APIs so you can do more cool things. (We currently do not have any new idea so please open issues and give us suggestions!!)
|
||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
|
|
||||||
@ -20,8 +20,8 @@ If you're using Portainer, you should know how to add Segfautils.
|
|||||||
```
|
```
|
||||||
git clone https://github.com/ProjectSegfault/segfautils
|
git clone https://github.com/ProjectSegfault/segfautils
|
||||||
cd segfautils/
|
cd segfautils/
|
||||||
# You need to add the environment HCAPTCHA_SITE_KEY, HCAPTCHA_SECRET_KEY, SEGFAUTILS_WEBHOOK_URL and SEGFAUTILS_PORT.
|
# You need to config file located in data/config.toml.
|
||||||
go run main.go # Run this when you've done above, and you're planning on developing, if not, do below
|
go run main.go # Run this when you've done above, and you're planning on developing, if not, do below
|
||||||
go build . -o segfautils
|
go build . -o segfautils
|
||||||
./segfautils
|
./segfautils
|
||||||
```
|
```
|
||||||
|
@ -2,37 +2,78 @@
|
|||||||
package utils
|
package utils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
"github.com/ProjectSegfault/segfautils/config"
|
var (
|
||||||
|
is = 0
|
||||||
|
arrName = [9]string{"Port", "Authentication token", "Webhook URL", "HCaptcha secret", "Hcaptcha site key", "OAuth client ID", "OAuth client secret", "OAuth redirect URL", "OAuth athentication URL"}
|
||||||
|
arrCfg = [9]string{"0", "YOURAUTHTOKEN", "YOURWEBHOOKURL", "YOURSECRETKEY", "YOURSITEKEY", "YOURCLIENTID", "YOURCLIENTSECRET", "YOURREDIRECTURL", "YOURAUTHURL"}
|
||||||
|
testCfg = [9]string{"config.Authtoken()", "config.WebhookURL()", "config.HCaptchaSecretKey()", "config.HCaptchaSiteKey()", "config.OAuthClientID()", "config.OAuthClientSecret()", "config.OAuthRedirectURL()", "config.OAuthURL()"}
|
||||||
)
|
)
|
||||||
|
|
||||||
func CheckConfig() {
|
func CheckConfig() {
|
||||||
if config.Port() == "0" {
|
|
||||||
log.Fatal("[Segfautils] ❌ You need to set the port you'd like to use in the config file. Check documentation for more information.")
|
for i := 0; i < 8; i++ {
|
||||||
} else {
|
if testCfg[i] == arrCfg[i] || testCfg[i] == "" {
|
||||||
log.Println("[Segfautils] ✅ segfautils.port is set to", config.Port())
|
fmt.Println(arrCfg[i])
|
||||||
|
is = i
|
||||||
|
Fail()
|
||||||
|
} else {
|
||||||
|
fmt.Println(arrCfg[i])
|
||||||
|
fmt.Println(testCfg[i])
|
||||||
|
is = i
|
||||||
|
Check()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if config.AuthToken() == "YOURAUTHTOKEN" || config.AuthToken() == "" {
|
}
|
||||||
log.Fatal("[Segfautils] ❌ You need to set the authentication token you'd like to use in the config file. Check documentation for more information.")
|
|
||||||
} else {
|
/*
|
||||||
log.Println("[Segfautils] ✅ segfautils.auth_token is set!")
|
func CheckConfig() {
|
||||||
}
|
if config.Port() == "0" {
|
||||||
if config.WebhookURL() == "YOURWEBHOOKURL" || config.WebhookURL() == "" {
|
Fail()
|
||||||
log.Fatal("[Segfautils] ❌ You need to set the Webhook URL you'd like to use in the config file. Check documentation for more information.")
|
} else {
|
||||||
} else {
|
Check()
|
||||||
log.Println("[Segfautils] ✅ segfautils.webhook_url is set!")
|
}
|
||||||
}
|
if config.AuthToken() == "YOURAUTHTOKEN" || config.AuthToken() == "" {
|
||||||
// Hcaptcha stuff
|
log.Fatal("[Segfautils] ❌ You need to set the authentication token you'd like to use in the config file. Check documentation for more information.")
|
||||||
if config.HCaptchaSecretKey() == "YOURSECRETKEY" || config.HCaptchaSecretKey() == "" {
|
} else {
|
||||||
log.Fatal("[Segfautils] ❌ You need to set the HCaptcha secret you'd like to use in the config file. Check documentation for more information.")
|
log.Println("[Segfautils] ✅ segfautils.auth_token is set!")
|
||||||
} else {
|
}
|
||||||
log.Println("[Segfautils] ✅ segfautils.hcaptcha_secret is set!")
|
if config.WebhookURL() == "YOURWEBHOOKURL" || config.WebhookURL() == "" {
|
||||||
}
|
log.Fatal("[Segfautils] ❌ You need to set the Webhook URL you'd like to use in the config file. Check documentation for more information.")
|
||||||
if config.HCaptchaSiteKey() == "YOURSITEKEY" || config.HCaptchaSiteKey() == "" {
|
} else {
|
||||||
log.Println("[Segfautils] ⚠️ The HCaptcha site key isn't set. You don't have to, but the demo form will not work without it. Check documentation for more information.")
|
log.Println("[Segfautils] ✅ segfautils.webhook_url is set!")
|
||||||
} else {
|
}
|
||||||
log.Println("[Segfautils] ✅ hcaptcha.site_key is set!")
|
// Hcaptcha stuff
|
||||||
}
|
if config.HCaptchaSecretKey() == "YOURSECRETKEY" || config.HCaptchaSecretKey() == "" {
|
||||||
log.Println("[Segfautils] ✅ All config checks passed!")
|
log.Fatal("[Segfautils] ❌ You need to set the HCaptcha secret you'd like to use in the config file. Check documentation for more information.")
|
||||||
|
} else {
|
||||||
|
log.Println("[Segfautils] ✅ segfautils.hcaptcha_secret is set!")
|
||||||
|
}
|
||||||
|
if config.HCaptchaSiteKey() == "YOURSITEKEY" || config.HCaptchaSiteKey() == "" {
|
||||||
|
log.Println("[Segfautils] ⚠️ The HCaptcha site key isn't set. You don't have to, but the demo form will not work without it. Check documentation for more information.")
|
||||||
|
} else {
|
||||||
|
log.Println("[Segfautils] ✅ hcaptcha.site_key is set!")
|
||||||
|
}
|
||||||
|
log.Println("[segfautils] ✅ All config checks passed!")
|
||||||
|
log.Println("[segfautils] ✅ Listening at port ", config.Port())
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
func Check() {
|
||||||
|
fmt.Printf("[Segfautils] ✅ %s is set!\n", arrName[is])
|
||||||
|
}
|
||||||
|
|
||||||
|
func Fail() {
|
||||||
|
fmt.Printf("[Segfautils] ❌ You need to set the %s you'd like to use in the config file. Check documentation for more information.\n", arrName[is])
|
||||||
|
os.Exit(Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
func OptionalFail() {
|
||||||
|
fmt.Printf("[Segfautils] ⚠️ The %s isn't set. You don't have to, but the program will not be able to behave correctly. Check documentation for more information.\n", arrName[is])
|
||||||
|
}
|
||||||
|
|
||||||
|
func Error() int {
|
||||||
|
return 12
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user