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 default to refresh token #1738

Merged
merged 3 commits into from
Sep 27, 2023

Conversation

duytiennguyen-okta
Copy link
Contributor

@duytiennguyen-okta duytiennguyen-okta commented Sep 25, 2023

In resource okta_app_oauth, sets refresh_token_rotation's default argument to STATIC, and sets refresh_token_leeway's default argument to 0.

@duytiennguyen-okta duytiennguyen-okta marked this pull request as ready for review September 27, 2023 21:11
@monde monde self-requested a review September 27, 2023 21:15
@duytiennguyen-okta duytiennguyen-okta merged commit e3998e2 into master Sep 27, 2023
2 checks passed
@duytiennguyen-okta duytiennguyen-okta deleted the OKTA-626970-add-default-to-refresh-token branch September 27, 2023 21:22
@monde monde mentioned this pull request Oct 9, 2023
@monde
Copy link
Collaborator

monde commented Oct 10, 2023

@thatguysimon
Copy link
Contributor

@duytiennguyen-okta @monde Seems like this needs to be ignored for all okta_app_oauth resources with type = service that use a private key for authentication. We're getting the following error for all of our service apps since upgrading:

│ Error: failed to update OAuth application: the API returned an error: You do not have permission to perform the requested action
│ 
│   with okta_app_oauth.my_service_app,
│   on applications.tf line 55, in resource "okta_app_oauth" "my_service_app":
│   55: resource "okta_app_oauth" "my_service_app" {
│ 

Apps with type = "web" applied this change successfully.

@duytiennguyen-okta
Copy link
Contributor Author

duytiennguyen-okta commented Oct 24, 2023

@thatguysimon how does the tf script looks like? because I don't have that issue with type = "service" and token_endpoint_auth_method = "private_key_jwt". From the error it looks like you don't have permission rather than the issue came from the provider

@thatguysimon
Copy link
Contributor

@duytiennguyen-okta other apps that are not type=service work as expected so I don't think it's a permission issue.
Here's an example for a service app that is having this issue:

resource "okta_app_oauth" "my_service_app" {
  client_id                  = var.my_service_app_id
  label                      = "My service app"
  logo                       = "${path.module}/assets/images/logo.png"
  type                       = "service"
  grant_types                = ["client_credentials"]
  response_types             = ["token"]
  token_endpoint_auth_method = "private_key_jwt"
  login_scopes               = []
  post_logout_redirect_uris  = []
  redirect_uris              = []

  jwks {
    kty = var.my_public_jwk.kty
    e   = var.my_public_jwk.e
    kid = var.my_public_jwk.kid
    n   = var.my_public_jwk.n
  }

  lifecycle {
    ignore_changes = [
      logo,
    ]
  }
}

Here's an OIDC app that works:

resource "okta_app_oauth" "my_oidc_app" {
  client_id           = var.my_client_id
  client_basic_secret = var.my_client_secret
  label               = "My app"
  logo                = "${path.module}/assets/images/logo.png"
  type                = "web"
  issuer_mode         = "DYNAMIC"
  grant_types = [
    "authorization_code", "refresh_token"
  ]
  redirect_uris = [
    "..."
  ]
  response_types = ["code"]
  login_uri      = var.my_host_url

  lifecycle {
    ignore_changes = [
      logo,
    ]
  }
}

Thanks!

@duytiennguyen-okta
Copy link
Contributor Author

duytiennguyen-okta commented Oct 24, 2023

@thatguysimon I think you should double check your permission. I just successfully run this script with my org

resource "okta_app_oauth" "test" {
  client_id                  = "efg456"
  label                      = "My service app"
  type                       = "service"
  grant_types                = ["client_credentials"]
  response_types             = ["token"]
  token_endpoint_auth_method = "private_key_jwt"
  login_scopes               = []
  post_logout_redirect_uris  = []
  redirect_uris              = []

  jwks {
    kty = var.my_public_jwk.kty
    e   = var.my_public_jwk.e
    kid = var.my_public_jwk.kid
    n   = var.my_public_jwk.n
  }

  lifecycle {
    ignore_changes = [
      logo,
    ]
  }
}

@thatguysimon
Copy link
Contributor

@duytiennguyen-okta was there a new Okta API scope that been added along with this feature? Because this was working before the upgrade, no permission issues before. (We're using a private key to authenticate the provider against the Okta tenant btw).
Maybe this has to do with creating the app in an earlier version of the provider (without this default), and then upgrading the provider and running plan+apply with this new change?

@duytiennguyen-okta
Copy link
Contributor Author

duytiennguyen-okta commented Oct 24, 2023

@thatguysimon I don't know which version you were upgrading from, but the default wouldn't do anything unless you have grant types refresh_token. Since I cannot reproduce this issue, can you provide the log? Just use
TF_LOG=debug terraform apply

@thatguysimon
Copy link
Contributor

@duytiennguyen-okta it suddenly started working, without making any changes.. one of those voodoo cases I guess 🤷🏻‍♂️
Anyway, sorry and thanks for your time 🙏🏻

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.

3 participants