Add OIdC provider service API specs

This commit is contained in:
Akshay Gaikwad
2022-01-20 11:18:58 +05:30
parent 6aeb92b0f5
commit de7e491802
4 changed files with 1125 additions and 0 deletions

View File

@@ -0,0 +1,875 @@
{
"swagger": "2.0",
"info": {
"title": "OIdC Provider Service",
"version": "2.0",
"contact": {
"name": "Rafay Dev"
}
},
"tags": [
{
"name": "OIDCProvider"
}
],
"schemes": [
"https"
],
"consumes": [
"application/json",
"application/yaml"
],
"produces": [
"application/json",
"application/yaml"
],
"paths": {
"/auth/v3/sso/oidc/provider": {
"get": {
"operationId": "OIDCProvider_ListOIDCProvider",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/v3OIDCProviderList"
}
},
"403": {
"description": "Returned when the user does not have permission to access the resource.",
"schema": {}
},
"404": {
"description": "Returned when the resource does not exist.",
"schema": {
"type": "string",
"format": "string"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/googlerpcStatus"
}
}
},
"tags": [
"OIDCProvider"
]
},
"post": {
"operationId": "OIDCProvider_CreateOIDCProvider",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/v3OIDCProvider"
}
},
"201": {
"description": "Returned when oidc provider is created successfully.",
"schema": {}
},
"403": {
"description": "Returned when the user does not have permission to access the resource.",
"schema": {}
},
"404": {
"description": "Returned when the resource does not exist.",
"schema": {
"type": "string",
"format": "string"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/googlerpcStatus"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/v3OIDCProvider"
}
}
],
"tags": [
"OIDCProvider"
]
}
},
"/auth/v3/sso/oidc/provider/{metadata.id}": {
"get": {
"operationId": "OIDCProvider_GetOIDCProvider",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/v3OIDCProvider"
}
},
"403": {
"description": "Returned when the user does not have permission to access the resource.",
"schema": {}
},
"404": {
"description": "Returned when the resource does not exist.",
"schema": {
"type": "string",
"format": "string"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/googlerpcStatus"
}
}
},
"parameters": [
{
"name": "metadata.id",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "apiVersion",
"description": "API Version. API Version of the OIDCProvider resource",
"in": "query",
"required": false,
"type": "string",
"default": "usermgmt.k8smgmt.io/v3"
},
{
"name": "kind",
"description": "Kind. Kind of the OIDCProvider resource",
"in": "query",
"required": false,
"type": "string",
"default": "OIDCProvider"
},
{
"name": "metadata.name",
"description": "Name. name of the resource",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "metadata.description",
"description": "Description. description of the resource",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "metadata.project",
"description": "Project. Project of the resource",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "metadata.organization",
"description": "Organization. Organization to which the resource belongs",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "metadata.partner",
"description": "Partner. Partner to which the resource belongs",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "metadata.modifiedAt",
"in": "query",
"required": false,
"type": "string",
"format": "date-time"
},
{
"name": "spec.providerName",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.mapperUrl",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.mapperFilename",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.clientId",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.clientSecret",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.scopes",
"in": "query",
"required": false,
"type": "array",
"items": {
"type": "string"
},
"collectionFormat": "multi"
},
{
"name": "spec.issuerUrl",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.authUrl",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.tokenUrl",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.predefined",
"in": "query",
"required": false,
"type": "boolean"
},
{
"name": "spec.callbackUrl",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "status.conditionType",
"description": "Condition Type. type of the status condition",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "status.conditionStatus",
"description": "Condition Status. status of the condition",
"in": "query",
"required": false,
"type": "string",
"enum": [
"StatusNotSet",
"StatusSubmitted",
"StatusOK",
"StatusFailed"
],
"default": "StatusNotSet"
},
{
"name": "status.lastUpdated",
"description": "Last Updated. when the condition status is last updated",
"in": "query",
"required": false,
"type": "string",
"format": "date-time"
},
{
"name": "status.reason",
"description": "Reason. reason of the last condition status",
"in": "query",
"required": false,
"type": "string"
}
],
"tags": [
"OIDCProvider"
]
},
"delete": {
"operationId": "OIDCProvider_DeleteOIDCProvider",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"properties": {}
}
},
"204": {
"description": "Returned when oidc provider is deleted successfully.",
"schema": {}
},
"403": {
"description": "Returned when the user does not have permission to access the resource.",
"schema": {}
},
"404": {
"description": "Returned when the resource does not exist.",
"schema": {
"type": "string",
"format": "string"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/googlerpcStatus"
}
}
},
"parameters": [
{
"name": "metadata.id",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "apiVersion",
"description": "API Version. API Version of the OIDCProvider resource",
"in": "query",
"required": false,
"type": "string",
"default": "usermgmt.k8smgmt.io/v3"
},
{
"name": "kind",
"description": "Kind. Kind of the OIDCProvider resource",
"in": "query",
"required": false,
"type": "string",
"default": "OIDCProvider"
},
{
"name": "metadata.name",
"description": "Name. name of the resource",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "metadata.description",
"description": "Description. description of the resource",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "metadata.project",
"description": "Project. Project of the resource",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "metadata.organization",
"description": "Organization. Organization to which the resource belongs",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "metadata.partner",
"description": "Partner. Partner to which the resource belongs",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "metadata.modifiedAt",
"in": "query",
"required": false,
"type": "string",
"format": "date-time"
},
{
"name": "spec.providerName",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.mapperUrl",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.mapperFilename",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.clientId",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.clientSecret",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.scopes",
"in": "query",
"required": false,
"type": "array",
"items": {
"type": "string"
},
"collectionFormat": "multi"
},
{
"name": "spec.issuerUrl",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.authUrl",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.tokenUrl",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.predefined",
"in": "query",
"required": false,
"type": "boolean"
},
{
"name": "spec.callbackUrl",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "status.conditionType",
"description": "Condition Type. type of the status condition",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "status.conditionStatus",
"description": "Condition Status. status of the condition",
"in": "query",
"required": false,
"type": "string",
"enum": [
"StatusNotSet",
"StatusSubmitted",
"StatusOK",
"StatusFailed"
],
"default": "StatusNotSet"
},
{
"name": "status.lastUpdated",
"description": "Last Updated. when the condition status is last updated",
"in": "query",
"required": false,
"type": "string",
"format": "date-time"
},
{
"name": "status.reason",
"description": "Reason. reason of the last condition status",
"in": "query",
"required": false,
"type": "string"
}
],
"tags": [
"OIDCProvider"
]
},
"put": {
"operationId": "OIDCProvider_UpdateOIDCProvider",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/v3OIDCProvider"
}
},
"403": {
"description": "Returned when the user does not have permission to access the resource.",
"schema": {}
},
"404": {
"description": "Returned when the resource does not exist.",
"schema": {
"type": "string",
"format": "string"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/googlerpcStatus"
}
}
},
"parameters": [
{
"name": "metadata.id",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/v3OIDCProvider"
}
}
],
"tags": [
"OIDCProvider"
]
}
}
},
"definitions": {
"commonv3Status": {
"type": "object",
"properties": {
"conditionType": {
"type": "string",
"description": "type of the status condition",
"title": "Condition Type",
"readOnly": true
},
"conditionStatus": {
"$ref": "#/definitions/v3ConditionStatus",
"enum": [
"StatusNotSet",
"StatusSubmitted",
"StatusOK",
"StatusFailed"
],
"description": "status of the condition",
"title": "Condition Status",
"readOnly": true
},
"lastUpdated": {
"type": "string",
"format": "date-time",
"description": "when the condition status is last updated",
"title": "Last Updated",
"readOnly": true
},
"reason": {
"type": "string",
"description": "reason of the last condition status",
"title": "Reason",
"readOnly": true
}
},
"description": "status of a resource",
"title": "Status",
"readOnly": true
},
"googlerpcStatus": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
},
"details": {
"type": "array",
"items": {
"$ref": "#/definitions/protobufAny"
}
}
}
},
"protobufAny": {
"type": "object",
"properties": {
"@type": {
"type": "string"
}
},
"additionalProperties": {}
},
"protobufNullValue": {
"type": "string",
"enum": [
"NULL_VALUE"
],
"default": "NULL_VALUE",
"description": "`NullValue` is a singleton enumeration to represent the null value for the\n`Value` type union.\n\n The JSON representation for `NullValue` is JSON `null`.\n\n - NULL_VALUE: Null value."
},
"v3ConditionStatus": {
"type": "string",
"enum": [
"StatusNotSet",
"StatusSubmitted",
"StatusOK",
"StatusFailed"
],
"default": "StatusNotSet",
"title": "$title: ConditionStatus\n$description: status of a condition for a resource"
},
"v3ListMetadata": {
"type": "object",
"properties": {
"count": {
"type": "string",
"format": "int64"
},
"offset": {
"type": "string",
"format": "int64"
},
"limt": {
"type": "string",
"format": "int64"
}
},
"title": "$title: ListMetadata\n$description: metadata for a list of resources\n$required: enabled"
},
"v3Metadata": {
"type": "object",
"example": {
"name": "some-name",
"project": "defaultproject"
},
"properties": {
"name": {
"type": "string",
"description": "name of the resource",
"title": "Name"
},
"description": {
"type": "string",
"description": "description of the resource",
"title": "Description"
},
"labels": {
"type": "object",
"additionalProperties": {
"type": "string"
},
"description": "labels of the resource",
"title": "Lables"
},
"annotations": {
"type": "object",
"additionalProperties": {
"type": "string"
},
"description": "annotations of the resource",
"title": "Annotations"
},
"project": {
"type": "string",
"description": "Project of the resource",
"title": "Project"
},
"organization": {
"type": "string",
"description": "Organization to which the resource belongs",
"title": "Organization"
},
"partner": {
"type": "string",
"description": "Partner to which the resource belongs",
"title": "Partner"
},
"id": {
"type": "string",
"readOnly": true
},
"modifiedAt": {
"type": "string",
"format": "date-time",
"readOnly": true
}
},
"description": "metadata of the resource",
"title": "Metadata",
"required": [
"name",
"project"
]
},
"v3OIDCProvider": {
"type": "object",
"properties": {
"apiVersion": {
"type": "string",
"default": "usermgmt.k8smgmt.io/v3",
"description": "API Version of the OIDCProvider resource",
"title": "API Version"
},
"kind": {
"type": "string",
"default": "OIDCProvider",
"description": "Kind of the OIDCProvider resource",
"title": "Kind"
},
"metadata": {
"$ref": "#/definitions/v3Metadata",
"description": "Metadata of the OIDCProvider resource",
"title": "Metadata"
},
"spec": {
"$ref": "#/definitions/v3OIDCProviderSpec",
"description": "Spec of the OIDCProvider resource",
"title": "Spec"
},
"status": {
"$ref": "#/definitions/commonv3Status",
"description": "Status of the resource",
"title": "Status",
"readOnly": true
}
},
"description": "Open Id Connect Provider",
"title": "OIDCProvider",
"required": [
"apiVersion",
"kind",
"metadata",
"spec"
]
},
"v3OIDCProviderList": {
"type": "object",
"properties": {
"apiVersion": {
"type": "string",
"default": "usermgmt.k8smgmt.io/v3",
"description": "API Version of the OIDCProvider list resource",
"title": "API Version",
"readOnly": true
},
"kind": {
"type": "string",
"default": "OIDCProviderList",
"description": "Kind of the OIDCProvider list resource",
"title": "Kind",
"readOnly": true
},
"metadata": {
"$ref": "#/definitions/v3ListMetadata",
"description": "Metadata of the OIDCProvider list resource",
"title": "Metadata",
"readOnly": true
},
"items": {
"type": "array",
"items": {
"$ref": "#/definitions/v3OIDCProvider"
},
"description": "List of the OIDCProvider resources",
"title": "Items",
"readOnly": true
}
},
"description": "OIDC providers list",
"title": "OIDCProviderList",
"readOnly": true
},
"v3OIDCProviderSpec": {
"type": "object",
"properties": {
"providerName": {
"type": "string"
},
"mapperUrl": {
"type": "string"
},
"mapperFilename": {
"type": "string"
},
"clientId": {
"type": "string"
},
"clientSecret": {
"type": "string"
},
"scopes": {
"type": "array",
"items": {
"type": "string"
}
},
"issuerUrl": {
"type": "string"
},
"authUrl": {
"type": "string"
},
"tokenUrl": {
"type": "string"
},
"requestedClaims": {
"type": "object"
},
"predefined": {
"type": "boolean"
},
"callbackUrl": {
"type": "string"
}
},
"description": "OIDCProvider specification",
"title": "OIDCProvider Specification"
}
},
"securityDefinitions": {
"ApiKeyAuth": {
"type": "apiKey",
"name": "X-RAFAY-API-KEYID",
"in": "header"
},
"BasicAuth": {
"type": "basic"
}
},
"security": [
{
"ApiKeyAuth": [],
"BasicAuth": []
}
]
}

View File

@@ -0,0 +1,43 @@
{
"swagger": "2.0",
"info": {
"title": "proto/types/userpb/v3/oidc_provider.proto",
"version": "version not set"
},
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {},
"definitions": {
"googlerpcStatus": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
},
"details": {
"type": "array",
"items": {
"$ref": "#/definitions/protobufAny"
}
}
}
},
"protobufAny": {
"type": "object",
"properties": {
"@type": {
"type": "string"
}
},
"additionalProperties": {}
}
}
}

View File

@@ -0,0 +1,104 @@
syntax = "proto3";
package rafay.dev.rpc.v3;
import "google/api/annotations.proto";
import "google/protobuf/empty.proto";
import "protoc-gen-openapiv2/options/annotations.proto";
import "proto/types/userpb/v3/oidc_provider.proto";
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
info : {
title : "OIdC Provider Service"
version : "2.0"
contact : {name : "Rafay Dev"}
}
schemes : HTTPS
consumes : "application/json"
consumes : "application/yaml"
produces : "application/json"
produces : "application/yaml"
security_definitions : {
security : {
key : "BasicAuth"
value : {type : TYPE_BASIC}
}
security : {
key : "ApiKeyAuth"
value : {type : TYPE_API_KEY in : IN_HEADER name : "X-RAFAY-API-KEYID"}
}
}
security : {
security_requirement : {
key : "BasicAuth"
value : {}
}
security_requirement : {
key : "ApiKeyAuth"
value : {}
}
}
responses : {
key : "403"
value : {
description : "Returned when the user does not have permission to access "
"the resource."
}
}
responses : {
key : "404"
value : {
description : "Returned when the resource does not exist."
schema : {json_schema : {type : STRING}}
}
}
};
service OIDCProvider {
rpc CreateOIDCProvider(rafay.dev.types.user.v3.OIDCProvider) returns (rafay.dev.types.user.v3.OIDCProvider) {
option (google.api.http) = {
post : "/auth/v3/sso/oidc/provider"
body : "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
responses : {
key : "201"
value : {description : "Returned when oidc provider is created successfully."}
}
};
}
rpc GetOIDCProvider(rafay.dev.types.user.v3.OIDCProvider) returns (rafay.dev.types.user.v3.OIDCProvider) {
option (google.api.http) = {
get : "/auth/v3/sso/oidc/provider/{metadata.id}"
};
};
rpc ListOIDCProvider(google.protobuf.Empty) returns (rafay.dev.types.user.v3.OIDCProviderList) {
option (google.api.http) = {
get : "/auth/v3/sso/oidc/provider"
};
};
rpc UpdateOIDCProvider(rafay.dev.types.user.v3.OIDCProvider) returns (rafay.dev.types.user.v3.OIDCProvider) {
option (google.api.http) = {
put : "/auth/v3/sso/oidc/provider/{metadata.id}"
body : "*"
};
};
rpc DeleteOIDCProvider(rafay.dev.types.user.v3.OIDCProvider) returns (google.protobuf.Empty) {
option (google.api.http) = {
delete : "/auth/v3/sso/oidc/provider/{metadata.id}"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
responses : {
key : "204"
value : {
description : "Returned when oidc provider is deleted successfully."
}
}
};
};
}

View File

@@ -0,0 +1,103 @@
syntax = "proto3";
package rafay.dev.types.user.v3;
import "proto/types/commonpb/v3/common.proto";
import "google/protobuf/struct.proto";
import "protoc-gen-openapiv2/options/annotations.proto";
message OIDCProvider {
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = {
json_schema : {
title : "OIDCProvider"
description : "Open Id Connect Provider"
required : [ "apiVersion", "kind", "metadata", "spec" ]
}
};
string apiVersion = 1
[ (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
title : "API Version",
description : "API Version of the OIDCProvider resource"
default : "usermgmt.k8smgmt.io/v3"
} ];
string kind = 2
[ (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
title : "Kind",
description : "Kind of the OIDCProvider resource"
default : "OIDCProvider"
} ];
rafay.dev.types.common.v3.Metadata metadata = 3
[ (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
title : "Metadata",
description : "Metadata of the OIDCProvider resource"
} ];
OIDCProviderSpec spec = 4
[ (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
title : "Spec",
description : "Spec of the OIDCProvider resource"
} ];
rafay.dev.types.common.v3.Status status = 5
[ (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
title : "Status",
description : "Status of the resource"
read_only : true
} ];
}
message OIDCProviderSpec {
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = {
json_schema : {
title : "OIDCProvider Specification"
description : "OIDCProvider specification"
}
};
string providerName = 1; // enumeration?
string mapperUrl = 2;
string mapperFilename = 3;
string clientId = 4;
string clientSecret = 5;
repeated string scopes = 6;
string issuerUrl = 7;
string authUrl = 8;
string tokenUrl = 9;
google.protobuf.Struct requestedClaims = 10; // JSON object
bool predefined = 11;
string callbackUrl = 12;
}
message OIDCProviderList {
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = {
json_schema : {
title : "OIDCProviderList"
description : "OIDC providers list"
read_only : true
}
};
string apiVersion = 1
[ (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
title : "API Version",
description : "API Version of the OIDCProvider list resource"
default : "usermgmt.k8smgmt.io/v3"
read_only : true
} ];
string kind = 2
[ (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
title : "Kind",
description : "Kind of the OIDCProvider list resource"
default : "OIDCProviderList"
read_only : true
} ];
rafay.dev.types.common.v3.ListMetadata metadata = 3
[ (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
title : "Metadata",
description : "Metadata of the OIDCProvider list resource"
read_only : true
} ];
repeated OIDCProvider items = 4
[ (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
title : "Items",
description : "List of the OIDCProvider resources"
read_only : true
} ];
}