Changeset 440 for TFP-WebServer


Ignore:
Timestamp:
May 24, 2023, 4:53:49 PM (19 months ago)
Author:
alloc
Message:

*Added: Allow specifying a single level 0 API token on the command line

Location:
TFP-WebServer
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • TFP-WebServer/CommandExtensions/ModInfo.xml

    r435 r440  
    55        <Description value="Additional commands for server operation" />
    66        <Author value="The Fun Pimps LLC" />
    7         <Version value="21.0.289.0" />
     7        <Version value="21.0.293.0" />
    88        <Website value="" />
    99</xml>
  • TFP-WebServer/MapRendering/ModInfo.xml

    r435 r440  
    55        <Description value="Render the game map to image map tiles as it is uncovered" />
    66        <Author value="The Fun Pimps LLC" />
    7         <Version value="21.0.289.0" />
     7        <Version value="21.0.293.0" />
    88        <Website value="" />
    99</xml>
  • TFP-WebServer/MarkersMod/ModInfo.xml

    r435 r440  
    55        <Description value="Allows placing custom markers on the web map" />
    66        <Author value="Catalysm and Alloc" />
    7         <Version value="21.0.289.0" />
     7        <Version value="21.0.293.0" />
    88        <Website value="" />
    99</xml>
  • TFP-WebServer/WebServer/ModInfo.xml

    r438 r440  
    55        <Description value="Integrated Webserver for the Web Dashboard and server APIs" />
    66        <Author value="The Fun Pimps LLC" />
    7         <Version value="21.0.289.3" />
     7        <Version value="21.0.293.0" />
    88        <Website value="" />
    99</xml>
  • TFP-WebServer/WebServer/src/Permissions/AdminApiTokens.cs

    r404 r440  
    117117                        }
    118118
     119                        if (IsCommandlineToken (_name, _secret)) {
     120                                return 0;
     121                        }
     122
    119123                        return int.MaxValue;
     124                }
     125
     126                private bool commandlineChecked;
     127                private string commandlineTokenName;
     128                private string commandlineTokenSecret;
     129
     130                private bool IsCommandlineToken (string _name, string _secret) {
     131                        if (!commandlineChecked) {
     132                                commandlineTokenName = GameUtils.GetLaunchArgument ("webapitokenname");
     133                                commandlineTokenSecret = GameUtils.GetLaunchArgument ("webapitokensecret");
     134
     135                                commandlineChecked = true;
     136                        }
     137
     138                        if (string.IsNullOrEmpty (commandlineTokenName) || string.IsNullOrEmpty (commandlineTokenSecret)) {
     139                                return false;
     140                        }
     141
     142                        return _name == commandlineTokenName && _secret == commandlineTokenSecret;
    120143                }
    121144
  • TFP-WebServer/WebServer/src/UrlHandlers/AbsHandler.cs

    r434 r440  
    1616                public abstract void HandleRequest (RequestContext _context);
    1717
    18                 public virtual bool IsAuthorizedForHandler (WebConnection _user, int _permissionLevel) {
    19                         return ModuleName == null || AdminWebModules.Instance.ModuleAllowedWithLevel (ModuleName, _permissionLevel);
     18                public virtual bool IsAuthorizedForHandler (RequestContext _context) {
     19                        return ModuleName == null || AdminWebModules.Instance.ModuleAllowedWithLevel (ModuleName, _context.PermissionLevel);
    2020                }
    2121
  • TFP-WebServer/WebServer/src/Web.cs

    r434 r440  
    271271                                }
    272272
    273                                 if (!handler.IsAuthorizedForHandler (_context.Connection, _context.PermissionLevel)) {
     273                                if (!handler.IsAuthorizedForHandler (_context)) {
    274274                                        _context.Response.StatusCode = (int)HttpStatusCode.Forbidden;
    275275                                        if (_context.Connection != null) {
  • TFP-WebServer/bin/Mods/TFP_CommandExtensions/ModInfo.xml

    r435 r440  
    55        <Description value="Additional commands for server operation" />
    66        <Author value="The Fun Pimps LLC" />
    7         <Version value="21.0.289.0" />
     7        <Version value="21.0.293.0" />
    88        <Website value="" />
    99</xml>
  • TFP-WebServer/bin/Mods/TFP_MapRendering/ModInfo.xml

    r435 r440  
    55        <Description value="Render the game map to image map tiles as it is uncovered" />
    66        <Author value="The Fun Pimps LLC" />
    7         <Version value="21.0.289.0" />
     7        <Version value="21.0.293.0" />
    88        <Website value="" />
    99</xml>
  • TFP-WebServer/bin/Mods/TFP_WebServer/ModInfo.xml

    r438 r440  
    55        <Description value="Integrated Webserver for the Web Dashboard and server APIs" />
    66        <Author value="The Fun Pimps LLC" />
    7         <Version value="21.0.289.3" />
     7        <Version value="21.0.293.0" />
    88        <Website value="" />
    99</xml>
  • TFP-WebServer/bin/Mods/Xample_MarkersMod/ModInfo.xml

    r435 r440  
    55        <Description value="Allows placing custom markers on the web map" />
    66        <Author value="Catalysm and Alloc" />
    7         <Version value="21.0.289.0" />
     7        <Version value="21.0.293.0" />
    88        <Website value="" />
    99</xml>
Note: See TracChangeset for help on using the changeset viewer.