1. Packages
  2. Kong Provider
  3. API Docs
  4. ConsumerOauth2
Kong v4.5.6 published on Wednesday, Oct 16, 2024 by Pulumi

kong.ConsumerOauth2

Explore with Pulumi AI

kong logo
Kong v4.5.6 published on Wednesday, Oct 16, 2024 by Pulumi

    # kong.ConsumerOauth2

    Resource that allows you to configure the OAuth2 plugin credentials for a consumer.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as kong from "@pulumi/kong";
    
    const myConsumer = new kong.Consumer("my_consumer", {
        username: "User1",
        customId: "123",
    });
    const oauth2Plugin = new kong.Plugin("oauth2_plugin", {
        name: "oauth2",
        configJson: `\x09{
    \x09\x09"global_credentials": true,
    \x09\x09"enable_password_grant": true,
    \x09\x09"token_expiration": 180,
    \x09\x09"refresh_token_ttl": 180,
    \x09\x09"provision_key": "testprovisionkey"
    \x09}
    `,
    });
    const consumerOauth2 = new kong.ConsumerOauth2("consumer_oauth2", {
        name: "test_application",
        consumerId: myConsumer.id,
        clientId: "client_id",
        clientSecret: "client_secret",
        redirectUris: [
            "https://asdf.com/callback",
            "https://test.cl/callback",
        ],
        tags: ["myTag"],
    });
    
    import pulumi
    import pulumi_kong as kong
    
    my_consumer = kong.Consumer("my_consumer",
        username="User1",
        custom_id="123")
    oauth2_plugin = kong.Plugin("oauth2_plugin",
        name="oauth2",
        config_json="""\x09{
    \x09\x09"global_credentials": true,
    \x09\x09"enable_password_grant": true,
    \x09\x09"token_expiration": 180,
    \x09\x09"refresh_token_ttl": 180,
    \x09\x09"provision_key": "testprovisionkey"
    \x09}
    """)
    consumer_oauth2 = kong.ConsumerOauth2("consumer_oauth2",
        name="test_application",
        consumer_id=my_consumer.id,
        client_id="client_id",
        client_secret="client_secret",
        redirect_uris=[
            "https://asdf.com/callback",
            "https://test.cl/callback",
        ],
        tags=["myTag"])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-kong/sdk/v4/go/kong"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		myConsumer, err := kong.NewConsumer(ctx, "my_consumer", &kong.ConsumerArgs{
    			Username: pulumi.String("User1"),
    			CustomId: pulumi.String("123"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = kong.NewPlugin(ctx, "oauth2_plugin", &kong.PluginArgs{
    			Name: pulumi.String("oauth2"),
    			ConfigJson: pulumi.String(`	{
    		"global_credentials": true,
    		"enable_password_grant": true,
    		"token_expiration": 180,
    		"refresh_token_ttl": 180,
    		"provision_key": "testprovisionkey"
    	}
    `),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = kong.NewConsumerOauth2(ctx, "consumer_oauth2", &kong.ConsumerOauth2Args{
    			Name:         pulumi.String("test_application"),
    			ConsumerId:   myConsumer.ID(),
    			ClientId:     pulumi.String("client_id"),
    			ClientSecret: pulumi.String("client_secret"),
    			RedirectUris: pulumi.StringArray{
    				pulumi.String("https://asdf.com/callback"),
    				pulumi.String("https://test.cl/callback"),
    			},
    			Tags: pulumi.StringArray{
    				pulumi.String("myTag"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Kong = Pulumi.Kong;
    
    return await Deployment.RunAsync(() => 
    {
        var myConsumer = new Kong.Consumer("my_consumer", new()
        {
            Username = "User1",
            CustomId = "123",
        });
    
        var oauth2Plugin = new Kong.Plugin("oauth2_plugin", new()
        {
            Name = "oauth2",
            ConfigJson = @"	{
    		""global_credentials"": true,
    		""enable_password_grant"": true,
    		""token_expiration"": 180,
    		""refresh_token_ttl"": 180,
    		""provision_key"": ""testprovisionkey""
    	}
    ",
        });
    
        var consumerOauth2 = new Kong.ConsumerOauth2("consumer_oauth2", new()
        {
            Name = "test_application",
            ConsumerId = myConsumer.Id,
            ClientId = "client_id",
            ClientSecret = "client_secret",
            RedirectUris = new[]
            {
                "https://asdf.com/callback",
                "https://test.cl/callback",
            },
            Tags = new[]
            {
                "myTag",
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.kong.Consumer;
    import com.pulumi.kong.ConsumerArgs;
    import com.pulumi.kong.Plugin;
    import com.pulumi.kong.PluginArgs;
    import com.pulumi.kong.ConsumerOauth2;
    import com.pulumi.kong.ConsumerOauth2Args;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            var myConsumer = new Consumer("myConsumer", ConsumerArgs.builder()
                .username("User1")
                .customId("123")
                .build());
    
            var oauth2Plugin = new Plugin("oauth2Plugin", PluginArgs.builder()
                .name("oauth2")
                .configJson("""
    	{
    		"global_credentials": true,
    		"enable_password_grant": true,
    		"token_expiration": 180,
    		"refresh_token_ttl": 180,
    		"provision_key": "testprovisionkey"
    	}
                """)
                .build());
    
            var consumerOauth2 = new ConsumerOauth2("consumerOauth2", ConsumerOauth2Args.builder()
                .name("test_application")
                .consumerId(myConsumer.id())
                .clientId("client_id")
                .clientSecret("client_secret")
                .redirectUris(            
                    "https://asdf.com/callback",
                    "https://test.cl/callback")
                .tags("myTag")
                .build());
    
        }
    }
    
    resources:
      myConsumer:
        type: kong:Consumer
        name: my_consumer
        properties:
          username: User1
          customId: '123'
      oauth2Plugin:
        type: kong:Plugin
        name: oauth2_plugin
        properties:
          name: oauth2
          configJson: |
            	{
            		"global_credentials": true,
            		"enable_password_grant": true,
            		"token_expiration": 180,
            		"refresh_token_ttl": 180,
            		"provision_key": "testprovisionkey"
            	}        
      consumerOauth2:
        type: kong:ConsumerOauth2
        name: consumer_oauth2
        properties:
          name: test_application
          consumerId: ${myConsumer.id}
          clientId: client_id
          clientSecret: client_secret
          redirectUris:
            - https://asdf.com/callback
            - https://test.cl/callback
          tags:
            - myTag
    

    Create ConsumerOauth2 Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new ConsumerOauth2(name: string, args: ConsumerOauth2Args, opts?: CustomResourceOptions);
    @overload
    def ConsumerOauth2(resource_name: str,
                       args: ConsumerOauth2Args,
                       opts: Optional[ResourceOptions] = None)
    
    @overload
    def ConsumerOauth2(resource_name: str,
                       opts: Optional[ResourceOptions] = None,
                       consumer_id: Optional[str] = None,
                       redirect_uris: Optional[Sequence[str]] = None,
                       client_id: Optional[str] = None,
                       client_secret: Optional[str] = None,
                       hash_secret: Optional[bool] = None,
                       name: Optional[str] = None,
                       tags: Optional[Sequence[str]] = None)
    func NewConsumerOauth2(ctx *Context, name string, args ConsumerOauth2Args, opts ...ResourceOption) (*ConsumerOauth2, error)
    public ConsumerOauth2(string name, ConsumerOauth2Args args, CustomResourceOptions? opts = null)
    public ConsumerOauth2(String name, ConsumerOauth2Args args)
    public ConsumerOauth2(String name, ConsumerOauth2Args args, CustomResourceOptions options)
    
    type: kong:ConsumerOauth2
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args ConsumerOauth2Args
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args ConsumerOauth2Args
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args ConsumerOauth2Args
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args ConsumerOauth2Args
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args ConsumerOauth2Args
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Constructor example

    The following reference example uses placeholder values for all input properties.

    var consumerOauth2Resource = new Kong.ConsumerOauth2("consumerOauth2Resource", new()
    {
        ConsumerId = "string",
        RedirectUris = new[]
        {
            "string",
        },
        ClientId = "string",
        ClientSecret = "string",
        HashSecret = false,
        Name = "string",
        Tags = new[]
        {
            "string",
        },
    });
    
    example, err := kong.NewConsumerOauth2(ctx, "consumerOauth2Resource", &kong.ConsumerOauth2Args{
    	ConsumerId: pulumi.String("string"),
    	RedirectUris: pulumi.StringArray{
    		pulumi.String("string"),
    	},
    	ClientId:     pulumi.String("string"),
    	ClientSecret: pulumi.String("string"),
    	HashSecret:   pulumi.Bool(false),
    	Name:         pulumi.String("string"),
    	Tags: pulumi.StringArray{
    		pulumi.String("string"),
    	},
    })
    
    var consumerOauth2Resource = new ConsumerOauth2("consumerOauth2Resource", ConsumerOauth2Args.builder()
        .consumerId("string")
        .redirectUris("string")
        .clientId("string")
        .clientSecret("string")
        .hashSecret(false)
        .name("string")
        .tags("string")
        .build());
    
    consumer_oauth2_resource = kong.ConsumerOauth2("consumerOauth2Resource",
        consumer_id="string",
        redirect_uris=["string"],
        client_id="string",
        client_secret="string",
        hash_secret=False,
        name="string",
        tags=["string"])
    
    const consumerOauth2Resource = new kong.ConsumerOauth2("consumerOauth2Resource", {
        consumerId: "string",
        redirectUris: ["string"],
        clientId: "string",
        clientSecret: "string",
        hashSecret: false,
        name: "string",
        tags: ["string"],
    });
    
    type: kong:ConsumerOauth2
    properties:
        clientId: string
        clientSecret: string
        consumerId: string
        hashSecret: false
        name: string
        redirectUris:
            - string
        tags:
            - string
    

    ConsumerOauth2 Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

    The ConsumerOauth2 resource accepts the following input properties:

    ConsumerId string
    The id of the consumer to be configured with oauth2.
    RedirectUris List<string>
    An array with one or more URLs in your app where users will be sent after authorization (RFC 6742 Section 3.1.2).
    ClientId string
    Unique oauth2 client id. If not set, the oauth2 plugin will generate one
    ClientSecret string
    Unique oauth2 client secret. If not set, the oauth2 plugin will generate one
    HashSecret bool
    A boolean flag that indicates whether the client_secret field will be stored in hashed form. If enabled on existing plugin instances, client secrets are hashed on the fly upon first usage. Default: false.
    Name string
    The name associated with the credential.
    Tags List<string>
    A list of strings associated with the consumer for grouping and filtering.
    ConsumerId string
    The id of the consumer to be configured with oauth2.
    RedirectUris []string
    An array with one or more URLs in your app where users will be sent after authorization (RFC 6742 Section 3.1.2).
    ClientId string
    Unique oauth2 client id. If not set, the oauth2 plugin will generate one
    ClientSecret string
    Unique oauth2 client secret. If not set, the oauth2 plugin will generate one
    HashSecret bool
    A boolean flag that indicates whether the client_secret field will be stored in hashed form. If enabled on existing plugin instances, client secrets are hashed on the fly upon first usage. Default: false.
    Name string
    The name associated with the credential.
    Tags []string
    A list of strings associated with the consumer for grouping and filtering.
    consumerId String
    The id of the consumer to be configured with oauth2.
    redirectUris List<String>
    An array with one or more URLs in your app where users will be sent after authorization (RFC 6742 Section 3.1.2).
    clientId String
    Unique oauth2 client id. If not set, the oauth2 plugin will generate one
    clientSecret String
    Unique oauth2 client secret. If not set, the oauth2 plugin will generate one
    hashSecret Boolean
    A boolean flag that indicates whether the client_secret field will be stored in hashed form. If enabled on existing plugin instances, client secrets are hashed on the fly upon first usage. Default: false.
    name String
    The name associated with the credential.
    tags List<String>
    A list of strings associated with the consumer for grouping and filtering.
    consumerId string
    The id of the consumer to be configured with oauth2.
    redirectUris string[]
    An array with one or more URLs in your app where users will be sent after authorization (RFC 6742 Section 3.1.2).
    clientId string
    Unique oauth2 client id. If not set, the oauth2 plugin will generate one
    clientSecret string
    Unique oauth2 client secret. If not set, the oauth2 plugin will generate one
    hashSecret boolean
    A boolean flag that indicates whether the client_secret field will be stored in hashed form. If enabled on existing plugin instances, client secrets are hashed on the fly upon first usage. Default: false.
    name string
    The name associated with the credential.
    tags string[]
    A list of strings associated with the consumer for grouping and filtering.
    consumer_id str
    The id of the consumer to be configured with oauth2.
    redirect_uris Sequence[str]
    An array with one or more URLs in your app where users will be sent after authorization (RFC 6742 Section 3.1.2).
    client_id str
    Unique oauth2 client id. If not set, the oauth2 plugin will generate one
    client_secret str
    Unique oauth2 client secret. If not set, the oauth2 plugin will generate one
    hash_secret bool
    A boolean flag that indicates whether the client_secret field will be stored in hashed form. If enabled on existing plugin instances, client secrets are hashed on the fly upon first usage. Default: false.
    name str
    The name associated with the credential.
    tags Sequence[str]
    A list of strings associated with the consumer for grouping and filtering.
    consumerId String
    The id of the consumer to be configured with oauth2.
    redirectUris List<String>
    An array with one or more URLs in your app where users will be sent after authorization (RFC 6742 Section 3.1.2).
    clientId String
    Unique oauth2 client id. If not set, the oauth2 plugin will generate one
    clientSecret String
    Unique oauth2 client secret. If not set, the oauth2 plugin will generate one
    hashSecret Boolean
    A boolean flag that indicates whether the client_secret field will be stored in hashed form. If enabled on existing plugin instances, client secrets are hashed on the fly upon first usage. Default: false.
    name String
    The name associated with the credential.
    tags List<String>
    A list of strings associated with the consumer for grouping and filtering.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the ConsumerOauth2 resource produces the following output properties:

    Id string
    The provider-assigned unique ID for this managed resource.
    Id string
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.
    id string
    The provider-assigned unique ID for this managed resource.
    id str
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.

    Look up Existing ConsumerOauth2 Resource

    Get an existing ConsumerOauth2 resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

    public static get(name: string, id: Input<ID>, state?: ConsumerOauth2State, opts?: CustomResourceOptions): ConsumerOauth2
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            client_id: Optional[str] = None,
            client_secret: Optional[str] = None,
            consumer_id: Optional[str] = None,
            hash_secret: Optional[bool] = None,
            name: Optional[str] = None,
            redirect_uris: Optional[Sequence[str]] = None,
            tags: Optional[Sequence[str]] = None) -> ConsumerOauth2
    func GetConsumerOauth2(ctx *Context, name string, id IDInput, state *ConsumerOauth2State, opts ...ResourceOption) (*ConsumerOauth2, error)
    public static ConsumerOauth2 Get(string name, Input<string> id, ConsumerOauth2State? state, CustomResourceOptions? opts = null)
    public static ConsumerOauth2 get(String name, Output<String> id, ConsumerOauth2State state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    ClientId string
    Unique oauth2 client id. If not set, the oauth2 plugin will generate one
    ClientSecret string
    Unique oauth2 client secret. If not set, the oauth2 plugin will generate one
    ConsumerId string
    The id of the consumer to be configured with oauth2.
    HashSecret bool
    A boolean flag that indicates whether the client_secret field will be stored in hashed form. If enabled on existing plugin instances, client secrets are hashed on the fly upon first usage. Default: false.
    Name string
    The name associated with the credential.
    RedirectUris List<string>
    An array with one or more URLs in your app where users will be sent after authorization (RFC 6742 Section 3.1.2).
    Tags List<string>
    A list of strings associated with the consumer for grouping and filtering.
    ClientId string
    Unique oauth2 client id. If not set, the oauth2 plugin will generate one
    ClientSecret string
    Unique oauth2 client secret. If not set, the oauth2 plugin will generate one
    ConsumerId string
    The id of the consumer to be configured with oauth2.
    HashSecret bool
    A boolean flag that indicates whether the client_secret field will be stored in hashed form. If enabled on existing plugin instances, client secrets are hashed on the fly upon first usage. Default: false.
    Name string
    The name associated with the credential.
    RedirectUris []string
    An array with one or more URLs in your app where users will be sent after authorization (RFC 6742 Section 3.1.2).
    Tags []string
    A list of strings associated with the consumer for grouping and filtering.
    clientId String
    Unique oauth2 client id. If not set, the oauth2 plugin will generate one
    clientSecret String
    Unique oauth2 client secret. If not set, the oauth2 plugin will generate one
    consumerId String
    The id of the consumer to be configured with oauth2.
    hashSecret Boolean
    A boolean flag that indicates whether the client_secret field will be stored in hashed form. If enabled on existing plugin instances, client secrets are hashed on the fly upon first usage. Default: false.
    name String
    The name associated with the credential.
    redirectUris List<String>
    An array with one or more URLs in your app where users will be sent after authorization (RFC 6742 Section 3.1.2).
    tags List<String>
    A list of strings associated with the consumer for grouping and filtering.
    clientId string
    Unique oauth2 client id. If not set, the oauth2 plugin will generate one
    clientSecret string
    Unique oauth2 client secret. If not set, the oauth2 plugin will generate one
    consumerId string
    The id of the consumer to be configured with oauth2.
    hashSecret boolean
    A boolean flag that indicates whether the client_secret field will be stored in hashed form. If enabled on existing plugin instances, client secrets are hashed on the fly upon first usage. Default: false.
    name string
    The name associated with the credential.
    redirectUris string[]
    An array with one or more URLs in your app where users will be sent after authorization (RFC 6742 Section 3.1.2).
    tags string[]
    A list of strings associated with the consumer for grouping and filtering.
    client_id str
    Unique oauth2 client id. If not set, the oauth2 plugin will generate one
    client_secret str
    Unique oauth2 client secret. If not set, the oauth2 plugin will generate one
    consumer_id str
    The id of the consumer to be configured with oauth2.
    hash_secret bool
    A boolean flag that indicates whether the client_secret field will be stored in hashed form. If enabled on existing plugin instances, client secrets are hashed on the fly upon first usage. Default: false.
    name str
    The name associated with the credential.
    redirect_uris Sequence[str]
    An array with one or more URLs in your app where users will be sent after authorization (RFC 6742 Section 3.1.2).
    tags Sequence[str]
    A list of strings associated with the consumer for grouping and filtering.
    clientId String
    Unique oauth2 client id. If not set, the oauth2 plugin will generate one
    clientSecret String
    Unique oauth2 client secret. If not set, the oauth2 plugin will generate one
    consumerId String
    The id of the consumer to be configured with oauth2.
    hashSecret Boolean
    A boolean flag that indicates whether the client_secret field will be stored in hashed form. If enabled on existing plugin instances, client secrets are hashed on the fly upon first usage. Default: false.
    name String
    The name associated with the credential.
    redirectUris List<String>
    An array with one or more URLs in your app where users will be sent after authorization (RFC 6742 Section 3.1.2).
    tags List<String>
    A list of strings associated with the consumer for grouping and filtering.

    Package Details

    Repository
    Kong pulumi/pulumi-kong
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the kong Terraform Provider.
    kong logo
    Kong v4.5.6 published on Wednesday, Oct 16, 2024 by Pulumi