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

Handle inconsistent URL path prefix across okta libs, fixing MFA regression #8807

Merged
merged 2 commits into from Apr 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion builtin/credential/okta/backend.go
Expand Up @@ -100,7 +100,7 @@ func (b *backend) Login(ctx context.Context, req *logical.Request, username stri
StateToken string `json:"stateToken"`
}

authReq, err := shim.NewRequest("POST", "/api/v1/authn", map[string]interface{}{
authReq, err := shim.NewRequest("POST", "authn", map[string]interface{}{
"username": username,
"password": password,
})
Expand Down
9 changes: 9 additions & 0 deletions builtin/credential/okta/backend_test.go
Expand Up @@ -15,6 +15,15 @@ import (
"github.com/hashicorp/vault/sdk/logical"
)

// To run this test, set the following env variables:
// VAULT_ACC=1
// OKTA_ORG=dev-219337
// OKTA_API_TOKEN=<find in 1password>
// OKTA_USERNAME=test2@example.com
// OKTA_PASSWORD=<find in 1password>
//
// You will need to install the Okta client app on your mobile device and
// setup MFA.
func TestBackend_Config(t *testing.T) {
defaultLeaseTTLVal := time.Hour * 12
maxLeaseTTLVal := time.Hour * 24
Expand Down
4 changes: 4 additions & 0 deletions builtin/credential/okta/path_config.go
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/hashicorp/go-cleanhttp"
"net/http"
"net/url"
"strings"
"time"

oktaold "github.com/chrismalek/oktasdk-go/okta"
Expand Down Expand Up @@ -282,6 +283,9 @@ func (new *oktaShimNew) Client() *oktanew.Client {
}

func (new *oktaShimNew) NewRequest(method string, url string, body interface{}) (*http.Request, error) {
if !strings.HasPrefix(url, "/") {
url = "/api/v1/" + url
}
return new.client.GetRequestExecutor().NewRequest(method, url, body)
}

Expand Down