Skip to content

Commit

Permalink
Login with One-time password for Two-factor authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
franklupo committed Sep 8, 2023
1 parent e4b0e6f commit 52311ee
Show file tree
Hide file tree
Showing 6 changed files with 691 additions and 681 deletions.
2 changes: 1 addition & 1 deletion 3rd-party-licenses.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# License overview of included 3rd party libraries

The project is licensed under the terms of the [LICENSE.md](LICENSE.md)
The project is licensed under the terms of the [LICENSE](LICENSE)

However, includes several third-party Open-Source libraries, which are licensed under their own respective Open-Source licenses.

Expand Down
4 changes: 2 additions & 2 deletions Corsinvest.ProxmoxVE.Api/Corsinvest.ProxmoxVE.Api.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Generated by: Daniele Corsini
#
# Generated on: 26/08/2023
# Generated on: 08/09/2023
#

@{
Expand All @@ -12,7 +12,7 @@
RootModule = 'Corsinvest.ProxmoxVE.Api.psm1'

# Version number of this module.
ModuleVersion = '8.0.1'
ModuleVersion = '8.0.2'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
10 changes: 10 additions & 0 deletions Corsinvest.ProxmoxVE.Api/Corsinvest.ProxmoxVE.Api.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ Skips certificate validation checks.
Username and password, username formatted as user@pam, user@pve, user@yourdomain or user (default domain pam).
.PARAMETER ApiToken
Api Token format USER@REALM!TOKENID=UUID
.PARAMETER Otp
One-time password for Two-factor authentication.
.PARAMETER SkipRefreshPveTicketLast
Skip refresh PveTicket Last global variable
.EXAMPLE
Expand All @@ -79,6 +81,8 @@ PveTicket. Return ticket connection.

[string]$ApiToken,

[string]$Otp,

[switch]$SkipCertificateCheck,

[switch]$SkipRefreshPveTicketLast
Expand Down Expand Up @@ -127,13 +131,19 @@ PveTicket. Return ticket connection.
password = $Credentials.GetNetworkCredential().Password
}

if($PSBoundParameters['Otp']) { $parameters['otp'] = $Otp }

$response = Invoke-PveRestApi -PveTicket $pveTicket -Method Create -Resource '/access/ticket' -Parameters $parameters

#erro response
if (!$response.IsSuccessStatusCode -or $response.StatusCode -le 0) {
throw $response.ReasonPhrase
}

if ($response.Response.data.NeedTFA){
throw "Couldn't authenticate user: missing Two Factor Authentication (TFA)"
}

$pveTicket.Ticket = $response.Response.data.ticket
$pveTicket.CSRFPreventionToken = $response.Response.data.CSRFPreventionToken
}
Expand Down
Loading

0 comments on commit 52311ee

Please sign in to comment.