aboutsummaryrefslogtreecommitdiff
path: root/Libs/VNLib.Plugins.Essentials.Sessions.OAuth/Endpoints/RevocationEndpoint.cs
blob: 095e07e9cbed135a6eb4edf7d29268d23c1eb729 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using System;
using System.Text.Json;

using VNLib.Plugins.Essentials.Oauth;
using VNLib.Plugins.Extensions.Loading.Configuration;

namespace VNLib.Plugins.Essentials.Sessions.OAuth.Endpoints
{
    /// <summary>
    /// An OAuth2 authorized endpoint for revoking the access token
    /// held by the current connection
    /// </summary>
    [ConfigurationName("oauth2")]
    internal class RevocationEndpoint : O2EndpointBase
    {

        public RevocationEndpoint(PluginBase pbase, IReadOnlyDictionary<string, JsonElement> config)
        {
            string? path = config["revocation_path"].GetString();
            InitPathAndLog(path, pbase.Log);
        }

        protected override VfReturnType Post(HttpEntity entity)
        {
            //Revoke the access token, by invalidating it
            entity.Session.Invalidate();
            entity.CloseResponse(System.Net.HttpStatusCode.OK);
            return VfReturnType.VirtualSkip;
        }
    }
}