Skip to content

Commit 15c4b9d

Browse files
varmax2511Maxrovr
authored andcommitted
Added - IAM DB Federated SSO for Oracle DB
1 parent e1089b2 commit 15c4b9d

8 files changed

+296
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
2+
// Licensed under the Mozilla Public License v2.0
3+
4+
5+
variable "public_key" {
6+
default = "-----BEGIN PUBLIC KEY-----MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuYNxKqyNSTPApIVh1xiR3914Q8Ex+goi8kbMUjMa/b47A12SGdh18SAsZTTkld09MGhIswyv2Eln5MQKyupf646zk0E0kxH4llpfSAtUEaa5bxRXhko5BejvimMy4hCMn+kYkzAre7CoAw97rZ96L+TgkqdtwYXl0JzE4xYwfM7OqkH9/3TIeiX4q8kVDi0CsHMGbBo4gMIIunLoEn27ej/Vm6Nbkgl8AnJaWZq8gG8y6ojDLrJhnTK4IVYZ3XYx2uxz/E5VcjMaTdWVjKVCS4F2yK9hFbL1G2KDDh8k3G7dFDFwGI6qxwidbZW7JtcXQWu0Qx0tBNdB28VlsDWZEQIDAQAB-----END PUBLIC KEY-----"
7+
}
8+
9+
variable "scope" {
10+
default = "urn:oracle:db::id::*"
11+
}
12+
13+
resource "oci_identity_data_plane_generate_scoped_access_token" "test_scoped_access_token" {
14+
#Required
15+
public_key = var.public_key
16+
scope = var.scope
17+
}

oci/export_definitions.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1982,6 +1982,11 @@ var exportIdentityDomainHints = &TerraformResourceHints{
19821982
},
19831983
}
19841984

1985+
var exportIdentityDataPlaneGenerateScopedAccessTokenHints = &TerraformResourceHints{
1986+
resourceClass: "oci_identity_data_plane_generate_scoped_access_token",
1987+
resourceAbbreviation: "generate_scoped_access_token",
1988+
}
1989+
19851990
var exportIdentityDbCredentialHints = &TerraformResourceHints{
19861991
resourceClass: "oci_identity_db_credential",
19871992
datasourceClass: "oci_identity_db_credentials",

oci/export_graphs.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ var compartmentResourceGraphs = map[string]TerraformResourceGraph{
4848
"functions": functionsResourceGraph,
4949
"golden_gate": goldenGateResourceGraph,
5050
"health_checks": healthChecksResourceGraph,
51+
"identity_data_plane": identityDataPlaneResourceGraph,
5152
"integration": integrationResourceGraph,
5253
"jms": jmsResourceGraph,
5354
"kms": kmsResourceGraph,
@@ -749,6 +750,10 @@ var identityResourceGraph = TerraformResourceGraph{
749750
},
750751
}
751752

753+
var identityDataPlaneResourceGraph = TerraformResourceGraph{
754+
"oci_identity_compartment": {},
755+
}
756+
752757
var integrationResourceGraph = TerraformResourceGraph{
753758
"oci_identity_compartment": {
754759
{TerraformResourceHints: exportIntegrationIntegrationInstanceHints},

oci/identity_data_plane_clients.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
2+
// Licensed under the Mozilla Public License v2.0
3+
4+
package oci
5+
6+
import (
7+
oci_identity_data_plane "github.com/oracle/oci-go-sdk/v53/identitydataplane"
8+
9+
oci_common "github.com/oracle/oci-go-sdk/v53/common"
10+
)
11+
12+
func init() {
13+
RegisterOracleClient("oci_identity_data_plane.DataplaneClient", &OracleClient{InitClientFn: initIdentitydataplaneDataplaneClient})
14+
}
15+
16+
func initIdentitydataplaneDataplaneClient(configProvider oci_common.ConfigurationProvider, configureClient ConfigureClient, serviceClientOverrides ServiceClientOverrides) (interface{}, error) {
17+
client, err := oci_identity_data_plane.NewDataplaneClientWithConfigurationProvider(configProvider)
18+
if err != nil {
19+
return nil, err
20+
}
21+
err = configureClient(&client.BaseClient)
22+
if err != nil {
23+
return nil, err
24+
}
25+
26+
if serviceClientOverrides.hostUrlOverride != "" {
27+
client.Host = serviceClientOverrides.hostUrlOverride
28+
}
29+
return &client, nil
30+
}
31+
32+
func (m *OracleClients) dataplaneClient() *oci_identity_data_plane.DataplaneClient {
33+
return m.GetClient("oci_identity_data_plane.DataplaneClient").(*oci_identity_data_plane.DataplaneClient)
34+
}
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
// Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
2+
// Licensed under the Mozilla Public License v2.0
3+
4+
package oci
5+
6+
import (
7+
"context"
8+
9+
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
10+
11+
oci_identity_data_plane "github.com/oracle/oci-go-sdk/v53/identitydataplane"
12+
)
13+
14+
func init() {
15+
RegisterResource("oci_identity_data_plane_generate_scoped_access_token", IdentityDataPlaneGenerateScopedAccessTokenResource())
16+
}
17+
18+
func IdentityDataPlaneGenerateScopedAccessTokenResource() *schema.Resource {
19+
return &schema.Resource{
20+
Importer: &schema.ResourceImporter{
21+
State: schema.ImportStatePassthrough,
22+
},
23+
Timeouts: DefaultTimeout,
24+
Create: createIdentityDataPlaneGenerateScopedAccessToken,
25+
Read: readIdentityDataPlaneGenerateScopedAccessToken,
26+
Delete: deleteIdentityDataPlaneGenerateScopedAccessToken,
27+
Schema: map[string]*schema.Schema{
28+
// Required
29+
"public_key": {
30+
Type: schema.TypeString,
31+
Required: true,
32+
ForceNew: true,
33+
},
34+
"scope": {
35+
Type: schema.TypeString,
36+
Required: true,
37+
ForceNew: true,
38+
},
39+
40+
// Optional
41+
42+
// Computed
43+
"token": {
44+
Type: schema.TypeString,
45+
Computed: true,
46+
},
47+
},
48+
}
49+
}
50+
51+
func createIdentityDataPlaneGenerateScopedAccessToken(d *schema.ResourceData, m interface{}) error {
52+
sync := &IdentityDataPlaneGenerateScopedAccessTokenResourceCrud{}
53+
sync.D = d
54+
sync.Client = m.(*OracleClients).dataplaneClient()
55+
56+
return CreateResource(d, sync)
57+
}
58+
59+
func readIdentityDataPlaneGenerateScopedAccessToken(d *schema.ResourceData, m interface{}) error {
60+
return nil
61+
}
62+
63+
func deleteIdentityDataPlaneGenerateScopedAccessToken(d *schema.ResourceData, m interface{}) error {
64+
return nil
65+
}
66+
67+
type IdentityDataPlaneGenerateScopedAccessTokenResourceCrud struct {
68+
BaseCrud
69+
Client *oci_identity_data_plane.DataplaneClient
70+
Res *oci_identity_data_plane.SecurityToken
71+
DisableNotFoundRetries bool
72+
}
73+
74+
func (s *IdentityDataPlaneGenerateScopedAccessTokenResourceCrud) ID() string {
75+
return *s.Res.Token
76+
}
77+
78+
func (s *IdentityDataPlaneGenerateScopedAccessTokenResourceCrud) Create() error {
79+
request := oci_identity_data_plane.GenerateScopedAccessTokenRequest{}
80+
81+
if publicKey, ok := s.D.GetOkExists("public_key"); ok {
82+
tmp := publicKey.(string)
83+
request.PublicKey = &tmp
84+
}
85+
86+
if scope, ok := s.D.GetOkExists("scope"); ok {
87+
tmp := scope.(string)
88+
request.Scope = &tmp
89+
}
90+
91+
request.RequestMetadata.RetryPolicy = GetRetryPolicy(s.DisableNotFoundRetries, "identity_data_plane")
92+
93+
response, err := s.Client.GenerateScopedAccessToken(context.Background(), request)
94+
if err != nil {
95+
return err
96+
}
97+
98+
s.Res = &response.SecurityToken
99+
return nil
100+
}
101+
102+
func (s *IdentityDataPlaneGenerateScopedAccessTokenResourceCrud) SetData() error {
103+
if s.Res.Token != nil {
104+
s.D.Set("token", *s.Res.Token)
105+
}
106+
107+
return nil
108+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
2+
// Licensed under the Mozilla Public License v2.0
3+
4+
package oci
5+
6+
import (
7+
"fmt"
8+
"strconv"
9+
"testing"
10+
11+
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
12+
"github.com/hashicorp/terraform-plugin-sdk/terraform"
13+
14+
"github.com/terraform-providers/terraform-provider-oci/httpreplay"
15+
)
16+
17+
var (
18+
generateScopedAccessTokenRepresentation = map[string]interface{}{
19+
"public_key": Representation{RepType: Required, Create: `-----BEGIN PUBLIC KEY-----MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuYNxKqyNSTPApIVh1xiR3914Q8Ex+goi8kbMUjMa/b47A12SGdh18SAsZTTkld09MGhIswyv2Eln5MQKyupf646zk0E0kxH4llpfSAtUEaa5bxRXhko5BejvimMy4hCMn+kYkzAre7CoAw97rZ96L+TgkqdtwYXl0JzE4xYwfM7OqkH9/3TIeiX4q8kVDi0CsHMGbBo4gMIIunLoEn27ej/Vm6Nbkgl8AnJaWZq8gG8y6ojDLrJhnTK4IVYZ3XYx2uxz/E5VcjMaTdWVjKVCS4F2yK9hFbL1G2KDDh8k3G7dFDFwGI6qxwidbZW7JtcXQWu0Qx0tBNdB28VlsDWZEQIDAQAB-----END PUBLIC KEY-----`},
20+
"scope": Representation{RepType: Required, Create: `urn:oracle:db::id::*`},
21+
}
22+
23+
GenerateScopedAccessTokenResourceDependencies = ""
24+
)
25+
26+
// issue-routing-tag: identity_data_plane/default
27+
func TestIdentityDataPlaneGenerateScopedAccessTokenResource_basic(t *testing.T) {
28+
httpreplay.SetScenario("TestIdentityDataPlaneGenerateScopedAccessTokenResource_basic")
29+
defer httpreplay.SaveScenario()
30+
31+
config := testProviderConfig()
32+
33+
compartmentId := getEnvSettingWithBlankDefault("compartment_ocid")
34+
compartmentIdVariableStr := fmt.Sprintf("variable \"compartment_id\" { default = \"%s\" }\n", compartmentId)
35+
36+
resourceName := "oci_identity_data_plane_generate_scoped_access_token.test_generate_scoped_access_token"
37+
38+
var resId string
39+
// Save TF content to Create resource with only required properties. This has to be exactly the same as the config part in the create step in the test.
40+
SaveConfigContent(config+compartmentIdVariableStr+GenerateScopedAccessTokenResourceDependencies+
41+
GenerateResourceFromRepresentationMap("oci_identity_data_plane_generate_scoped_access_token", "test_generate_scoped_access_token", Required, Create, generateScopedAccessTokenRepresentation), "identitydataplane", "generateScopedAccessToken", t)
42+
43+
ResourceTest(t, nil, []resource.TestStep{
44+
// verify Create
45+
{
46+
Config: config + compartmentIdVariableStr + GenerateScopedAccessTokenResourceDependencies +
47+
GenerateResourceFromRepresentationMap("oci_identity_data_plane_generate_scoped_access_token", "test_generate_scoped_access_token", Required, Create, generateScopedAccessTokenRepresentation),
48+
Check: ComposeAggregateTestCheckFuncWrapper(
49+
resource.TestCheckResourceAttr(resourceName, "public_key", "-----BEGIN PUBLIC KEY-----MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuYNxKqyNSTPApIVh1xiR3914Q8Ex+goi8kbMUjMa/b47A12SGdh18SAsZTTkld09MGhIswyv2Eln5MQKyupf646zk0E0kxH4llpfSAtUEaa5bxRXhko5BejvimMy4hCMn+kYkzAre7CoAw97rZ96L+TgkqdtwYXl0JzE4xYwfM7OqkH9/3TIeiX4q8kVDi0CsHMGbBo4gMIIunLoEn27ej/Vm6Nbkgl8AnJaWZq8gG8y6ojDLrJhnTK4IVYZ3XYx2uxz/E5VcjMaTdWVjKVCS4F2yK9hFbL1G2KDDh8k3G7dFDFwGI6qxwidbZW7JtcXQWu0Qx0tBNdB28VlsDWZEQIDAQAB-----END PUBLIC KEY-----"),
50+
resource.TestCheckResourceAttr(resourceName, "scope", "urn:oracle:db::id::*"),
51+
52+
func(s *terraform.State) (err error) {
53+
resId, err = FromInstanceState(s, resourceName, "id")
54+
if isEnableExportCompartment, _ := strconv.ParseBool(getEnvSettingWithDefault("enable_export_compartment", "true")); isEnableExportCompartment {
55+
if errExport := TestExportCompartmentWithResourceName(&resId, &compartmentId, resourceName); errExport != nil {
56+
return errExport
57+
}
58+
}
59+
return err
60+
},
61+
),
62+
},
63+
})
64+
}

website/docs/guides/resource_discovery.html.markdown

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ The generated `.tf` files contain the Terraform configuration with the resources
149149
* `golden_gate` - Discovers golden_gate resources within the specified compartment
150150
* `health_checks` - Discovers health_checks resources within the specified compartment
151151
* `identity` - Discovers identity resources across the entire tenancy
152+
* `identity_data_plane` - Discovers identity_data_plane resources within the specified compartment
152153
* `integration` - Discovers integration resources within the specified compartment
153154
* `jms` - Discovers jms resources within the specified compartment
154155
* `kms` - Discovers kms resources within the specified compartment
@@ -565,6 +566,10 @@ identity
565566
* oci\_identity\_domain
566567
* oci\_identity\_db\_credential
567568

569+
identity_data_plane
570+
571+
* oci\_identity\_data\_plane\_generate\_scoped\_access\_token
572+
568573
integration
569574

570575
* oci\_integration\_integration\_instance
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
subcategory: "Identity Data Plane"
3+
layout: "oci"
4+
page_title: "Oracle Cloud Infrastructure: oci_identity_data_plane_generate_scoped_access_token"
5+
sidebar_current: "docs-oci-resource-identity_data_plane-generate_scoped_access_token"
6+
description: |-
7+
Provides the Generate Scoped Access Token resource in Oracle Cloud Infrastructure Identity Data Plane service
8+
---
9+
10+
# oci_identity_data_plane_generate_scoped_access_token
11+
This resource provides the Generate Scoped Access Token resource in Oracle Cloud Infrastructure Identity Data Plane service.
12+
13+
Based on the calling principal and the input payload, derive the claims and create a security token.
14+
15+
16+
## Example Usage
17+
18+
```hcl
19+
resource "oci_identity_data_plane_generate_scoped_access_token" "test_generate_scoped_access_token" {
20+
#Required
21+
public_key = var.generate_scoped_access_token_public_key
22+
scope = var.generate_scoped_access_token_scope
23+
}
24+
```
25+
26+
## Argument Reference
27+
28+
The following arguments are supported:
29+
30+
* `public_key` - (Required) A temporary public key, owned by the service. The service also owns the corresponding private key. This public key will by put inside the security token by the auth service after successful validation of the certificate.
31+
* `scope` - (Required) Scope definition for the scoped access token
32+
33+
34+
** IMPORTANT **
35+
Any change to a property that does not support update will force the destruction and recreation of the resource with the new property values
36+
37+
## Attributes Reference
38+
39+
The following attributes are exported:
40+
41+
* `token` - The security token, signed by auth service
42+
43+
## Timeouts
44+
45+
The `timeouts` block allows you to specify [timeouts](https://registry.terraform.io/providers/hashicorp/oci/latest/docs/guides/changing_timeouts) for certain operations:
46+
* `create` - (Defaults to 20 minutes), when creating the Generate Scoped Access Token
47+
* `update` - (Defaults to 20 minutes), when updating the Generate Scoped Access Token
48+
* `delete` - (Defaults to 20 minutes), when destroying the Generate Scoped Access Token
49+
50+
51+
## Import
52+
53+
GenerateScopedAccessToken can be imported using the `id`, e.g.
54+
55+
```
56+
$ terraform import oci_identity_data_plane_generate_scoped_access_token.test_generate_scoped_access_token "id"
57+
```
58+

0 commit comments

Comments
 (0)