Skip to content

Commit

Permalink
Update user authentication logic
Browse files Browse the repository at this point in the history
  • Loading branch information
minpeter committed Jan 11, 2024
1 parent 9f1886e commit b4a185f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion auth/oauth/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ var OauthStateCache = cache2go.Cache("oauthState")

func GithubConfig() oauth2.Config {

if os.Getenv("OAUTH_REDIRECT_URL") == "" {
os.Setenv("OAUTH_REDIRECT_URL", "http://localhost:4000")
}

GitHubLoginConfig = oauth2.Config{
RedirectURL: "http://localhost:4000/api/auth/callback/github",
RedirectURL: os.Getenv("OAUTH_REDIRECT_URL") + "/api/auth/callback/github",
ClientID: os.Getenv("GITHUB_CLIENT_ID"),
ClientSecret: os.Getenv("GITHUB_CLIENT_SECRET"),
Scopes: []string{"user"},
Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func main() {

fmt.Println("\n\n===== ENVIRONMENT VARIABLES =====")
fmt.Println("PORT: port to run the server on (optional, default 4000)")
fmt.Println("OAUTH_REDIRECT_URL: OAuth redirect URL (required, default http://localhost:4000)")
fmt.Println("GITHUB_CLIENT_ID: GitHub OAuth client ID (required)")
fmt.Printf("GITHUB_CLIENT_SECRET: GitHub OAuth client secret (required)\n\n")

Expand Down

0 comments on commit b4a185f

Please sign in to comment.