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 WebAuth{, Passwordwordless} Policy #356

Merged
merged 15 commits into from
Sep 17, 2020
Merged

Add WebAuth{, Passwordwordless} Policy #356

merged 15 commits into from
Sep 17, 2020

Conversation

klausenbusk
Copy link
Contributor

Fix #355

@klausenbusk

This comment has been minimized.

@svenstaro
Copy link

Why is this failing CI? Sadly I can't see the result on CircleCI somehow.

I'd like to note that without this PR, it's really annoying to operate this provider with an active WebAuthn config as every time the realm is modified via this Terraform provider, the WebAuthn config is reset to defaults which is really tricky if you forget about it and quite the security risk too.

@klausenbusk

This comment has been minimized.

@klausenbusk
Copy link
Contributor Author

@mrparkers CI is green now (I just did a squash of all the commits, but he code didn't change), any chance you could have a look? :)

@mrparkers
Copy link
Contributor

Sorry for the delayed review here. Overall the code looks fine, but I think the schema could potentially be improved by aggregating each of these attributes underneath web_authn_policy and web_authn_passwordless_policy blocks. So it might look something like this:

resource "keycloak_realm" "test" {
  name = "test"

  web_authn_policy {
    rp_entity_name = "keycloak"
  }

  web_authn_passwordless_policy {
    rp_entity_name = "keycloak"
  }
}

This would let you mark attributes such as rp_entity_name as required within the web_authn_policy block.

What do you think about this?

@klausenbusk
Copy link
Contributor Author

What do you think about this?

Sounds good to me, it is a bit easier to manage.

This would let you mark attributes such as rp_entity_name as required within the web_authn_policy block.

Do we want it to be required?

@mrparkers
Copy link
Contributor

I saw that it was required in the GUI, so that's why I mentioned it. But I've never actually used this feature of Keycloak before, so I'll defer to your judgement about whether or not it should be. The only thing I wanted to mention is that this approach would allow us to have a WebAuthn attribute marked as required if we wanted to.

@klausenbusk
Copy link
Contributor Author

klausenbusk commented Sep 11, 2020

I saw that it was required in the GUI, so that's why I mentioned it. But I've never actually used this feature of Keycloak before, so I'll defer to your judgement about whether or not it should be.

I think Default: "keycloak", is good enough. Anyways the schema change is done and CI is green.

Copy link
Contributor

@mrparkers mrparkers left a comment

Choose a reason for hiding this comment

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

just had a few comments about the schema, but overall it looks good.

I do want to add these attributes to an existing test case, or add some new test cases altogether. if you'd prefer, I can work on this and push it to your branch, or you could give it a shot.

provider/resource_keycloak_realm.go Outdated Show resolved Hide resolved
provider/resource_keycloak_realm.go Show resolved Hide resolved
provider/resource_keycloak_realm.go Outdated Show resolved Hide resolved
provider/resource_keycloak_realm.go Outdated Show resolved Hide resolved
provider/resource_keycloak_realm.go Outdated Show resolved Hide resolved
Elem: &schema.Schema{
Type: schema.TypeString,
},
Optional: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

in the schema for the data source, none of these attributes should have Optional: true or Default, and all of them should have Computed: true

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Like this? Should web_authn_policy have Optional: true?

keycloak/realm.go Outdated Show resolved Hide resolved
Type: schema.TypeString,
Description: "Either none, indirect or direct",
Optional: true,
Default: "not specified",
Copy link
Contributor

Choose a reason for hiding this comment

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

I really hate how the Keycloak API uses this as the nil value. I'm not sure how I feel about setting this as the default within the provider package. However, I don't feel strongly enough about this to force you to change it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could use the WebAuthn defaults though. Ex for attestation_conveyance_preference the default is none, any opinions?

@klausenbusk
Copy link
Contributor Author

if you'd prefer, I can work on this and push it to your branch

Feel free to take a stab at it :) The schema should be fixed now and CI is green.

@mrparkers
Copy link
Contributor

I should have left this comment previously, but I missed it. What would you think about being more explicit with the rp_* attributes, so they say relying_party_* instead? Since the UI refers to them this way, I think it would make this more clear.

@klausenbusk

This comment has been minimized.

@klausenbusk
Copy link
Contributor Author

Fine with my. I will change it later.

Done and rebased.

Copy link
Contributor

@mrparkers mrparkers left a comment

Choose a reason for hiding this comment

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

LGTM - thanks for the PR!

@mrparkers mrparkers merged commit 9a0d48f into keycloak:master Sep 17, 2020
hcl31415 pushed a commit to hcl31415/terraform-provider-keycloak that referenced this pull request Oct 12, 2020
hcl31415 pushed a commit to hcl31415/terraform-provider-keycloak that referenced this pull request Oct 12, 2020
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.

Realm WebAuth{, Passwordwordless} Policy
3 participants