OpenIDConnect's New method returns "Provider, error" instead of just "Provider"
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 6.6k
- Forks
- 631
- PR merge metrics
- No merged PRs in 30d
Description
For users of [Buffalo](https://github.com/gobuffalo/buffalo) along with the `openidConnect` provider, the default generated code will always contain an error. See this snippet:
```go
package actions
import (
"fmt"
"os"
"github.com/gobuffalo/buffalo"
"github.com/markbates/goth"
"github.com/markbates/goth/gothic"
"github.com/markbates/goth/providers/openidConnect"
)
func init() {
gothic.Store = App().SessionStore
goth.UseProviders(
openidConnect.New(os.Getenv("OPENIDCONNECT_KEY"), os.Getenv("OPENIDCONNECT_SECRET"), fmt.Sprintf("%s%s", App().Host, "/auth/openidconnect/callback"), "REDACT", "REDACT"),
)
}
```
The `goth.UseProviders` call expects *only* a `Provider` to be passed, but in the case of `openidConnect.New()`, we end up passing a `Provider` and `error` since that's what `openidConnect.New()` returns, so the code fails to compile.
One fix for this is to add a new function with a different name that's similar to the existing [`func New(clientKey, secret, callbackURL, openIDAutoDiscoveryURL string, scopes ...string) (*Provider, error)`](https://github.com/markbates/goth/blob/master/providers/openidConnect/openidConnect.go#L86), but that does not return an error (you could instead `panic`, or use some alternative way of dealing with the error).
That being said, I'd be happy to hear from anyone who has an alternative solution.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in providers/openidConnect/openidConnect.go at New and compare its return signature with the goth.UseProviders call shown in the issue. Review the generated Buffalo OpenID Connect setup and decide how the API should handle initialization errors; done means the generated setup can compile while retaining an explicit error-handling path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- authentication, backend
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100