summaryrefslogtreecommitdiff
path: root/internal/handlers/handler_oauth_introspection.go
diff options
context:
space:
mode:
authorJames Elliott <james-d-elliott@users.noreply.github.com>2022-04-07 10:58:51 +1000
committerGitHub <noreply@github.com>2022-04-07 10:58:51 +1000
commit4ebd8fdf4e9fb0eb20684197f39929304fcb74b7 (patch)
tree895df7c98abce57e1e3e83eab848e399effce227 /internal/handlers/handler_oauth_introspection.go
parenta694cf851f24868c2ca6c6a8e51f66083b22b4a2 (diff)
feat(oidc): provide cors config including options handlers (#3005)
This adjusts the CORS headers appropriately for OpenID Connect. This includes responding to OPTIONS requests appropriately. Currently this is only configured to operate when the Origin scheme is HTTPS; but can easily be expanded in the future to include additional Origins.
Diffstat (limited to 'internal/handlers/handler_oauth_introspection.go')
-rw-r--r--internal/handlers/handler_oauth_introspection.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/internal/handlers/handler_oauth_introspection.go b/internal/handlers/handler_oauth_introspection.go
new file mode 100644
index 000000000..331ce201d
--- /dev/null
+++ b/internal/handlers/handler_oauth_introspection.go
@@ -0,0 +1,38 @@
+package handlers
+
+import (
+ "net/http"
+
+ "github.com/ory/fosite"
+
+ "github.com/authelia/authelia/v4/internal/middlewares"
+ "github.com/authelia/authelia/v4/internal/oidc"
+)
+
+// OAuthIntrospectionPOST handles POST requests to the OAuth 2.0 Introspection endpoint.
+//
+// https://datatracker.ietf.org/doc/html/rfc7662
+func OAuthIntrospectionPOST(ctx *middlewares.AutheliaCtx, rw http.ResponseWriter, req *http.Request) {
+ var (
+ responder fosite.IntrospectionResponder
+ err error
+ )
+
+ oidcSession := oidc.NewSession()
+
+ if responder, err = ctx.Providers.OpenIDConnect.Fosite.NewIntrospectionRequest(ctx, req, oidcSession); err != nil {
+ rfc := fosite.ErrorToRFC6749Error(err)
+
+ ctx.Logger.Errorf("Introspection Request failed with error: %+v", rfc)
+
+ ctx.Providers.OpenIDConnect.Fosite.WriteIntrospectionError(rw, err)
+
+ return
+ }
+
+ requester := responder.GetAccessRequester()
+
+ ctx.Logger.Tracef("Introspection Request yeilded a %s (active: %t) requested at %s created with request id '%s' on client with id '%s'", responder.GetTokenUse(), responder.IsActive(), requester.GetRequestedAt().String(), requester.GetID(), requester.GetClient().GetID())
+
+ ctx.Providers.OpenIDConnect.Fosite.WriteIntrospectionResponse(rw, responder)
+}