Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
c9e0a9b
update: move enum to .cs file + new UserRequest model
saph1s Nov 25, 2024
d47d8b9
update: move to src
saph1s Nov 25, 2024
16c1ba9
update: new models + client + ep's
saph1s Nov 26, 2024
adc044b
bump version
saph1s Nov 26, 2024
e718bc9
add LICENSE
saph1s Nov 26, 2024
1ef4506
update: new utils + models update
saph1s Nov 27, 2024
0363da3
update: disable SourceGenerationContext
saph1s Dec 11, 2024
8c07db8
update: add CoreUsersRetrieve
saph1s Dec 11, 2024
0666e9c
fix: change string to int
saph1s Dec 11, 2024
ab0879e
update: add 404 exception
saph1s Dec 13, 2024
cd9bb00
update: add doc
saph1s Dec 13, 2024
93c6703
add: new CoreUsersPartialUpdate
saph1s Jan 15, 2025
acdff6b
update: improve documentation and add CoreUsersCreate method
saph1s Mar 13, 2025
3413db9
update: bump version to 0.0.2
saph1s Mar 13, 2025
0765998
update: enhance AdminApi with new settings methods and improve Settin…
saph1s Apr 23, 2025
80f52d9
update: add PatchedSettingsRequest model and modify AdminSettingsPart…
saph1s Apr 23, 2025
8d2a047
update: enhance JSON converters with documentation and improve enum d…
saph1s Apr 23, 2025
9ebb7d0
update: bump version to 0.0.4, add LICENSE and NOTICE files, and impr…
saph1s Apr 23, 2025
8bdd83e
update: remove unused license from root dir
saph1s Apr 24, 2025
2fe16fa
update: refactor AuthentikClient constructor and bump version to 0.0.…
saph1s May 3, 2025
bc3682c
update: improve NuGet publish workflow
saph1s May 4, 2025
4a137a1
update: modify NuGet pack command to include version suffix from extr…
saph1s May 4, 2025
2a768ed
fix: fix workflow pt.2
saph1s May 4, 2025
f9ace96
update: enhance NuGet versioning logic and streamline build process
saph1s May 7, 2025
36d7b7c
update: enhance versioning logic to ensure new versions are greater t…
saph1s May 7, 2025
bba1a88
update: update models + add universal converter for enum + use authen…
saph1s May 7, 2025
ba5e470
update: add models for SSF API including enums and data structures
saph1s Jun 10, 2025
41f7553
update: bump version to 2025.4.2 and update release notes
saph1s Jun 10, 2025
0027355
update: add CoreGroupsList method to retrieve paginated group data wi…
saph1s Jun 10, 2025
bb4cd2a
update: add PaginatedGroupList model for handling paginated group data
saph1s Jun 10, 2025
2ad3428
update: make membersByPk parameter optional in CoreGroupsList method
saph1s Aug 21, 2025
e318980
update: modify group viewset summary and add CoreGroupsRetrieve metho…
saph1s Aug 21, 2025
6316576
update: add JsonIgnore attribute to nullable properties in PatchedUse…
saph1s Aug 30, 2025
1b66dad
update: refactor query string construction in user and group retrieva…
saph1s Jan 6, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 110 additions & 0 deletions .github/workflows/nuget-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: NuGet | Build and Publish

on:
workflow_dispatch:
push:
branches:
- main
- dev
tags: [ "[0-9]+.[0-9]+.[0-9]+" ]
release:
types:
- published


env:
PROJECT_PATH: ./src/AuthentikNet.Api/AuthentikNet.Api.csproj
PACKAGE_OUTPUT_DIRECTORY: ${{ github.workspace }}/output
NUGET_SOURCE_URL: "https://api.nuget.org/v3/index.json"

jobs:
build-nuget:
name: Build NuGet package
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x

- name: Restore dependencies
run: dotnet restore ${{ env.PROJECT_PATH }}

- name: Extract version from project file
id: extract_version
shell: bash
run: |
VERSION=$(grep -oPm1 "(?<=<Version>)[^<]+" ${{ env.PROJECT_PATH }})
PACKAGE_ID=$(grep -oPm1 "(?<=<PackageId>)[^<]+" ${{ env.PROJECT_PATH }} || basename ${{ env.PROJECT_PATH }} .csproj)
ALL_VERSIONS=$(curl -s "https://api.nuget.org/v3-flatcontainer/${PACKAGE_ID,,}/index.json" | jq -r '.versions[]' || true)
MAX_VERSION=$(echo "$ALL_VERSIONS" | sort -V | tail -n1)
if [[ "${GITHUB_REF}" == "refs/heads/main" ]]; then
FINAL_VERSION="$VERSION"
elif [[ "${GITHUB_REF}" == "refs/heads/dev" ]]; then
DEV_VERSIONS=$(echo "$ALL_VERSIONS" | grep "^${VERSION}-dev\." || true)
if [[ -z "$DEV_VERSIONS" ]]; then
N=0
else
N=$(echo "$DEV_VERSIONS" | sed -E "s/^${VERSION}-dev\.([0-9]+)$/\1/" | sort -nr | head -n1)
N=$((N+1))
fi
FINAL_VERSION="${VERSION}-dev.${N}"
else
SHORT_SHA=$(git rev-parse --short HEAD)
FINAL_VERSION="${VERSION}-${SHORT_SHA}"
fi

if [[ -n "$MAX_VERSION" ]]; then
if [[ "$(printf '%s\n' "$MAX_VERSION" "$FINAL_VERSION" | sort -V | tail -n1)" != "$FINAL_VERSION" ]]; then
echo "Error: The version $FINAL_VERSION is not greater than the latest version $MAX_VERSION."
exit 1
fi
fi

echo "PROJECT_VERSION=$FINAL_VERSION" >> $GITHUB_OUTPUT
echo "Extracted version: $FINAL_VERSION"

- name: Get short SHA
id: short_sha
run: echo "SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT

- name: Build
run: dotnet build ${{ env.PROJECT_PATH }} --configuration Release --no-restore /p:Version="${{ steps.extract_version.outputs.PROJECT_VERSION }}"

- name: Pack
run: dotnet pack ${{ env.PROJECT_PATH }} --configuration Release --no-build --output ${{ env.PACKAGE_OUTPUT_DIRECTORY }} /p:Version="${{ steps.extract_version.outputs.PROJECT_VERSION }}"

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: nuget-package
path: ${{ env.PACKAGE_OUTPUT_DIRECTORY }}/*.nupkg

publish-nuget:
name: Publish NuGet package
needs: build-nuget
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev'
runs-on: ubuntu-latest
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: nuget-package
path: ${{ env.PACKAGE_OUTPUT_DIRECTORY }}

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x

- name: Publish to NuGet
run: |
for f in ${{ env.PACKAGE_OUTPUT_DIRECTORY }}/*.nupkg; do
echo "Publishing $f to NuGet..."
dotnet nuget push "$f" --source ${{ env.NUGET_SOURCE_URL }} --api-key ${{ secrets.NUGET_API_KEY }} --skip-duplicate
done
2 changes: 1 addition & 1 deletion AuthentikNet.sln
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AuthentikNet.Api", "AuthentikNet.Api\AuthentikNet.Api.csproj", "{D0BDC4CF-C6DC-4DCC-A38A-589FA8FA9ACF}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AuthentikNet.Api", "src\AuthentikNet.Api\AuthentikNet.Api.csproj", "{D0BDC4CF-C6DC-4DCC-A38A-589FA8FA9ACF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,34 @@
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>0.0.1-dev</Version>

<Version>2025.4.2</Version>

<Authors>Saph1s</Authors>
<Description>Authentik api client</Description>
<Copyright>Copyright (c) Saph1s 2024</Copyright>
<PackageProjectUrl>https://github.com/Saph1s/AuthentikNet</PackageProjectUrl>
<Company>Saph1s</Company>
<Description>Authentik API client</Description>
<Copyright>Copyright 2024-2025 Anton "Saph1s" Babenko</Copyright>

<PackageProjectUrl>https://github.com/Saph1s/AuthentikNet</PackageProjectUrl>
<RepositoryUrl>https://github.com/Saph1s/AuthentikNet</RepositoryUrl>
<RepositoryType>git</RepositoryType>

<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>

<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageReadmeFile>README.md</PackageReadmeFile>
<RepositoryUrl>https://github.com/Saph1s/AuthentikNet</RepositoryUrl>
</PropertyGroup>

<PropertyGroup>
<PackageTags>authentik;sso;identity</PackageTags>
<PackageReleaseNotes>Authentik compatible version - 2025.4.2</PackageReleaseNotes>
</PropertyGroup>

<ItemGroup>
<None Include="README.md" Pack="true" PackagePath=""/>
<None Include="LICENSE" Pack="true" PackagePath=""/>
<None Include="NOTICE" Pack="true" PackagePath=""/>
</ItemGroup>

</Project>
173 changes: 173 additions & 0 deletions src/AuthentikNet.Api/Client/Admin/AdminApi.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
using AuthentikNet.Api.Models;
using Version = AuthentikNet.Api.Models.Version;

namespace AuthentikNet.Api.Client.Admin;

public class AdminApi

Check warning on line 6 in src/AuthentikNet.Api/Client/Admin/AdminApi.cs

View workflow job for this annotation

GitHub Actions / Build NuGet package

Missing XML comment for publicly visible type or member 'AdminApi'
{
private readonly AuthentikClient _client;

public AdminApi(AuthentikClient client)

Check warning on line 10 in src/AuthentikNet.Api/Client/Admin/AdminApi.cs

View workflow job for this annotation

GitHub Actions / Build NuGet package

Missing XML comment for publicly visible type or member 'AdminApi.AdminApi(AuthentikClient)'
{
_client = client;
}

/// <summary>
/// Read-only view list all installed apps
/// </summary>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public async Task<List<App>> AdminAppsList(CancellationToken cancellationToken = default)
{
return await _client.SendAsync<List<App>>(HttpMethod.Get, "/admin/apps/", cancellationToken: cancellationToken);
}

/// <summary>
/// Login Metrics per 1h
/// </summary>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public async Task<LoginMetrics> AdminMetricsRetrieve(CancellationToken cancellationToken = default)
{
return await _client.SendAsync<LoginMetrics>(HttpMethod.Get, "/admin/metrics/",
cancellationToken: cancellationToken);
}

/// <summary>
/// Read-only view list all installed models
/// </summary>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public async Task<List<App>> AdminModelsList(CancellationToken cancellationToken = default)
{
return await _client.SendAsync<List<App>>(HttpMethod.Get, "/admin/models/",
cancellationToken: cancellationToken);
}

/// <summary>
/// Get settings
/// </summary>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public async Task<Settings> AdminSettingsRetrieve(CancellationToken cancellationToken = default)
{
return await _client.SendAsync<Settings>(HttpMethod.Get, "/admin/settings/",
cancellationToken: cancellationToken);
}

/// <summary>
/// Update settings
/// </summary>
/// <param name="data">Settings model</param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public async Task<Settings> AdminSettingsUpdate(Settings data, CancellationToken cancellationToken = default)
{
return await _client.SendAsync<Settings>(HttpMethod.Put, "/admin/settings/", data, cancellationToken);
}

/// <summary>
/// Partial update settings
/// </summary>
/// <param name="data">PartialSettings moder</param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public async Task<Settings> AdminSettingsPartialUpdate(PatchedSettingsRequest data,
CancellationToken cancellationToken = default)
{
return await _client.SendAsync<Settings>(HttpMethod.Patch, "/admin/settings/", data, cancellationToken);
}

/// <summary>
/// Get system information
/// </summary>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public async Task<SystemInfo> AdminSystemRetrieve(CancellationToken cancellationToken = default)
{
return await _client.SendAsync<SystemInfo>(HttpMethod.Get, "/admin/system/",
cancellationToken: cancellationToken);
}

/// <summary>
/// Get system information
/// </summary>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public async Task<SystemInfo> AdminSystemCreate(CancellationToken cancellationToken = default)
{
return await _client.SendAsync<SystemInfo>(HttpMethod.Post, "/admin/system/",
cancellationToken: cancellationToken);
}

/// <summary>
/// Get running and latest version
/// </summary>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public async Task<Version> AdminVersionRetrieve(CancellationToken cancellationToken = default)
{
return await _client.SendAsync<Version>(HttpMethod.Get, "/admin/version/",
cancellationToken: cancellationToken);
}

/// <summary>
/// VersionHistory Viewset
/// </summary>
/// <param name="build"></param>
/// <param name="ordering">Which field to use when ordering the results.</param>
/// <param name="search">A search term.</param>
/// <param name="version"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public async Task<List<VersionHistory>> AdminVersionHistoryList(
string? build = null,
string? ordering = null,
string? search = null,
string? version = null,
CancellationToken cancellationToken = default)
{
var url = "/admin/version/history/";
var queryParameters = new Dictionary<string, string?>
{
{ "build", build },
{ "ordering", ordering },
{ "search", search },
{ "version", version }
}
.Where(kv => kv.Value != null)
.ToDictionary(kv => kv.Key, kv => kv.Value!);

if (queryParameters.Count > 0)
{
var query = string.Join("&", queryParameters
.Select(x => $"{x.Key}={Uri.EscapeDataString(x.Value)}"));
url += "?" + query;
}

return await _client.SendAsync<List<VersionHistory>>(HttpMethod.Get, url, cancellationToken: cancellationToken);
}

/// <summary>
/// VersionHistory Viewset
/// </summary>
/// <param name="id">A unique integer value identifying this Version history.</param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public async Task<VersionHistory> AdminVersionHistoryRetrieve(int id, CancellationToken cancellationToken = default)
{
return await _client.SendAsync<VersionHistory>(HttpMethod.Get, $"/admin/version/history/{id}/",
cancellationToken: cancellationToken);
}

/// <summary>
/// Get currently connected worker count.
/// </summary>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public async Task<Workers> AdminWorkersRetrieve(CancellationToken cancellationToken = default)
{
return await _client.SendAsync<Workers>(HttpMethod.Get, "/admin/workers/",
cancellationToken: cancellationToken);
}
}
Loading