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
Action appSignOn
missing from * okta/policyRuleActions.go#PolicyRuleActions *
#286
Comments
appSignOn
missing from *okta/policyRuleActions.go#PolicyRuleActions*appSignOn
missing from * okta/policyRuleActions.go#PolicyRuleActions *
Thanks for reporting this @mimatache! Someone from our team will into it soon. cc @monde |
@mimatache we are working on a patch update on our SDKs, I'll see if I can get this in also. |
@mimatache can you give me a sample of the JSON you are seeing and little bit more of your code? In the API spec that all of our SDKs are generated from there is a Here are the related models that are generated in golang
I'm wondering if you are missing a casting in your implementation. Something like |
Hello @monde , Glad to see such a quick response from 👍 . I hope this is all the information you requested From an API call with Postman to the URI {
"id": "ruleID",
"status": "ACTIVE",
"name": "Admin App Policy",
"priority": 0,
"created": "2022-03-25T09:58:52.000Z",
"lastUpdated": "2022-03-25T09:58:52.000Z",
"system": false,
"conditions": {
"people": {
"users": {
"exclude": []
}
},
"network": {
"connection": "ANYWHERE"
},
"userType": {
"include": [],
"exclude": []
}
},
"actions": {
"appSignOn": {
"access": "ALLOW",
"verificationMethod": {
"factorMode": "2FA",
"type": "ASSURANCE",
"reauthenticateIn": "PT0S",
"constraints": [
{
"knowledge": {
"types": [
"password"
],
"reauthenticateIn": "PT43800H"
}
}
]
}
}
},
"_links": {
"self": {
"href": "https://account.okta.com/api/v1/policies/somePolicyID/rules/ruleID",
"hints": {
"allow": [
"GET",
"PUT",
"DELETE"
]
}
},
"deactivate": {
"href": "https://account.okta.com/api/v1/policies/somePolicyID/rules/ruleID/lifecycle/deactivate",
"hints": {
"allow": [
"POST"
]
}
}
},
"type": "ACCESS_POLICY"
} As for the code, here is a test that gives the same results as the code I am using: package rule_test
import (
"context"
"encoding/json"
"fmt"
"testing"
"github.com/okta/okta-sdk-golang/v2/okta"
)
func Test_GetAccessRule(t *testing.T) {
_, client, err := okta.NewClient(
context.TODO(),
okta.WithOrgUrl("account.okta.com"),
okta.WithToken("some-long-token"),
)
if err != nil {
t.Fail()
}
rls, _, err := client.Policy.ListPolicyRules(context.TODO(), "somePolicyID")
if err != nil {
t.Fail()
}
data, err := json.MarshalIndent(rls, "", " ")
if err != nil {
t.Fail()
}
fmt.Println(string(data))
} As for the Let me know if you need anything else from me. |
Just posting this up for others looking for sample code ...
package main
import (
"context"
"encoding/json"
"fmt"
"log"
"github.com/okta/okta-sdk-golang/v2/okta"
"github.com/okta/okta-sdk-golang/v2/okta/query"
)
func main() {
_, client, err := okta.NewClient(
context.TODO(),
// OKTA_CLIENT_TOKEN set in env
// OKTA_CLIENT_ORGURL set in env
)
if err != nil {
log.Fatalf("client: %+v\n", err)
}
policies, _, err := client.Policy.ListPolicies(context.TODO(), &query.Params{Type: "ACCESS_POLICY"})
if err != nil {
log.Fatalf("list policies: %+v\n", err)
}
for _, policy := range policies {
//policy := okta.AccessPolicy(p)
fmt.Printf("\n================= policy (%T) %s : %s ============\n\n", policy, policy.Id, policy.Name)
rls, _, err := client.Policy.ListPolicyRules(context.TODO(), policy.Id)
if err != nil {
log.Fatalf("list policy rules: %+v\n", err)
}
for _, rule := range rls {
//actions := rule.Actions.(*okta.AccessPolicyRuleActions)
fmt.Printf(" ---- policy rule (%T) %s : %s : %s ----\n", rule, rule.Id, rule.Type, rule.Name)
//data, err := json.MarshalIndent(rule.(*okta.AccessPolicyRule).Actions, "", " ")
data, err := json.MarshalIndent(rule.Actions, "", " ")
if err != nil {
log.Fatalf("json: %+v\n", err)
}
fmt.Println(" action")
fmt.Printf(" %T\n %s\n\n", rule.Actions, string(data))
}
}
} |
Ok, @mimatache I had to refresh memory of the architecture of the okta-sdk-golang. Basically, it is half polymorphic (on the write), in that if you created an access policy rule like: rule := okta.AccessPolicyRule{
Actions: &okta.AccessPolicyRuleActions {
AppSignOn: &okta.AccessPolicyRuleApplicationSignOn {
Access: "some value",
},
},
} you can the call update policy rule with that access policy rule, something like _, _, err := client.Policy.UpdatePolicyRule(ctx, policyId, ruleId, rule) It isn't polymorphic on the read, which is what I thought it would do, but can see that it doesn't. rls, _, err := client.Policy.ListPolicyRulesTyped(context.TODO(), "somePolicyID", okta.AccessPolicyRule) or define We are getting ready to update the API spec (and the code generator tooling) that all of the Okta SDK languages use to generate their code. I'm not certain I'll be able to address this issue in v2.11.X of okta-sdk-golang or if it will be addressed in v3.0.0 when we change the way we generate the golang code. |
Thank you for the update. I can probably work around this issue at this point. |
v3 of the Okta API spec will be supported in golang in the next couple of months. I marked the issue with a v3 label and will keep it open to mark that we should address this then. The Okta Java SDK has a beta out now https://github.com/okta/okta-sdk-java/releases/tag/okta-sdk-root-9.0.0-beta so know that this is a high priority in Okta Developer Experience team. My time is getting pulled between all of our golang items, okta-sdk-golang, and the Okta Terraform provider. |
This issue has been marked stale because there has been no activity within the last 14 days. To keep this issue active, remove the |
Hi!
|
Describe the bug?
When using the
client.Policy.ListPolicyRules(ctx, "policyID")
theappSignOn
attribute is missing from the Go struct, even though it is present in the JSON Response.Looking at the struct used to return the body, this attribute/tag is missing from the representation:
What is expected to happen?
I expect the Go structs to match the JSON Response received from the server
What is the actual behavior?
Some fields that are present in the JSON are missing from the Go representation.
Reproduction Steps?
For our case, the issue is present in the Okta Admin Console policy
Additional Information?
No response
Golang Version
go version go1.18 linux/amd64
SDK Version
v2.11.1
OS version
No response
The text was updated successfully, but these errors were encountered: