Skip to content

Commit

Permalink
fix: target abi version 10.9 #2
Browse files Browse the repository at this point in the history
  • Loading branch information
hexxone committed Oct 5, 2024
1 parent f641de2 commit d825e0b
Show file tree
Hide file tree
Showing 13 changed files with 104 additions and 70 deletions.
2 changes: 1 addition & 1 deletion HttpsReverseProxy/HttpsReverseProxy.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Yarp.ReverseProxy" Version="2.1.0"/>
<PackageReference Include="Yarp.ReverseProxy" Version="2.2.0"/>
</ItemGroup>

<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
Expand Down
6 changes: 5 additions & 1 deletion HttpsReverseProxy/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ public static void Main(string[] args)
var builder = WebApplication.CreateBuilder(args);

builder.Services.AddReverseProxy()
.LoadFromConfig(builder.Configuration.GetSection("ReverseProxy"));
.LoadFromConfig(builder.Configuration.GetSection("ReverseProxy"))
.ConfigureHttpClient((context, handler) =>
{
handler.AllowAutoRedirect = true;
});

var app = builder.Build();

Expand Down
7 changes: 0 additions & 7 deletions HttpsReverseProxy/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
2 changes: 1 addition & 1 deletion JellyfinPluginHelper/JellyfinPluginHelper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MinVer" Version="5.0.0">
<PackageReference Include="MinVer" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
7 changes: 4 additions & 3 deletions JellyfinPluginHelper/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
const string GitManifestBranch = "dist";
const string GitManifestPath = "manifest.json";

const string TargetAbi = "10.8.0.0";
const string TargetAbi = "10.9.0.0";
const string ChangeMessage = "Automatic Release by Github Actions: ";

if (args.Length != 3)
Expand Down Expand Up @@ -145,7 +145,7 @@ static void UpdateMeta(string metaPath, string version, string timestamp)
Console.WriteLine("JPH - Updating meta.json.");

// Read the existing meta.json
string metaJson = File.ReadAllText(metaPath);
var metaJson = File.ReadAllText(metaPath);
var meta = JsonSerializer.Deserialize<Dictionary<string, object>>(metaJson);

if (meta == null)
Expand All @@ -155,12 +155,13 @@ static void UpdateMeta(string metaPath, string version, string timestamp)
}

// Update the fields
meta["targetAbi"] = TargetAbi;
meta["timestamp"] = timestamp;
meta["version"] = FixVersionString(version);
meta["changelog"] = $"{ChangeMessage} https://github.com/{GitUser}/{GitProject}/releases/tag/{version}";

// Serialize and write back to meta.json
string updatedMetaJson = JsonSerializer.Serialize(meta, new JsonSerializerOptions { WriteIndented = true });
var updatedMetaJson = JsonSerializer.Serialize(meta, new JsonSerializerOptions { WriteIndented = true });
File.WriteAllText(metaPath, updatedMetaJson);

Console.WriteLine("JPH - Successfully updated meta.json.");
Expand Down
40 changes: 31 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,21 +136,43 @@ _Note: Video & Screenshots are taken with [my custom css theme](https://gist.git

![Config Page 1](./screenshots/02.png)

## Development

1. Clone Repo
2. Make sure to install "[JellyFin Server](https://repo.jellyfin.org/releases/server/windows/stable/)" for debugging on Windows. Keep the default path.
3. Open Solution file, restore packages
4. Build the Plugin in Release mode
5. Select to run "HttpsReverseProxy" AND "jellyfin" (server) at the same time.
6. The plugin gets copied to the server and the browser opens automatically.

## Dependencies

- [Telegram.Bot](https://github.com/TelegramBots/telegram.bot) library for validating bot token & determining bot username
- [ILRepack](https://github.com/gluck/il-repack) for packing all dependency dlls into one single plugin dll
- [MinVer](https://github.com/adamralph/minver) for automated Release-versioning via git tags

## Development / Contributing

### Tools

- [git](https://git-scm.com/downloads)
- [Visual Studio](https://visualstudio.microsoft.com/de/downloads/) or Rider IDE
- [.NET6](https://dotnet.microsoft.com/en-us/download/dotnet/6.0) for Jellyfin <= 10.8
- [.NET8](https://dotnet.microsoft.com/en-us/download/dotnet/8.0) for Jellyfin >= 10.9
- [JellyFin Server](https://repo.jellyfin.org/?path=/server/windows) for debugging on Windows. Keep the default path.

### Getting Started

1. Run `git clone https://github.com/hexxone/TeleJelly.git`
2. Open `TeleJelly.sln` file with VS or Rider, restore Nuget packages
3. Build `TeleJelly` Plugin in Release mode
4. First run `HttpsReverseProxy` AND then `jellyfin` (server) at the same time.
5. The plugin gets copied to the server and the browser opens automatically.

### Making changes

When implementing a new feature, please name your commit messages in a meaningful way and refer to git best practices.

The plugin uses "MinVer" and git-tags for semantic versioning.

Most of the Versions (meta.json and manifest.json) get incremented automatically on release build,
**but** there are some places which have to be done manually - for example in the `config.html`.

When targeting an updated version of Jellyfin, remember to set the correct `TargetAbi` version in `JellyfinPluginHelper`!

Feel free to open Pull-Requests for useful additions and fixes you made, but if you disregard these guidelines, I will disregard your PR.

## Licensing

Licensing is a complex topic. This repository features a GPLv3 license template that can be used to provide a good default license for your plugin.
Expand Down
2 changes: 1 addition & 1 deletion TeleJelly/Assets/Config/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<!-- Title and Infos -->
<div class="sectionTitleContainer flex align-items-center">
<h2 class="sectionTitle">TeleJelly Configuration</h2>
<h3>Version: <b id="TeleJellyVersion">1.0.6.0</b></h3>
<h3>Version: <b id="TeleJellyVersion">1.0.8.0</b></h3>
<a href="https://github.com/hexxone/TeleJelly"
class="button-link emby-button headerHelpButton"
is="emby-linkbutton"
Expand Down
45 changes: 22 additions & 23 deletions TeleJelly/Classes/ControllerExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
using System;
using Microsoft.AspNetCore.Http;

namespace Jellyfin.Plugin.TeleJelly.Classes
namespace Jellyfin.Plugin.TeleJelly.Classes;

internal static class ControllerExtensions
{
internal static class ControllerExtensions
/// <summary>
/// Gets the "FQDN" of the current web request context (aka. this Jellyfin server's host address).
/// With respect to the configured "ForcedUrlScheme".
/// </summary>
/// <param name="request">Incoming Context.</param>
/// <param name="configuration">of the plugin.</param>
/// <returns>string of Format "FQDN.TLD".</returns>
public static string GetRequestBase(this HttpRequest request, PluginConfiguration configuration)
{
/// <summary>
/// Gets the "FQDN" of the current web request context (aka. this Jellyfin server's host address).
/// With respect to the configured "ForcedUrlScheme".
/// </summary>
/// <param name="request">Incoming Context.</param>
/// <param name="configuration">of the plugin.</param>
/// <returns>string of Format "FQDN.TLD".</returns>
public static string GetRequestBase(this HttpRequest request, PluginConfiguration configuration)
if (request == null)
{
if (request == null)
{
throw new ArgumentNullException(nameof(request), "Request is null.");
}

var requestPort = request.Host.Port ?? -1;
var requestScheme = configuration.ForceUrlScheme ? configuration.ForcedUrlScheme : request.Scheme;
throw new ArgumentNullException(nameof(request), "Request is null.");
}

// strip the default ports of given protocol in the final result (80 = http, 443 = https)
if ((requestPort == 80 && string.Equals(requestScheme, "http", StringComparison.OrdinalIgnoreCase)) || (requestPort == 443 && string.Equals(requestScheme, "https", StringComparison.OrdinalIgnoreCase)))
{
requestPort = -1;
}
var requestPort = request.Host.Port ?? -1;
var requestScheme = configuration.ForceUrlScheme ? configuration.ForcedUrlScheme : request.Scheme;

return new UriBuilder { Scheme = requestScheme, Host = request.Host.Host, Port = requestPort, Path = request.PathBase }.ToString().TrimEnd('/');
// strip the default ports of given protocol in the final result (80 = http, 443 = https)
if ((requestPort == 80 && string.Equals(requestScheme, "http", StringComparison.OrdinalIgnoreCase)) || (requestPort == 443 && string.Equals(requestScheme, "https", StringComparison.OrdinalIgnoreCase)))
{
requestPort = -1;
}

return new UriBuilder { Scheme = requestScheme, Host = request.Host.Host, Port = requestPort, Path = request.PathBase }.ToString().TrimEnd('/');
}
}
2 changes: 1 addition & 1 deletion TeleJelly/Controller/TelegramController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace Jellyfin.Plugin.TeleJelly.Controller;
[Route("sso/{Controller}")]
public class TelegramController : ControllerBase
{
private static readonly string[] _entryPoints = { "index.html", "login", "login.html" };
private static readonly string[] _entryPoints = ["index.html", "login", "login.html"];

// private readonly ILogger _logger;
private readonly TeleJellyPlugin _instance;
Expand Down
21 changes: 12 additions & 9 deletions TeleJelly/TeleJelly.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Jellyfin.Plugin.TeleJelly</RootNamespace>
<AssemblyVersion>1.0.6.0</AssemblyVersion>
<FileVersion>1.0.6.0</FileVersion>
<Version>1.0.6.0</Version>
<AssemblyVersion>1.0.8.0</AssemblyVersion>
<FileVersion>1.0.8.0</FileVersion>
<Version>1.0.8.0</Version>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<MSBuildArgs>/property:GenerateFullPaths=true /consoleloggerparameters:NoSummary</MSBuildArgs>
Expand All @@ -28,25 +28,28 @@
<Product>TeleJelly</Product>
<Nullable>enable</Nullable>
<DebugType>embedded</DebugType>
<LangVersion>12</LangVersion>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App"/>
<PackageReference Include="Jellyfin.Controller" Version="10.8.13"/>
<PackageReference Include="Jellyfin.Model" Version="10.8.13"/>
<PackageReference Include="Jellyfin.Controller" Version="10.9.11"/>
<PackageReference Include="Jellyfin.Model" Version="10.9.11"/>
<PackageReference Include="Telegram.Bot" Version="19.0.0"/>
<PackageReference Include="MinVer" Version="5.0.0">
<PackageReference Include="MinVer" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="ILRepack.Lib.MSBuild.Task" Version="2.0.31">
<PackageReference Include="ILRepack.Lib.MSBuild.Task" Version="2.0.34.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="SerilogAnalyzer" Version="0.15.0" PrivateAssets="All"/>
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.376" PrivateAssets="All"/>
<PackageReference Include="SmartAnalyzers.MultithreadingAnalyzer" Version="1.1.31" PrivateAssets="All"/>
<PackageReference Include="WebMarkupMin.Core" Version="2.16.0"/>
<PackageReference Include="WebMarkupMin.Core" Version="2.17.0"/>
</ItemGroup>

<ItemGroup>
Expand Down
20 changes: 16 additions & 4 deletions TeleJelly/TeleJellyPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@ public class TeleJellyPlugin : BasePlugin<PluginConfiguration>, IPlugin, IHasWeb
/// - {{TELEGRAM_BOT_NAME}} = Bot Username.
/// </summary>
/// <returns>A list of internal webpages in this application.</returns>
public static readonly ExtraPageInfo[] LoginFiles = { new() { Name = "index", EmbeddedResourcePath = $"{typeof(TeleJellyPlugin).Namespace}.Assets.Login.login.html", NeedsReplacement = true }, new() { Name = "login.css", EmbeddedResourcePath = $"{typeof(TeleJellyPlugin).Namespace}.Assets.Login.login.css", NeedsReplacement = true }, new() { Name = "login.js", EmbeddedResourcePath = $"{typeof(TeleJellyPlugin).Namespace}.Assets.Login.login.js", NeedsReplacement = true }, new() { Name = "material_icons.woff2", EmbeddedResourcePath = $"{typeof(TeleJellyPlugin).Namespace}.Assets.Login.material_icons.woff2" }, new() { Name = Constants.DefaultUserImageExtraFile, EmbeddedResourcePath = $"{typeof(TeleJellyPlugin).Namespace}.Assets.Login.TeleJellyLogo.jpg" }, };
public static readonly ExtraPageInfo[] LoginFiles =
[
new() { Name = "index", EmbeddedResourcePath = $"{typeof(TeleJellyPlugin).Namespace}.Assets.Login.login.html", NeedsReplacement = true },
new() { Name = "login.css", EmbeddedResourcePath = $"{typeof(TeleJellyPlugin).Namespace}.Assets.Login.login.css", NeedsReplacement = true },
new() { Name = "login.js", EmbeddedResourcePath = $"{typeof(TeleJellyPlugin).Namespace}.Assets.Login.login.js", NeedsReplacement = true },
new() { Name = "material_icons.woff2", EmbeddedResourcePath = $"{typeof(TeleJellyPlugin).Namespace}.Assets.Login.material_icons.woff2" },
new() { Name = Constants.DefaultUserImageExtraFile, EmbeddedResourcePath = $"{typeof(TeleJellyPlugin).Namespace}.Assets.Login.TeleJellyLogo.jpg" }
];

/// <summary>
/// Initializes a new instance of the <see cref="TeleJellyPlugin" /> class.
Expand Down Expand Up @@ -66,11 +73,16 @@ public TeleJellyPlugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSer
public override Guid Id => Constants.Id;

/// <summary>
/// Returns the available internal web pages of this plugin.
/// Gets the available internal web pages of this plugin.
/// </summary>
/// <returns>A list of internal webpages in this application.</returns>
public IEnumerable<PluginPageInfo> GetPages()
IEnumerable<PluginPageInfo> IHasWebPages.GetPages()
{
return new PluginPageInfo[] { new() { Name = Name, EmbeddedResourcePath = $"{typeof(TeleJellyPlugin).Namespace}.Assets.Config.config.html" }, new() { Name = Name + ".js", EmbeddedResourcePath = $"{typeof(TeleJellyPlugin).Namespace}.Assets.Config.config.js" }, new() { Name = Name + ".css", EmbeddedResourcePath = $"{typeof(TeleJellyPlugin).Namespace}.Assets.Config.config.css" } };
return
[
new PluginPageInfo { Name = Name, EmbeddedResourcePath = $"{typeof(TeleJellyPlugin).Namespace}.Assets.Config.config.html" },
new PluginPageInfo { Name = Name + ".js", EmbeddedResourcePath = $"{typeof(TeleJellyPlugin).Namespace}.Assets.Config.config.js" },
new PluginPageInfo { Name = Name + ".css", EmbeddedResourcePath = $"{typeof(TeleJellyPlugin).Namespace}.Assets.Config.config.css" }
];
}
}
8 changes: 4 additions & 4 deletions TeleJelly/Telegram/TelegramHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public async Task<User> GetOrCreateJellyUser(SortedDictionary<string, string> au
AppVersion = GetType().Assembly.GetName().Version?.ToString() ?? "0.0.0.1",
DeviceId = request.Headers[HeaderNames.UserAgent].ToString(),
DeviceName = "TelegramBrowserSSO",
RemoteEndPoint = request.HttpContext.GetNormalizedRemoteIp().ToString(),
RemoteEndPoint = request.HttpContext.GetNormalizedRemoteIP().ToString(),
UserId = user.Id,
Username = user.Username
};
Expand All @@ -181,13 +181,13 @@ public TelegramAuthResult CheckTelegramAuthorizationImpl(SortedDictionary<string
Debug.Assert(fields != null, nameof(fields) + " != null");

if (!fields.ContainsKey(Field.Id) ||
!fields.TryGetValue(Field.AuthDate, out string? authDate) ||
!fields.TryGetValue(Field.Hash, out string? hash))
!fields.TryGetValue(Field.AuthDate, out var authDate) ||
!fields.TryGetValue(Field.Hash, out var hash))
{
return new TelegramAuthResult { ErrorMessage = "Data has missing fields." };
}

if (!long.TryParse(authDate, out long timestamp))
if (!long.TryParse(authDate, out var timestamp))
{
return new TelegramAuthResult { ErrorMessage = "Invalid AuthDate Format." };
}
Expand Down
12 changes: 6 additions & 6 deletions meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"overview": "Log in to Jellyfin using Telegram",
"description": "Enables logging in to Jellyfin using the Telegram Login Widget as SSO provider. Allows for simple Group management. Having a Telegram Username is mandatory. A Telegram Bot is required to validate the Telegram login credentials. A valid, public domain SSL certificate is required for the Login Widget to work. This plug-in is free, open-source software. \u0027Production\u0027-usage is NOT recommended. I do not accept any responsibility for errors. Repo: https://github.com/hexxone/TeleJelly",
"owner": "hexxone",
"category": "Metadata",
"category": "Authentication",
"imageUrl": "https://github.com/hexxone/TeleJelly/blob/main/TeleJelly/thumb.jpg?raw=true",
"targetAbi": "10.8.0.0",
"timestamp": "2024-05-06T21:37:13Z",
"version": "1.0.6",
"changelog": "Automatic Release by Github Actions: https://github.com/hexxone/TeleJelly/releases/tag/1.0.6"
}
"targetAbi": "10.9.0.0",
"timestamp": "2024-10-05T15:43:50Z",
"version": "1.0.7.1",
"changelog": "Automatic Release by Github Actions: https://github.com/hexxone/TeleJelly/releases/tag/1.0.8-alpha.0.1"
}

0 comments on commit d825e0b

Please sign in to comment.