Skip to content

Commit

Permalink
Merge pull request #2 from ansrivas/as/migrate-to-v2
Browse files Browse the repository at this point in the history
Fixes issue#1; migration to fiber-v2
  • Loading branch information
Shareed2k authored Nov 28, 2020
2 parents 5e2e254 + a39bebf commit 1349488
Show file tree
Hide file tree
Showing 6 changed files with 487 additions and 156 deletions.
123 changes: 66 additions & 57 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,62 +14,62 @@ $ go get github.com/shareed2k/goth_fiber

## Supported Providers

* Amazon
* Apple
* Auth0
* Azure AD
* Battle.net
* Bitbucket
* Box
* Cloud Foundry
* Dailymotion
* Deezer
* Digital Ocean
* Discord
* Dropbox
* Eve Online
* Facebook
* Fitbit
* Gitea
* GitHub
* Gitlab
* Google
* Google+ (deprecated)
* Heroku
* InfluxCloud
* Instagram
* Intercom
* Kakao
* Lastfm
* Linkedin
* LINE
* Mailru
* Meetup
* MicrosoftOnline
* Naver
* Nextcloud
* OneDrive
* OpenID Connect (auto discovery)
* Paypal
* SalesForce
* Shopify
* Slack
* Soundcloud
* Spotify
* Steam
* Strava
* Stripe
* Tumblr
* Twitch
* Twitter
* Typetalk
* Uber
* VK
* Wepay
* Xero
* Yahoo
* Yammer
* Yandex
- Amazon
- Apple
- Auth0
- Azure AD
- Battle.net
- Bitbucket
- Box
- Cloud Foundry
- Dailymotion
- Deezer
- Digital Ocean
- Discord
- Dropbox
- Eve Online
- Facebook
- Fitbit
- Gitea
- GitHub
- Gitlab
- Google
- Google+ (deprecated)
- Heroku
- InfluxCloud
- Instagram
- Intercom
- Kakao
- Lastfm
- Linkedin
- LINE
- Mailru
- Meetup
- MicrosoftOnline
- Naver
- Nextcloud
- OneDrive
- OpenID Connect (auto discovery)
- Paypal
- SalesForce
- Shopify
- Slack
- Soundcloud
- Spotify
- Steam
- Strava
- Stripe
- Tumblr
- Twitch
- Twitter
- Typetalk
- Uber
- VK
- Wepay
- Xero
- Yahoo
- Yammer
- Yandex

## Examples

Expand All @@ -81,10 +81,19 @@ To run the example either clone the source from GitHub
```text
$ git clone [email protected]/shareed2k/goth_fiber.git
```
or use

or use for v2

```text
$ go get github.com/shareed2k/goth_fiber/v2
```

For v1

```
$ go get github.com/shareed2k/goth_fiber
```

```text
$ cd goth_fiber/examples
$ go get -v
Expand Down
16 changes: 7 additions & 9 deletions examples/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ import (
"log"
"os"

"github.com/gofiber/fiber"
"github.com/gofiber/fiber/v2"
"github.com/markbates/goth"
"github.com/markbates/goth/providers/google"

"github.com/shareed2k/goth_fiber"
"github.com/shareed2k/goth_fiber/v2"
)

func main() {
Expand All @@ -17,26 +16,25 @@ func main() {
goth.UseProviders(
google.New(os.Getenv("OAUTH_KEY"), os.Getenv("OAUTH_SECRET"), "http://127.0.0.1:8088/auth/callback"),
)

app.Get("/login", goth_fiber.BeginAuthHandler)
app.Get("/auth/callback", func(ctx *fiber.Ctx) {
app.Get("/auth/callback", func(ctx *fiber.Ctx) error {
user, err := goth_fiber.CompleteUserAuth(ctx)
if err != nil {
log.Fatal(err)
}

ctx.Send(user)
return ctx.SendString(user.Email)

})
app.Get("/logout", func(ctx *fiber.Ctx) {
app.Get("/logout", func(ctx *fiber.Ctx) error {
if err := goth_fiber.Logout(ctx); err != nil {
log.Fatal(err)
}

ctx.SendString("logout")
return ctx.SendString("logout")
})

if err := app.Listen(8088); err != nil {
if err := app.Listen(":8088"); err != nil {
log.Fatal(err)
}
}
21 changes: 16 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
module github.com/shareed2k/goth_fiber
module github.com/shareed2k/goth_fiber/v2

go 1.14
go 1.15

require (
github.com/gofiber/fiber v1.10.1
github.com/gofiber/session v1.2.0
github.com/markbates/goth v1.64.1
github.com/andybalholm/brotli v1.0.1 // indirect
github.com/gofiber/fiber/v2 v2.2.1
github.com/golang/protobuf v1.4.3 // indirect
github.com/gorilla/mux v1.7.3 // indirect
github.com/klauspost/compress v1.11.3 // indirect
github.com/kr/pretty v0.2.0 // indirect
github.com/markbates/goth v1.66.0
github.com/stretchr/testify v1.6.1 // indirect
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b // indirect
golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58 // indirect
golang.org/x/sys v0.0.0-20201126144705-a4b67b81d3d2 // indirect
google.golang.org/appengine v1.6.7 // indirect
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c // indirect
)
Loading

0 comments on commit 1349488

Please sign in to comment.