Note: We've made substantial changes to our packages.json, and have moved all of the build scripts there. Below needs to be updated.
npm install --production
npm run build
install go
brew install go
install packages
go mod tidy
Populate .env.production.local
Current version includes:
MONGO_DB_URL=
MONGO_DB_PASSWORD=
MONGO_DB_NAME=
MONGO_COLLECTION_NAME=
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
FACEBOOK_APP_ID=
FACEBOOK_APP_SECRET=
SMTP_USER=
SMTP_PASS=
SECRET_KEY=
build server binary
go build -o build
./server
Server should now be running on http://localhost:8080
Head to http://localhost:8080/web/ for an example of the current authorization methods
You can find the front end code in /auth-example-frontend/main.js
Open routes:
/web
, /register
, /auth
, /avatar
Protected routes:
/private_data
You can register to a mongodb store with a POST request to /register
with a body such as:
{
"username": "user",
"password": "secret"
}
Authorization handlers can be access via POST requests to /auth/<handler>
You can login via a check against a mongodb store with a POST request in the form
http://localhost:8080/auth/mongo/login?id=sweepstakes&user=<username>&passwd=<password>
Using a valid username and password combo (such as test
& secret
) will give you a response including your name, id and avatar, and set both a JWT and XSRF-TOKEN
You can login with any username with a POST request in the form
http://localhost:8080/auth/anonymous/login?id=sweepstakes&user=<username>
You will again receive a response including your name, id and avatar, and set both a JWT and XSRF-TOKEN, but clients with ids prepended with anonymous
are not permitted along the protected routes
You can only use these providers if you've set the relevant environment variables, and the server is deployed on a domain that has been registered and verified / gone through the steps required.
For development purposes only an dummy oauth2 dev server is provided. You can login with any username. Notice that you'll get more info if you login with dev_admin
as the username.
Here's the current model for the User entity. At this time I'm not handling email, just username and password
// User is a reduced model of objects that will be retrived or inserted into the DB
type User struct {
ID primitive.ObjectID `bson:"_id"`
Created_at time.Time `json:"created_at"`
Updated_at time.Time `json:"updated_at"`
Username string `json:"Username"`
Password string `json:"Password"`
User_id string `json:"user_id"`
//Email string `json:"email"`
//Nation string `json:"nation"`
}
I have yet to add a data model for Teams.
Thank you so much to the creators of github.com/go-pkgz and github.com/go-chi
- Add Nations data model
- Add logic for allocating nations
- Start building out required features
- Consider local copy of World Cup 2022 API, + cronjob to populate the database within rate limits
- Consider rate limiting / throttling:
- registration attempts
- login attempts