external site url
This commit is contained in:
@@ -2,6 +2,18 @@
|
||||
|
||||
Comment engine
|
||||
|
||||
## Install
|
||||
|
||||
### Backend
|
||||
|
||||
- copy provided docker-compose.yml and customize for your needs
|
||||
- make sure you **don't keep** `DEV=true` for any non-development deployments
|
||||
- pull and start `docker compose pull && docker compose up`
|
||||
|
||||
### Frontend
|
||||
|
||||
TBD
|
||||
|
||||
## API
|
||||
|
||||
### Authorization
|
||||
|
||||
@@ -25,6 +25,7 @@ var opts struct {
|
||||
GithubCID string `long:"github-cid" env:"REMARK_GITHUB_CID" description:"Github OAuth client ID"`
|
||||
GithubCSEC string `long:"github-csec" env:"REMARK_GITHUB_CSEC" description:"Github OAuth client secret"`
|
||||
|
||||
SiteURL string `long:"site-url" env:"REMARK_URL" default:"http://remark.umputun.com:8080" description:"url to remark site"`
|
||||
Admins []string `long:"admin" env:"ADMIN" default:"umputun@gmail.com" description:"admin(s) names" env-delim:","`
|
||||
DevMode bool `long:"dev" env:"DEV" description:"development mode, no auth enforced"`
|
||||
Dbg bool `long:"dbg" env:"DEBUG" description:"debug mode"`
|
||||
@@ -60,11 +61,13 @@ func main() {
|
||||
Cid: opts.GoogleCID,
|
||||
Csecret: opts.GoogleCSEC,
|
||||
SessionStore: sessionStore,
|
||||
SiteURL: opts.SiteURL,
|
||||
}),
|
||||
AuthGithub: auth.NewGithub(auth.Params{
|
||||
Cid: opts.GithubCID,
|
||||
Csecret: opts.GithubCSEC,
|
||||
SessionStore: sessionStore,
|
||||
SiteURL: opts.SiteURL,
|
||||
}),
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ type Params struct {
|
||||
Cid string
|
||||
Csecret string
|
||||
SessionStore *sessions.FilesystemStore
|
||||
SiteURL string
|
||||
}
|
||||
|
||||
// newProvider makes auth for given provider
|
||||
|
||||
@@ -14,7 +14,7 @@ func NewGoogle(p Params) *Provider {
|
||||
return initProvider(p, Provider{
|
||||
Name: "google",
|
||||
Endpoint: google.Endpoint,
|
||||
RedirectURL: "http://remark.umputun.com:8080/auth/google",
|
||||
RedirectURL: p.SiteURL + "/auth/google",
|
||||
Scopes: []string{"https://www.googleapis.com/auth/userinfo.email"},
|
||||
InfoURL: "https://www.googleapis.com/oauth2/v3/userinfo",
|
||||
FilesystemStore: p.SessionStore,
|
||||
@@ -39,7 +39,7 @@ func NewGithub(p Params) *Provider {
|
||||
return initProvider(p, Provider{
|
||||
Name: "github",
|
||||
Endpoint: github.Endpoint,
|
||||
RedirectURL: "http://remark.umputun.com:8080/auth/github",
|
||||
RedirectURL: p.SiteURL + "/auth/github",
|
||||
Scopes: []string{"user:email"},
|
||||
InfoURL: "https://api.github.com/user",
|
||||
FilesystemStore: p.SessionStore,
|
||||
|
||||
+5
-5
@@ -49,11 +49,11 @@ func (s *Server) Run() {
|
||||
rapi.Get("/last/{max}", s.getLastComments)
|
||||
rapi.Get("/count", s.getCountCtrl)
|
||||
|
||||
rapi.With(Auth(s.SessionStore, s.Admins, s.DevMode)).Group(func(r chi.Router) {
|
||||
r.Post("/comment", s.createCommentCtrl)
|
||||
r.Get("/user", s.getUserInfo)
|
||||
r.Put("/vote/{id}", s.voteCtrl)
|
||||
r.With(AdminOnly).Delete("/comment/{id}", s.deleteCommentCtrl)
|
||||
rapi.With(Auth(s.SessionStore, s.Admins, s.DevMode)).Group(func(rauth chi.Router) {
|
||||
rauth.Post("/comment", s.createCommentCtrl)
|
||||
rauth.Get("/user", s.getUserInfo)
|
||||
rauth.Put("/vote/{id}", s.voteCtrl)
|
||||
rauth.With(AdminOnly).Delete("/comment/{id}", s.deleteCommentCtrl)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
+3
-5
@@ -15,18 +15,16 @@ services:
|
||||
max-size: "10m"
|
||||
max-file: "5"
|
||||
|
||||
environment:
|
||||
- MHOST=${MHOST}
|
||||
|
||||
ports:
|
||||
- "8080:8080"
|
||||
|
||||
environment:
|
||||
- REMARK_URL=http://remark.umputun.com:8080
|
||||
- BOLTDB_FILE=/srv/var/remark.db
|
||||
- SESSION_STORE=/srv/var
|
||||
- DEV=true
|
||||
- DEV=true # development mode flag. It turns authentication off, be careful!
|
||||
- DEBUG=true
|
||||
|
||||
volumes:
|
||||
- ./var:/srv/var
|
||||
|
||||
- ./web:/srv/web # maps web directory directly and propagate local changes to container without redeploy
|
||||
|
||||
Reference in New Issue
Block a user