* first draft of a new server interface * allow any response type * complete interface docs * refelct the format from the proposal * intermediate commit with some methods implemented * implement remaining token grant type methods * implement remaining server methods * error handling * rewrite auth request validation * define handlers, routes * input validation and concrete handlers * check if client credential client is authenticated * copy and modify the routes test for the legacy server * run integration tests against both Server and Provider * remove unuse ValidateAuthRequestV2 function * unit tests for error handling * cleanup tokenHandler * move server routest test * unit test authorize * handle client credentials in VerifyClient * change code exchange route test * finish http unit tests * review server interface docs and spelling * add withClient unit test * server options * cleanup unused GrantType method * resolve typo comments * make endpoints pointers to enable/disable them * jwt profile base work * jwt: correct the test expect --------- Co-authored-by: Livio Spring <livio.a@gmail.com>
49 lines
958 B
Go
49 lines
958 B
Go
package op
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"net/http"
|
|
|
|
httphelper "github.com/zitadel/oidc/v3/pkg/http"
|
|
)
|
|
|
|
type ProbesFn func(context.Context) error
|
|
|
|
func healthHandler(w http.ResponseWriter, r *http.Request) {
|
|
ok(w)
|
|
}
|
|
|
|
func readyHandler(probes []ProbesFn) func(w http.ResponseWriter, r *http.Request) {
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
Readiness(w, r, probes...)
|
|
}
|
|
}
|
|
|
|
func Readiness(w http.ResponseWriter, r *http.Request, probes ...ProbesFn) {
|
|
ctx := r.Context()
|
|
for _, probe := range probes {
|
|
if err := probe(ctx); err != nil {
|
|
http.Error(w, "not ready", http.StatusInternalServerError)
|
|
return
|
|
}
|
|
}
|
|
ok(w)
|
|
}
|
|
|
|
func ReadyStorage(s Storage) ProbesFn {
|
|
return func(ctx context.Context) error {
|
|
if s == nil {
|
|
return errors.New("no storage")
|
|
}
|
|
return s.Health(ctx)
|
|
}
|
|
}
|
|
|
|
func ok(w http.ResponseWriter) {
|
|
httphelper.MarshalJSON(w, Status{"ok"})
|
|
}
|
|
|
|
type Status struct {
|
|
Status string `json:"status,omitempty"`
|
|
}
|