chore: remove unused context in NewOpenIDProvider

BREAKING CHANGE:

- op.NewOpenIDProvider
- op.NewDynamicOpenIDProvider

The call chain of above functions did not use the context anywhere.
This change removes the context from those fucntion arguments.
This commit is contained in:
Tim Möhlmann 2023-03-08 11:43:47 +02:00 committed by Tim Möhlmann
parent 4dca29f1f9
commit 4bd2b742f9
6 changed files with 14 additions and 22 deletions

View file

@ -125,7 +125,7 @@ func newDynamicOP(ctx context.Context, storage op.Storage, key [32]byte) (*op.Pr
//this example has only static texts (in English), so we'll set the here accordingly
SupportedUILocales: []language.Tag{language.English},
}
handler, err := op.NewDynamicOpenIDProvider(ctx, "/", config, storage,
handler, err := op.NewDynamicOpenIDProvider("/", config, storage,
//we must explicitly allow the use of the http issuer
op.WithAllowInsecure(),
//as an example on how to customize an endpoint this will change the authorization_endpoint from /authorize to /auth

View file

@ -1,7 +1,6 @@
package exampleop
import (
"context"
"crypto/sha256"
"log"
"net/http"
@ -35,7 +34,7 @@ type Storage interface {
// SetupServer creates an OIDC server with Issuer=http://localhost:<port>
//
// Use one of the pre-made clients in storage/clients.go or register a new one.
func SetupServer(ctx context.Context, issuer string, storage Storage) *mux.Router {
func SetupServer(issuer string, storage Storage) *mux.Router {
// the OpenID Provider requires a 32-byte key for (token) encryption
// be sure to create a proper crypto random key and manage it securely!
key := sha256.Sum256([]byte("test"))
@ -51,7 +50,7 @@ func SetupServer(ctx context.Context, issuer string, storage Storage) *mux.Route
})
// creation of the OpenIDProvider with the just created in-memory Storage
provider, err := newOP(ctx, storage, issuer, key)
provider, err := newOP(storage, issuer, key)
if err != nil {
log.Fatal(err)
}
@ -80,7 +79,7 @@ func SetupServer(ctx context.Context, issuer string, storage Storage) *mux.Route
// newOP will create an OpenID Provider for localhost on a specified port with a given encryption key
// and a predefined default logout uri
// it will enable all options (see descriptions)
func newOP(ctx context.Context, storage op.Storage, issuer string, key [32]byte) (op.OpenIDProvider, error) {
func newOP(storage op.Storage, issuer string, key [32]byte) (op.OpenIDProvider, error) {
config := &op.Config{
CryptoKey: key,
@ -112,7 +111,7 @@ func newOP(ctx context.Context, storage op.Storage, issuer string, key [32]byte)
UserCode: op.UserCodeBase20,
},
}
handler, err := op.NewOpenIDProvider(ctx, issuer, config, storage,
handler, err := op.NewOpenIDProvider(issuer, config, storage,
//we must explicitly allow the use of the http issuer
op.WithAllowInsecure(),
// as an example on how to customize an endpoint this will change the authorization_endpoint from /authorize to /auth

View file

@ -1,7 +1,6 @@
package main
import (
"context"
"fmt"
"log"
"net/http"
@ -11,8 +10,6 @@ import (
)
func main() {
ctx := context.Background()
//we will run on :9998
port := "9998"
//which gives us the issuer: http://localhost:9998/
@ -23,7 +20,7 @@ func main() {
// in this example it will be handled in-memory
storage := storage.NewStorage(storage.NewUserStore(issuer))
router := exampleop.SetupServer(ctx, issuer, storage)
router := exampleop.SetupServer(issuer, storage)
server := &http.Server{
Addr: ":" + port,
@ -35,5 +32,4 @@ func main() {
if err != nil {
log.Fatal(err)
}
<-ctx.Done()
}