feat: idp and login policy configurations (#619)

* feat: oidc config

* fix: oidc configurations

* feat: oidc idp config

* feat: add oidc config test

* fix: tests

* fix: tests

* feat: translate new events

* feat: idp eventstore

* feat: idp eventstore

* fix: tests

* feat: command side idp

* feat: query side idp

* feat: idp config on org

* fix: tests

* feat: authz idp on org

* feat: org idps

* feat: login policy

* feat: login policy

* feat: login policy

* feat: add idp func on login policy

* feat: add validation to loginpolicy and idp provider

* feat: add default login policy

* feat: login policy on org

* feat: login policy on org

* fix: id config handlers

* fix: id config handlers

* fix: create idp on org

* fix: create idp on org

* fix: not existing idp config

* fix: default login policy

* fix: add login policy on org

* fix: idp provider search on org

* fix: test

* fix: remove idp on org

* fix: test

* fix: test

* fix: remove admin idp

* fix: logo src as byte

* fix: migration

* fix: tests

* Update internal/iam/repository/eventsourcing/iam.go

Co-authored-by: Silvan <[email protected]>

* Update internal/iam/repository/eventsourcing/iam_test.go

Co-authored-by: Silvan <[email protected]>

* Update internal/iam/repository/eventsourcing/iam_test.go

Co-authored-by: Silvan <[email protected]>

* Update internal/iam/repository/eventsourcing/model/login_policy.go

Co-authored-by: Silvan <[email protected]>

* Update internal/iam/repository/eventsourcing/model/login_policy.go

Co-authored-by: Silvan <[email protected]>

* Update internal/org/repository/eventsourcing/org_test.go

Co-authored-by: Silvan <[email protected]>

* Update internal/iam/repository/eventsourcing/model/login_policy_test.go

Co-authored-by: Silvan <[email protected]>

* Update internal/iam/repository/eventsourcing/model/login_policy_test.go

Co-authored-by: Silvan <[email protected]>

* fix: pr comments

* fix: tests

* Update types.go

* fix: merge request changes

* fix: reduce optimization

Co-authored-by: Silvan <[email protected]>
Co-authored-by: Livio Amstutz <[email protected]>
This commit is contained in:
Fabi
2020-08-26 09:56:23 +02:00
committed by GitHub
co-authored by Silvan Livio Amstutz
parent f05c5bae24
commit db1d8f4efe
157 changed files with 37510 additions and 15698 deletions
+774 -1
View File
@@ -89,6 +89,230 @@
]
}
},
"/idps/_search": {
"post": {
"operationId": "SearchIdps",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/v1IdpSearchResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/v1IdpSearchRequest"
}
}
],
"tags": [
"AdminService"
]
}
},
"/idps/oidc": {
"post": {
"operationId": "CreateOidcIdp",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/v1Idp"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/v1OidcIdpConfigCreate"
}
}
],
"tags": [
"AdminService"
]
}
},
"/idps/{idp_id}/oidcconfig": {
"put": {
"operationId": "UpdateOidcIdpConfig",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/v1OidcIdpConfig"
}
}
},
"parameters": [
{
"name": "idp_id",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/v1OidcIdpConfigUpdate"
}
}
],
"tags": [
"AdminService"
]
}
},
"/idps/{id}": {
"get": {
"operationId": "IdpByID",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/v1IdpView"
}
}
},
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"type": "string"
}
],
"tags": [
"AdminService"
]
},
"delete": {
"operationId": "RemoveIdpConfig",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"properties": {}
}
}
},
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"type": "string"
}
],
"tags": [
"AdminService"
]
},
"put": {
"operationId": "UpdateIdpConfig",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/v1Idp"
}
}
},
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/v1IdpUpdate"
}
}
],
"tags": [
"AdminService"
]
}
},
"/idps/{id}/_deactivate": {
"put": {
"operationId": "DeactivateIdpConfig",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/v1Idp"
}
}
},
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/v1IdpID"
}
}
],
"tags": [
"AdminService"
]
}
},
"/idps/{id}/_reactivate": {
"put": {
"operationId": "ReactivateIdpConfig",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/v1Idp"
}
}
},
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/v1IdpID"
}
}
],
"tags": [
"AdminService"
]
}
},
"/members": {
"post": {
"operationId": "AddIamMember",
@@ -425,6 +649,130 @@
]
}
},
"/policies/login": {
"get": {
"operationId": "GetDefaultLoginPolicy",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/v1DefaultLoginPolicyView"
}
}
},
"tags": [
"AdminService"
]
},
"put": {
"operationId": "UpdateDefaultLoginPolicy",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/v1DefaultLoginPolicy"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/v1DefaultLoginPolicy"
}
}
],
"tags": [
"AdminService"
]
}
},
"/policies/login/idpproviders": {
"post": {
"operationId": "AddIdpProviderToDefaultLoginPolicy",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/v1IdpProviderID"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/v1IdpProviderID"
}
}
],
"tags": [
"AdminService"
]
}
},
"/policies/login/idpproviders/_search": {
"post": {
"operationId": "GetDefaultLoginPolicyIdpProviders",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/v1IdpProviderSearchResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/v1IdpProviderSearchRequest"
}
}
],
"tags": [
"AdminService"
]
}
},
"/policies/login/idpproviders/{idp_config_id}": {
"post": {
"operationId": "RemoveIdpProviderFromDefaultLoginPolicy",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"properties": {}
}
}
},
"parameters": [
{
"name": "idp_config_id",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/v1IdpProviderID"
}
}
],
"tags": [
"AdminService"
]
}
},
"/ready": {
"get": {
"summary": "Ready returns status OK as soon as all dependent services are available",
@@ -449,7 +797,7 @@
"200": {
"description": "A successful response.",
"schema": {
"type": "object"
"$ref": "#/definitions/protobufStruct"
}
}
},
@@ -506,6 +854,19 @@
}
},
"definitions": {
"protobufListValue": {
"type": "object",
"properties": {
"values": {
"type": "array",
"items": {
"$ref": "#/definitions/protobufValue"
},
"description": "Repeated field of dynamically typed values."
}
},
"description": "`ListValue` is a wrapper around a repeated field of values.\n\nThe JSON representation for `ListValue` is JSON array."
},
"protobufNullValue": {
"type": "string",
"enum": [
@@ -514,6 +875,51 @@
"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."
},
"protobufStruct": {
"type": "object",
"properties": {
"fields": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/protobufValue"
},
"description": "Unordered map of dynamically typed values."
}
},
"description": "`Struct` represents a structured data value, consisting of fields\nwhich map to dynamically typed values. In some languages, `Struct`\nmight be supported by a native representation. For example, in\nscripting languages like JS a struct is represented as an\nobject. The details of that representation are described together\nwith the proto support for the language.\n\nThe JSON representation for `Struct` is JSON object."
},
"protobufValue": {
"type": "object",
"properties": {
"null_value": {
"$ref": "#/definitions/protobufNullValue",
"description": "Represents a null value."
},
"number_value": {
"type": "number",
"format": "double",
"description": "Represents a double value."
},
"string_value": {
"type": "string",
"description": "Represents a string value."
},
"bool_value": {
"type": "boolean",
"format": "boolean",
"description": "Represents a boolean value."
},
"struct_value": {
"$ref": "#/definitions/protobufStruct",
"description": "Represents a structured value."
},
"list_value": {
"$ref": "#/definitions/protobufListValue",
"description": "Represents a repeated `Value`."
}
},
"description": "`Value` represents a dynamically typed value which can be either\nnull, a number, a string, a boolean, a recursive struct value, or a\nlist of values. A producer of value is expected to set one of that\nvariants, absence of any variant indicates an error.\n\nThe JSON representation for `Value` is JSON value."
},
"v1AddIamMemberRequest": {
"type": "object",
"properties": {
@@ -608,6 +1014,40 @@
}
}
},
"v1DefaultLoginPolicy": {
"type": "object",
"properties": {
"allow_username_password": {
"type": "boolean",
"format": "boolean"
},
"allow_register": {
"type": "boolean",
"format": "boolean"
},
"allow_external_idp": {
"type": "boolean",
"format": "boolean"
}
}
},
"v1DefaultLoginPolicyView": {
"type": "object",
"properties": {
"allow_username_password": {
"type": "boolean",
"format": "boolean"
},
"allow_register": {
"type": "boolean",
"format": "boolean"
},
"allow_external_idp": {
"type": "boolean",
"format": "boolean"
}
}
},
"v1FailedEvent": {
"type": "object",
"properties": {
@@ -804,6 +1244,339 @@
}
}
},
"v1Idp": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"state": {
"$ref": "#/definitions/v1IdpState"
},
"creation_date": {
"type": "string",
"format": "date-time"
},
"change_date": {
"type": "string",
"format": "date-time"
},
"name": {
"type": "string"
},
"logo_src": {
"type": "string",
"format": "byte"
},
"oidc_config": {
"$ref": "#/definitions/v1OidcIdpConfig"
},
"sequence": {
"type": "string",
"format": "uint64"
}
}
},
"v1IdpID": {
"type": "object",
"properties": {
"id": {
"type": "string"
}
}
},
"v1IdpProviderID": {
"type": "object",
"properties": {
"idp_config_id": {
"type": "string"
}
}
},
"v1IdpProviderSearchRequest": {
"type": "object",
"properties": {
"offset": {
"type": "string",
"format": "uint64"
},
"limit": {
"type": "string",
"format": "uint64"
}
}
},
"v1IdpProviderSearchResponse": {
"type": "object",
"properties": {
"offset": {
"type": "string",
"format": "uint64"
},
"limit": {
"type": "string",
"format": "uint64"
},
"total_result": {
"type": "string",
"format": "uint64"
},
"result": {
"type": "array",
"items": {
"$ref": "#/definitions/v1IdpProviderView"
}
},
"processed_sequence": {
"type": "string",
"format": "uint64"
},
"view_timestamp": {
"type": "string",
"format": "date-time"
}
}
},
"v1IdpProviderView": {
"type": "object",
"properties": {
"idp_config_id": {
"type": "string"
},
"name": {
"type": "string"
},
"type": {
"$ref": "#/definitions/v1IdpType"
}
}
},
"v1IdpSearchKey": {
"type": "string",
"enum": [
"IDPSEARCHKEY_UNSPECIFIED",
"IDPSEARCHKEY_IDP_CONFIG_ID",
"IDPSEARCHKEY_NAME"
],
"default": "IDPSEARCHKEY_UNSPECIFIED"
},
"v1IdpSearchQuery": {
"type": "object",
"properties": {
"key": {
"$ref": "#/definitions/v1IdpSearchKey"
},
"method": {
"$ref": "#/definitions/v1SearchMethod"
},
"value": {
"type": "string"
}
}
},
"v1IdpSearchRequest": {
"type": "object",
"properties": {
"offset": {
"type": "string",
"format": "uint64"
},
"limit": {
"type": "string",
"format": "uint64"
},
"queries": {
"type": "array",
"items": {
"$ref": "#/definitions/v1IdpSearchQuery"
}
}
}
},
"v1IdpSearchResponse": {
"type": "object",
"properties": {
"offset": {
"type": "string",
"format": "uint64"
},
"limit": {
"type": "string",
"format": "uint64"
},
"total_result": {
"type": "string",
"format": "uint64"
},
"result": {
"type": "array",
"items": {
"$ref": "#/definitions/v1IdpView"
}
},
"processed_sequence": {
"type": "string",
"format": "uint64"
},
"view_timestamp": {
"type": "string",
"format": "date-time"
}
}
},
"v1IdpState": {
"type": "string",
"enum": [
"IDPCONFIGSTATE_UNSPECIFIED",
"IDPCONFIGSTATE_ACTIVE",
"IDPCONFIGSTATE_INACTIVE"
],
"default": "IDPCONFIGSTATE_UNSPECIFIED"
},
"v1IdpType": {
"type": "string",
"enum": [
"IDPTYPE_UNSPECIFIED",
"IDPTYPE_OIDC",
"IDPTYPE_SAML"
],
"default": "IDPTYPE_UNSPECIFIED"
},
"v1IdpUpdate": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"logo_src": {
"type": "string",
"format": "byte"
}
}
},
"v1IdpView": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"state": {
"$ref": "#/definitions/v1IdpState"
},
"creation_date": {
"type": "string",
"format": "date-time"
},
"change_date": {
"type": "string",
"format": "date-time"
},
"name": {
"type": "string"
},
"logo_src": {
"type": "string",
"format": "byte"
},
"oidc_config": {
"$ref": "#/definitions/v1OidcIdpConfigView"
},
"sequence": {
"type": "string",
"format": "uint64"
}
}
},
"v1OidcIdpConfig": {
"type": "object",
"properties": {
"client_id": {
"type": "string"
},
"client_secret": {
"type": "string"
},
"issuer": {
"type": "string"
},
"scopes": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"v1OidcIdpConfigCreate": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"logo_src": {
"type": "string",
"format": "byte"
},
"client_id": {
"type": "string"
},
"client_secret": {
"type": "string"
},
"issuer": {
"type": "string"
},
"scopes": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"v1OidcIdpConfigUpdate": {
"type": "object",
"properties": {
"idp_id": {
"type": "string"
},
"client_id": {
"type": "string"
},
"client_secret": {
"type": "string"
},
"issuer": {
"type": "string"
},
"scopes": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"v1OidcIdpConfigView": {
"type": "object",
"properties": {
"client_id": {
"type": "string"
},
"issuer": {
"type": "string"
},
"scopes": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"v1Org": {
"type": "object",
"properties": {