mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-07-15 01:52:07 -04:00
* re-implement the auth-api service to authenticate Reva tokens following the OIDC Userinfo endpoint specification * pass the context where necessary and add an authenticator interface to the JMAP HTTP driver, in order to select between master authentication (which is used when GROUPWARE_JMAP_MASTER_USERNAME and GROUPWARE_JMAP_MASTER_PASSWORD are both set) and OIDC token forwarding through bearer auth * add Stalwart directory configuration "idmoidc" which uses the OpenCloud auth-api service API (/auth/) to validate the token it received as bearer auth from the Groupware backend's JMAP client, using it as an OIDC Userinfo endpoint * implement optional additional shared secret to secure the Userinfo service, as an additional path parameter
54 lines
1.4 KiB
Go
54 lines
1.4 KiB
Go
package svc
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/go-chi/chi/v5"
|
|
|
|
"github.com/riandyrn/otelchi"
|
|
oteltrace "go.opentelemetry.io/otel/trace"
|
|
|
|
"github.com/opencloud-eu/opencloud/pkg/log"
|
|
"github.com/opencloud-eu/opencloud/pkg/tracing"
|
|
auth_api "github.com/opencloud-eu/opencloud/services/auth-api/pkg/auth-api"
|
|
"github.com/opencloud-eu/opencloud/services/auth-api/pkg/config"
|
|
"github.com/opencloud-eu/opencloud/services/auth-api/pkg/metrics"
|
|
)
|
|
|
|
// Service defines the service handlers.
|
|
type Service interface {
|
|
ServeHTTP(w http.ResponseWriter, r *http.Request)
|
|
}
|
|
|
|
// NewService returns a service implementation for Service.
|
|
func NewService(
|
|
logger *log.Logger,
|
|
metrics *metrics.Metrics,
|
|
tracerProvider oteltrace.TracerProvider,
|
|
config *config.Config,
|
|
middlewares ...func(http.Handler) http.Handler) (Service, error) {
|
|
m := chi.NewMux()
|
|
|
|
mwlist := []func(http.Handler) http.Handler{}
|
|
mwlist = append(mwlist, middlewares...)
|
|
o := otelchi.Middleware(
|
|
"auth-api",
|
|
otelchi.WithChiRoutes(m),
|
|
otelchi.WithTracerProvider(tracerProvider),
|
|
otelchi.WithPropagators(tracing.GetPropagator()),
|
|
otelchi.WithTraceResponseHeaders(otelchi.TraceHeaderConfig{}),
|
|
)
|
|
mwlist = append(mwlist, o)
|
|
|
|
m.Use(mwlist...)
|
|
|
|
authApi, err := auth_api.NewAuthApi(config, logger, tracerProvider, metrics, m)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
m.Route(config.HTTP.Root, authApi.Route)
|
|
|
|
return authApi, nil
|
|
}
|