config

package module
v0.0.0-...-62869bb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 21, 2020 License: MIT Imports: 10 Imported by: 0

README

Bebop

Bebop is a simple discussion board / forum web application.

Features

  • REST API backend written in Go
  • Vue.js-based frontend
  • Two databases are supported:
    • PostgreSQL
    • MySQL
  • Three file-storage backends are supported to store user-uploaded files (e.g. avatars):
    • Local filesystem
    • Google Cloud Storage
    • Amazon S3
  • Social login (OAuth 2.0) via three providers:
    • Google
    • Facebook
    • Github
  • JSON Web Tokens (JWT) are used for user authentication in the API
  • Single binary deploy. All the static assets (frontend JavaScript & CSS files) are embedded into the binary
  • Markdown comments
  • Avatar upload, including animated GIFs. Auto-generated letter-avatars on user creation

Getting Started

  • Create a new empty database (MySQL оr PostgreSQL) that will be used as a data store and a database user with all privileges granted on this database.

  • Obtain OAuth 2.0 credentials (client_id and secret) from at least one of the providers (Google, Facebook, Github) so users can log into the web application. The OAuth callback url will be <base_url>/oauth/end/<provider>. The <base_url> is where the bebop web app will be mounted on your site and the <provider> is the lowercase provider name. For example, if base_url is https://my.website.com/forum/, then the oauth callback url for google will be https://my.website.com/forum/oauth/end/google.

  • Download and compile the bebop binary:

    $ go get -u github.com/disintegration/bebop/cmd/bebop
    
  • Inside an empty directory run:

    $ bebop init
    

    This will generate an initial configuration file "bebop.conf" inside the current dir. Edit the configuration file to set the server listen address, the base url, the database and file storage parameters, OAuth credentials, etc.

  • Run the following command to start the bebop web server.

    $ bebop start
    
  • Sign in into your web application using one of the social login providers. Then run the following command to grant admin privileges to your user.

    $ bebop add-admin <your-username>
    

Screenshots

Topics

Topics

Comments

Comments

Documentation

Overview

Package config provides the bebop configuration file structure, initialization and reading.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenKeyHex

func GenKeyHex(byteLen int) string

GenKeyHex generates a crypto-random key with byte length byteLen and hex-encodes it to a string.

func Init

func Init() (string, error)

Init generates an initial config string.

Types

type Config

type Config struct {
	Address string `hcl:"address" envconfig:"BEBOP_ADDRESS"`
	BaseURL string `hcl:"base_url" envconfig:"BEBOP_BASE_URL"`
	Title   string `hcl:"title" envconfig:"BEBOP_TITLE"`

	JWT struct {
		Secret string `hcl:"secret" envconfig:"BEBOP_JWT_SECRET"`
	} `hcl:"jwt"`

	FileStorage struct {
		Type string `hcl:"type" envconfig:"BEBOP_FILE_STORAGE_TYPE"`

		Local struct {
			Dir string `hcl:"dir" envconfig:"BEBOP_FILE_STORAGE_LOCAL_DIR"`
		} `hcl:"local"`

		GoogleCloudStorage struct {
			ServiceAccountFile string `hcl:"service_account_file" envconfig:"BEBOP_FILE_STORAGE_GCS_SERVICE_ACCOUNT_FILE"`
			Bucket             string `hcl:"bucket" envconfig:"BEBOP_FILE_STORAGE_GCS_BUCKET"`
		} `hcl:"google_cloud_storage"`

		AmazonS3 struct {
			AccessKey string `hcl:"access_key" envconfig:"BEBOP_FILE_STORAGE_S3_ACCESS_KEY"`
			SecretKey string `hcl:"secret_key" envconfig:"BEBOP_FILE_STORAGE_S3_SECRET_KEY"`
			Region    string `hcl:"region" envconfig:"BEBOP_FILE_STORAGE_S3_REGION"`
			Bucket    string `hcl:"bucket" envconfig:"BEBOP_FILE_STORAGE_S3_BUCKET"`
		} `hcl:"amazon_s3"`
	} `hcl:"file_storage"`

	Store struct {
		Type string `hcl:"type" envconfig:"BEBOP_STORE_TYPE"`

		PostgreSQL struct {
			Address     string `hcl:"address" envconfig:"BEBOP_STORE_POSTGRESQL_ADDRESS"`
			Username    string `hcl:"username" envconfig:"BEBOP_STORE_POSTGRESQL_USERNAME"`
			Password    string `hcl:"password" envconfig:"BEBOP_STORE_POSTGRESQL_PASSWORD"`
			Database    string `hcl:"database" envconfig:"BEBOP_STORE_POSTGRESQL_DATABASE"`
			SSLMode     string `hcl:"sslmode" envconfig:"BEBOP_STORE_POSTGRESQL_SSLMODE"`
			SSLRootCert string `hcl:"sslrootcert" envconfig:"BEBOP_STORE_POSTGRESQL_SSLROOTCERT"`
		} `hcl:"postgresql"`

		MySQL struct {
			Address  string `hcl:"address" envconfig:"BEBOP_STORE_MYSQL_ADDRESS"`
			Username string `hcl:"username" envconfig:"BEBOP_STORE_MYSQL_USERNAME"`
			Password string `hcl:"password" envconfig:"BEBOP_STORE_MYSQL_PASSWORD"`
			Database string `hcl:"database" envconfig:"BEBOP_STORE_MYSQL_DATABASE"`
		} `hcl:"mysql"`
	} `hcl:"store"`

	OAuth struct {
		Google struct {
			ClientID string `hcl:"client_id" envconfig:"BEBOP_OAUTH_GOOGLE_CLIENT_ID"`
			Secret   string `hcl:"secret" envconfig:"BEBOP_OAUTH_GOOGLE_SECRET"`
		} `hcl:"google"`

		Facebook struct {
			ClientID string `hcl:"client_id" envconfig:"BEBOP_OAUTH_FACEBOOK_CLIENT_ID"`
			Secret   string `hcl:"secret" envconfig:"BEBOP_OAUTH_FACEBOOK_SECRET"`
		} `hcl:"facebook"`

		Github struct {
			ClientID string `hcl:"client_id" envconfig:"BEBOP_OAUTH_GITHUB_CLIENT_ID"`
			Secret   string `hcl:"secret" envconfig:"BEBOP_OAUTH_GITHUB_SECRET"`
		} `hcl:"github"`
	} `hcl:"oauth"`
}

Config is a bebop configuration struct.

func ReadEnv

func ReadEnv() (*Config, error)

ReadEnv reads a bebop config from environment variables.

func ReadFile

func ReadFile(filename string) (*Config, error)

ReadFile reads a bebop config from file.

Directories

Path Synopsis
Package api provides an HTTP handler that handles the bebop REST API requests.
Package api provides an HTTP handler that handles the bebop REST API requests.
Package avatar provides a service that manages bebop user avatars.
Package avatar provides a service that manages bebop user avatars.
cmd
bebop
Bebop is a simple discussion board / forum web application.
Bebop is a simple discussion board / forum web application.
Package config provides the bebop configuration file structure, initialization and reading.
Package config provides the bebop configuration file structure, initialization and reading.
Package filestorage provides a file storage service that manages public web app files e.g.
Package filestorage provides a file storage service that manages public web app files e.g.
Package jwt provides a service to create and verify JWT auth tokens for the bebop web app.
Package jwt provides a service to create and verify JWT auth tokens for the bebop web app.
Package oauth provides an HTTP handler to handle OAuth2 redirect and callback requests for the bebop web app.
Package oauth provides an HTTP handler to handle OAuth2 redirect and callback requests for the bebop web app.
Package static provides http handlers for serving static files from the embedded filesystem or from a local directory.
Package static provides http handlers for serving static files from the embedded filesystem or from a local directory.
Package store provides a bebop data store interface.
Package store provides a bebop data store interface.
mysql
Package mysql provides a MySQL implementation of the bebop data store interface.
Package mysql provides a MySQL implementation of the bebop data store interface.
postgresql
Package postgresql provides a PostgreSQL implementation of the bebop data store interface.
Package postgresql provides a PostgreSQL implementation of the bebop data store interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL