Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for v5 signatures #48

Merged
merged 9 commits into from
Feb 5, 2024

Conversation

jaherne-duo
Copy link
Contributor

@jaherne-duo jaherne-duo commented Aug 24, 2023

Description

This PR adds a new function JSONSignedCall(). Calls made through this function will use a v5 signature automatically.

Motivation and Context

V5 signatures and params encoded as JSON are required for the new policy API endpoints (see https://duo.com/docs/adminapi#policies). However, updating the existing SignedCall function would break existing golang client users. By adding a separate call, we can add support for future policy calls without disrupting existing code.

How Has This Been Tested?

Added new tests for the internal functions. Also verified the new call works with GETs and POSTs, both with and without params.

Example of how to use the new function:

func EnrollStatusV5(api *duoapi.DuoApi, userid string,
	activationCode string) (*authapi.EnrollStatusResult, error) {
	params := duoapi.JSONParams{
		"user_id":         userid,
		"activation_code": activationCode,
	}
	_, body, err := api.JSONSignedCall("POST", "/auth/v2/enroll_status", params)
	ret := &authapi.EnrollStatusResult{}
	if err = json.Unmarshal(body, ret); err != nil {
		return nil, err
	}
	return ret, nil
}

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

duoapi.go Outdated Show resolved Hide resolved
Copy link
Contributor

@yizshi yizshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the canonicalization part looks right to me

duoapi.go Outdated Show resolved Hide resolved
duoapi.go Outdated Show resolved Hide resolved
@AaronAtDuo AaronAtDuo merged commit bb361ad into duosecurity:master Feb 5, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants