Skip to content

Commit f3a6277

Browse files
authored
feat: add OIDC Direct IdP Login URL retrieval functionality /v1/oidc/direct-idp-login-url (11.19) (#859)
* fix: refactor Jamf Protect functions * feat: add OIDC Direct IdP Login URL retrieval functionality /v1/oidc/direct-idp-login-url * chore: update API reference for OIDC Direct IdP Login URL
1 parent 7c280e1 commit f3a6277

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package main
2+
3+
import (
4+
"encoding/json"
5+
"fmt"
6+
"log"
7+
8+
"github.com/deploymenttheory/go-api-sdk-jamfpro/sdk/jamfpro"
9+
)
10+
11+
func main() {
12+
// Define the path to the JSON configuration file
13+
configFilePath := "/Users/Shared/GitHub/go-api-sdk-jamfpro/localtesting/clientconfig.json"
14+
15+
// Initialize the Jamf Pro client with the HTTP client configuration
16+
client, err := jamfpro.BuildClientWithConfigFile(configFilePath)
17+
if err != nil {
18+
log.Fatalf("Failed to initialize Jamf Pro client: %v", err)
19+
}
20+
21+
// Get the OIDC Direct IdP Login URL
22+
oIDCDirectIdPLoginURLResponse, err := client.GetDirectURLForOIDCLogin()
23+
if err != nil {
24+
log.Fatalf("Error retrieving OIDC direct IdP login URL: %v", err)
25+
}
26+
27+
// Pretty print the response in JSON
28+
oIDCDirectIdPLoginURLJSON, err := json.MarshalIndent(oIDCDirectIdPLoginURLResponse, "", " ")
29+
if err != nil {
30+
log.Fatalf("Error marshaling OIDC direct IdP login URL data: %v", err)
31+
}
32+
fmt.Println("OIDC Direct IdP Login URL Details:\n", string(oIDCDirectIdPLoginURLJSON))
33+
}

sdk/jamfpro/jamfproapi_oidc.go

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// jamfproapi_oidc.go
22
// Jamf Pro Api - OIDC
33
// api reference: https://developer.jamf.com/jamf-pro/reference/get_v1-oidc-public-key
4+
// https://developer.jamf.com/jamf-pro/reference/get_v1-oidc-direct-idp-login-url
45
// Jamf Pro Api requires the structs to support an JSON data structure.
56

67
package jamfpro
@@ -9,7 +10,12 @@ import "fmt"
910

1011
const uriOIDC = "/api/v1/oidc"
1112

12-
// ResponseOIDCPublicKeyrepresents the response structure for the OIDC public key.
13+
// ResponseOIDCDirectIdPLoginURL represents the response structure for the OIDC Direct IdP Login URL.
14+
type ResponseOIDCDirectIdPLoginURL struct {
15+
URL string `json:"url"`
16+
}
17+
18+
// ResponseOIDCPublicKey represents the response structure for the OIDC public key.
1319
type ResponseOIDCPublicKey struct {
1420
Keys []ResourceOIDCKey `json:"keys"`
1521
}
@@ -36,6 +42,23 @@ type ResponseOIDCRedirectURL struct {
3642
RedirectURL string `json:"redirectUrl"`
3743
}
3844

45+
// GetDirectURLForOIDCLogin retrieves the direct IdP login URL for OIDC.
46+
func (c *Client) GetDirectURLForOIDCLogin() (*ResponseOIDCDirectIdPLoginURL, error) {
47+
endpoint := fmt.Sprintf("%s/direct-idp-login-url", uriOIDC)
48+
49+
var response ResponseOIDCDirectIdPLoginURL
50+
resp, err := c.HTTP.DoRequest("GET", endpoint, nil, &response)
51+
if err != nil {
52+
return nil, fmt.Errorf("failed to get OIDC direct IdP login URL: %v", err)
53+
}
54+
55+
if resp != nil && resp.Body != nil {
56+
defer resp.Body.Close()
57+
}
58+
59+
return &response, nil
60+
}
61+
3962
// GetPublicKeyOfOIDCKeystore retrieves the public key of the keystore used for signing OIDC messages as a JWT.
4063
func (c *Client) GetPublicKeyOfOIDCKeystore() (*ResponseOIDCPublicKey, error) {
4164
endpoint := fmt.Sprintf("%s/public-key", uriOIDC)

0 commit comments

Comments
 (0)