Skip to content

Commit 5d0f51e

Browse files
authored
adding get provider name support for chi router (#569)
1 parent 4961631 commit 5d0f51e

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module github.com/markbates/goth
33
go 1.18
44

55
require (
6+
github.com/go-chi/chi/v5 v5.1.0
67
github.com/golang-jwt/jwt/v4 v4.2.0
78
github.com/gorilla/mux v1.6.2
89
github.com/gorilla/pat v0.0.0-20180118222023-199c85a7f6d1

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
99
github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo=
1010
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs=
1111
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0=
12+
github.com/go-chi/chi/v5 v5.1.0 h1:acVI1TYaD+hhedDJ3r54HyA6sExp3HfXq7QWEEY/xMw=
13+
github.com/go-chi/chi/v5 v5.1.0/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
1214
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
1315
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
1416
github.com/golang-jwt/jwt/v4 v4.2.0 h1:besgBTC8w8HjP6NzQdxwKH9Z5oQMZ24ThTrHp3cZ8eU=

gothic/gothic.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"os"
2323
"strings"
2424

25+
"github.com/go-chi/chi/v5"
2526
"github.com/gorilla/mux"
2627
"github.com/gorilla/sessions"
2728
"github.com/markbates/goth"
@@ -282,6 +283,11 @@ func getProviderName(req *http.Request) (string, error) {
282283
return p, nil
283284
}
284285

286+
// try to get it from the url param "provider", when req is routed through 'chi'
287+
if p := chi.URLParam(req, "provider"); p != "" {
288+
return p, nil
289+
}
290+
285291
// try to get it from the go-context's value of providerContextKey key
286292
if p, ok := req.Context().Value(ProviderParamKey).(string); ok {
287293
return p, nil

0 commit comments

Comments
 (0)