mirror of
https://github.com/davidallendj/opaal.git
synced 2025-12-20 03:27:02 -07:00
Made it possible to override certain example IDP endpoints
This commit is contained in:
parent
f10a771db6
commit
73e4e50d44
4 changed files with 57 additions and 18 deletions
19
cmd/serve.go
19
cmd/serve.go
|
|
@ -2,6 +2,7 @@ package cmd
|
|||
|
||||
import (
|
||||
opaal "davidallendj/opaal/internal"
|
||||
"davidallendj/opaal/internal/oidc"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
|
@ -9,23 +10,31 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var exampleCmd = &cobra.Command{
|
||||
var (
|
||||
endpoints oidc.Endpoints
|
||||
)
|
||||
|
||||
var serveCmd = &cobra.Command{
|
||||
Use: "serve",
|
||||
Short: "Start an simple identity provider server",
|
||||
Short: "Start an simple, bare minimal identity provider server",
|
||||
Long: "The built-in identity provider is not (nor meant to be) a complete OIDC implementation and behaves like an external IdP",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
s := opaal.NewServerWithConfig(&config)
|
||||
// FIXME: change how the server address is set with `NewServerWithConfig`
|
||||
s.Server.Addr = fmt.Sprintf("%s:%d", s.Issuer.Host, s.Issuer.Port)
|
||||
err := s.StartIdentityProvider()
|
||||
err := s.StartIdentityProvider(endpoints)
|
||||
if errors.Is(err, http.ErrServerClosed) {
|
||||
fmt.Printf("Identity provider server closed.\n")
|
||||
} else if err != nil {
|
||||
fmt.Errorf("failed to start server: %v", err)
|
||||
fmt.Printf("failed to start server: %v", err)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(exampleCmd)
|
||||
serveCmd.Flags().StringVar(&endpoints.Authorization, "endpoints.authorization", "", "set the authorization endpoint for the identity provider")
|
||||
serveCmd.Flags().StringVar(&endpoints.Token, "endpoints.token", "", "set the token endpoint for the identity provider")
|
||||
serveCmd.Flags().StringVar(&endpoints.JwksUri, "endpoints.jwks_uri", "", "set the JWKS endpoints for the identity provider")
|
||||
|
||||
rootCmd.AddCommand(serveCmd)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue