< Summary - Kestrun — Combined Coverage

Information
Class: Public.Authentication.Add-KrGitHubAuthentication
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Authentication/Add-KrGitHubAuthentication.ps1
Tag: Kestrun/Kestrun@0d738bf294e6281b936d031e1979d928007495ff
Line coverage
0%
Covered lines: 0
Uncovered lines: 4
Coverable lines: 4
Total lines: 77
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 11/19/2025 - 02:25:56 Line coverage: 0% (0/4) Total lines: 55 Tag: Kestrun/Kestrun@98ff905e5605a920343154665980a71211a03c6d12/12/2025 - 17:27:19 Line coverage: 0% (0/4) Total lines: 77 Tag: Kestrun/Kestrun@826bf9dcf9db118c5de4c78a3259bce9549f0dcd

Metrics

File(s)

/home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Authentication/Add-KrGitHubAuthentication.ps1

#LineLine coverage
 1<#
 2.SYNOPSIS
 3    Adds GitHub OAuth (Authorization Code) authentication to the Kestrun server.
 4.DESCRIPTION
 5    Convenience wrapper around the C# extension AddGitHubOAuthAuthentication. Registers three schemes:
 6      <Name>, <Name>.Cookies, <Name>.Policy
 7    Includes PKCE, saves tokens, maps login & avatar claims, and can enrich email from /user/emails.
 8.PARAMETER Server
 9    The Kestrun server instance. If omitted, uses the current active server.
 10.PARAMETER AuthenticationScheme
 11    Base scheme name (default 'GitHub').
 12.PARAMETER DisplayName
 13    Display name for the authentication scheme.
 14.PARAMETER Description
 15    A description of the GitHub authentication scheme.
 16.PARAMETER DocId
 17    Documentation IDs for the authentication scheme.
 18.PARAMETER ClientId
 19    GitHub OAuth App Client ID.
 20.PARAMETER ClientSecret
 21    GitHub OAuth App Client Secret.
 22.PARAMETER CallbackPath
 23    Optional callback path (default '/signin-oauth'). Must match your GitHub OAuth App redirect URL path.
 24.PARAMETER PassThru
 25    Return the modified server object.
 26.EXAMPLE
 27    Add-KrGitHubAuthentication -ClientId $env:GITHUB_CLIENT_ID -ClientSecret $env:GITHUB_CLIENT_SECRET
 28.EXAMPLE
 29    Add-KrGitHubAuthentication -AuthenticationScheme 'GitHubMain' -ClientId 'abc' -ClientSecret 'secret' -Scope 'gist' -
 30.NOTES
 31    Requires the generic OAuth2 infrastructure plus provider-specific handling in C#.
 32#>
 33function Add-KrGitHubAuthentication {
 34    [KestrunRuntimeApi('Definition')]
 35    [CmdletBinding()]
 36    [OutputType([Kestrun.Hosting.KestrunHost])]
 37    param(
 38        [Parameter(ValueFromPipeline = $true)]
 39        [Kestrun.Hosting.KestrunHost]$Server,
 40
 41        [Parameter()]
 42        [string]$AuthenticationScheme = [Kestrun.Authentication.AuthenticationDefaults]::GitHubAuthenticationSchemeName,
 43
 44        [Parameter()]
 45        [string]$DisplayName = [Kestrun.Authentication.AuthenticationDefaults]::GitHubDisplayName,
 46
 47        [Parameter()]
 48        [string[]]$DocId = [Kestrun.Authentication.IOpenApiAuthenticationOptions]::DefaultDocumentationIds,
 49
 50        [Parameter()]
 51        [string]$Description,
 52
 53        [Parameter(Mandatory = $true)]
 54        [string]$ClientId,
 55        [Parameter(Mandatory = $true)]
 56        [string]$ClientSecret,
 57        [string]$CallbackPath = '/signin-oauth',
 58        [switch]$PassThru
 59    )
 60    begin {
 061        $Server = Resolve-KestrunServer -Server $Server
 62    }
 63    process {
 064        [Kestrun.Hosting.KestrunHostAuthnExtensions]::AddGitHubOAuthAuthentication(
 65            $Server,
 66            $AuthenticationScheme,
 67            $DisplayName,
 68            $DocId,
 69            $Description,
 70            $ClientId,
 71            $ClientSecret,
 72            $CallbackPath
 073        ) | Out-Null
 74
 075        if ($PassThru) { return $Server }
 76    }
 77}

Methods/Properties

Add-KrGitHubAuthentication()