record user.login event by kratos hooks (#111)

* record user.login event by kratos hooks

Signed-off-by: mabhi <abhijit.mukherjee@infracloud.io>

* added test case for create login auditlog

Signed-off-by: mabhi <abhijit.mukherjee@infracloud.io>

* updated change log

Signed-off-by: mabhi <abhijit.mukherjee@infracloud.io>
This commit is contained in:
Abhijit Mukherjee
2022-12-26 11:55:19 +05:30
committed by GitHub
parent f5cbe6ca1e
commit cd55d2d1da
11 changed files with 934 additions and 369 deletions

View File

@@ -57,6 +57,49 @@
]
}
},
"/auth/v3/user/auditlog": {
"post": {
"operationId": "UserService_AuditLogWebhook",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/v3UserLoginAuditResponse"
}
},
"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/v3UserLoginAuditRequest"
}
}
],
"tags": [
"UserService"
]
}
},
"/auth/v3/user/{metadata.name}": {
"get": {
"operationId": "UserService_GetUser",
@@ -95,51 +138,51 @@
},
{
"name": "apiVersion",
"description": "API Version. API Version of the user resource",
"description": "API Version\n\nAPI Version of the user resource",
"in": "query",
"required": false,
"required": true,
"type": "string",
"default": "system.k8smgmt.io/v3"
},
{
"name": "kind",
"description": "Kind. Kind of the user resource",
"description": "Kind\n\nKind of the user resource",
"in": "query",
"required": false,
"required": true,
"type": "string",
"default": "User"
},
{
"name": "metadata.displayName",
"description": "Display Name. display name of the resource",
"description": "Display Name\n\ndisplay name of the resource",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "metadata.description",
"description": "Description. description of the resource",
"description": "Description\n\ndescription of the resource",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "metadata.project",
"description": "Project. Project of the resource",
"description": "Project\n\nProject of the resource",
"in": "query",
"required": false,
"required": true,
"type": "string"
},
{
"name": "metadata.organization",
"description": "Organization. Organization to which the resource belongs",
"description": "Organization\n\nOrganization to which the resource belongs",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "metadata.partner",
"description": "Partner. Partner to which the resource belongs",
"description": "Partner\n\nPartner to which the resource belongs",
"in": "query",
"required": false,
"type": "string"
@@ -172,92 +215,94 @@
},
{
"name": "spec.firstName",
"description": "FirstName. First name of the user",
"description": "FirstName\n\nFirst name of the user",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.lastName",
"description": "LastName. Last name of the user",
"description": "LastName\n\nLast name of the user",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.phone",
"description": "Phone. Phone number of the user",
"description": "Phone\n\nPhone number of the user",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.password",
"description": "Password. Password of the user",
"description": "Password\n\nPassword of the user",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.groups",
"description": "Group. Groups the user belongs to",
"description": "Group\n\nGroups the user belongs to",
"in": "query",
"required": false,
"type": "array",
"items": {
"type": "string"
"type": "string",
"readOnly": true
},
"collectionFormat": "multi"
},
{
"name": "spec.idpGroups",
"description": "Idp Group. Idp Groups the user belongs to",
"description": "Idp Group\n\nIdp Groups the user belongs to",
"in": "query",
"required": false,
"type": "array",
"items": {
"type": "string"
"type": "string",
"readOnly": true
},
"collectionFormat": "multi"
},
{
"name": "spec.emailVerified",
"description": "EmailVerified. Flag to show if the email of the user was verified",
"description": "EmailVerified\n\nFlag to show if the email of the user was verified",
"in": "query",
"required": false,
"type": "boolean"
},
{
"name": "spec.phoneVerified",
"description": "PhoneVerified. Flag to show if phone number of the user was verified",
"description": "PhoneVerified\n\nFlag to show if phone number of the user was verified",
"in": "query",
"required": false,
"type": "boolean"
},
{
"name": "spec.recoveryUrl",
"description": "Recovery Url. Initial signup URL returned after user creation",
"description": "Recovery Url\n\nInitial signup URL returned after user creation",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.lastLogin",
"description": "LastLogin. Last access date time in RFC3339 format.",
"description": "LastLogin\n\nLast access date time in RFC3339 format.",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "status.conditionType",
"description": "Condition Type. type of the status condition",
"description": "Condition Type\n\ntype of the status condition",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "status.conditionStatus",
"description": "Condition Status. status of the condition",
"description": "Condition Status\n\nstatus of the condition",
"in": "query",
"required": false,
"type": "string",
@@ -271,7 +316,7 @@
},
{
"name": "status.lastUpdated",
"description": "Last Updated. when the condition status is last updated",
"description": "Last Updated\n\nwhen the condition status is last updated",
"in": "query",
"required": false,
"type": "string",
@@ -279,7 +324,7 @@
},
{
"name": "status.reason",
"description": "Reason. reason of the last condition status",
"description": "Reason\n\nreason of the last condition status",
"in": "query",
"required": false,
"type": "string"
@@ -330,51 +375,51 @@
},
{
"name": "apiVersion",
"description": "API Version. API Version of the user resource",
"description": "API Version\n\nAPI Version of the user resource",
"in": "query",
"required": false,
"required": true,
"type": "string",
"default": "system.k8smgmt.io/v3"
},
{
"name": "kind",
"description": "Kind. Kind of the user resource",
"description": "Kind\n\nKind of the user resource",
"in": "query",
"required": false,
"required": true,
"type": "string",
"default": "User"
},
{
"name": "metadata.displayName",
"description": "Display Name. display name of the resource",
"description": "Display Name\n\ndisplay name of the resource",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "metadata.description",
"description": "Description. description of the resource",
"description": "Description\n\ndescription of the resource",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "metadata.project",
"description": "Project. Project of the resource",
"description": "Project\n\nProject of the resource",
"in": "query",
"required": false,
"required": true,
"type": "string"
},
{
"name": "metadata.organization",
"description": "Organization. Organization to which the resource belongs",
"description": "Organization\n\nOrganization to which the resource belongs",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "metadata.partner",
"description": "Partner. Partner to which the resource belongs",
"description": "Partner\n\nPartner to which the resource belongs",
"in": "query",
"required": false,
"type": "string"
@@ -407,92 +452,94 @@
},
{
"name": "spec.firstName",
"description": "FirstName. First name of the user",
"description": "FirstName\n\nFirst name of the user",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.lastName",
"description": "LastName. Last name of the user",
"description": "LastName\n\nLast name of the user",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.phone",
"description": "Phone. Phone number of the user",
"description": "Phone\n\nPhone number of the user",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.password",
"description": "Password. Password of the user",
"description": "Password\n\nPassword of the user",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.groups",
"description": "Group. Groups the user belongs to",
"description": "Group\n\nGroups the user belongs to",
"in": "query",
"required": false,
"type": "array",
"items": {
"type": "string"
"type": "string",
"readOnly": true
},
"collectionFormat": "multi"
},
{
"name": "spec.idpGroups",
"description": "Idp Group. Idp Groups the user belongs to",
"description": "Idp Group\n\nIdp Groups the user belongs to",
"in": "query",
"required": false,
"type": "array",
"items": {
"type": "string"
"type": "string",
"readOnly": true
},
"collectionFormat": "multi"
},
{
"name": "spec.emailVerified",
"description": "EmailVerified. Flag to show if the email of the user was verified",
"description": "EmailVerified\n\nFlag to show if the email of the user was verified",
"in": "query",
"required": false,
"type": "boolean"
},
{
"name": "spec.phoneVerified",
"description": "PhoneVerified. Flag to show if phone number of the user was verified",
"description": "PhoneVerified\n\nFlag to show if phone number of the user was verified",
"in": "query",
"required": false,
"type": "boolean"
},
{
"name": "spec.recoveryUrl",
"description": "Recovery Url. Initial signup URL returned after user creation",
"description": "Recovery Url\n\nInitial signup URL returned after user creation",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.lastLogin",
"description": "LastLogin. Last access date time in RFC3339 format.",
"description": "LastLogin\n\nLast access date time in RFC3339 format.",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "status.conditionType",
"description": "Condition Type. type of the status condition",
"description": "Condition Type\n\ntype of the status condition",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "status.conditionStatus",
"description": "Condition Status. status of the condition",
"description": "Condition Status\n\nstatus of the condition",
"in": "query",
"required": false,
"type": "string",
@@ -506,7 +553,7 @@
},
{
"name": "status.lastUpdated",
"description": "Last Updated. when the condition status is last updated",
"description": "Last Updated\n\nwhen the condition status is last updated",
"in": "query",
"required": false,
"type": "string",
@@ -514,7 +561,7 @@
},
{
"name": "status.reason",
"description": "Reason. reason of the last condition status",
"description": "Reason\n\nreason of the last condition status",
"in": "query",
"required": false,
"type": "string"
@@ -564,7 +611,111 @@
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/v3User"
"type": "object",
"properties": {
"apiVersion": {
"type": "string",
"default": "system.k8smgmt.io/v3",
"description": "API Version of the user resource",
"title": "API Version"
},
"kind": {
"type": "string",
"default": "User",
"description": "Kind of the user resource",
"title": "Kind"
},
"metadata": {
"type": "object",
"example": {
"name": "some-name",
"project": "defaultproject"
},
"properties": {
"displayName": {
"type": "string",
"description": "display name of the resource",
"title": "Display Name"
},
"description": {
"type": "string",
"description": "description of the resource",
"title": "Description"
},
"labels": {
"type": "object",
"additionalProperties": {
"type": "string"
},
"description": "labels of the resource",
"title": "Labels"
},
"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
},
"urlScope": {
"type": "string",
"readOnly": true
},
"createdAt": {
"type": "string",
"format": "date-time",
"readOnly": true
},
"modifiedAt": {
"type": "string",
"format": "date-time",
"readOnly": true
}
},
"description": "metadata of the resource",
"title": "Metadata"
},
"spec": {
"$ref": "#/definitions/v3UserSpec",
"description": "Spec of the user resource",
"title": "Spec"
},
"status": {
"$ref": "#/definitions/commonv3Status",
"description": "Status of the resource",
"title": "Status",
"readOnly": true
}
},
"description": "User",
"title": "User",
"required": [
"apiVersion",
"kind",
"metadata",
"spec",
"project"
]
}
}
],
@@ -739,58 +890,58 @@
"parameters": [
{
"name": "apiVersion",
"description": "API Version. API Version of the user resource",
"description": "API Version\n\nAPI Version of the user resource",
"in": "query",
"required": false,
"required": true,
"type": "string",
"default": "system.k8smgmt.io/v3"
},
{
"name": "kind",
"description": "Kind. Kind of the user resource",
"description": "Kind\n\nKind of the user resource",
"in": "query",
"required": false,
"required": true,
"type": "string",
"default": "User"
},
{
"name": "metadata.name",
"description": "Name. name of the resource",
"description": "Name\n\nname of the resource",
"in": "query",
"required": false,
"required": true,
"type": "string"
},
{
"name": "metadata.displayName",
"description": "Display Name. display name of the resource",
"description": "Display Name\n\ndisplay name of the resource",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "metadata.description",
"description": "Description. description of the resource",
"description": "Description\n\ndescription of the resource",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "metadata.project",
"description": "Project. Project of the resource",
"description": "Project\n\nProject of the resource",
"in": "query",
"required": false,
"required": true,
"type": "string"
},
{
"name": "metadata.organization",
"description": "Organization. Organization to which the resource belongs",
"description": "Organization\n\nOrganization to which the resource belongs",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "metadata.partner",
"description": "Partner. Partner to which the resource belongs",
"description": "Partner\n\nPartner to which the resource belongs",
"in": "query",
"required": false,
"type": "string"
@@ -823,92 +974,94 @@
},
{
"name": "spec.firstName",
"description": "FirstName. First name of the user",
"description": "FirstName\n\nFirst name of the user",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.lastName",
"description": "LastName. Last name of the user",
"description": "LastName\n\nLast name of the user",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.phone",
"description": "Phone. Phone number of the user",
"description": "Phone\n\nPhone number of the user",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.password",
"description": "Password. Password of the user",
"description": "Password\n\nPassword of the user",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.groups",
"description": "Group. Groups the user belongs to",
"description": "Group\n\nGroups the user belongs to",
"in": "query",
"required": false,
"type": "array",
"items": {
"type": "string"
"type": "string",
"readOnly": true
},
"collectionFormat": "multi"
},
{
"name": "spec.idpGroups",
"description": "Idp Group. Idp Groups the user belongs to",
"description": "Idp Group\n\nIdp Groups the user belongs to",
"in": "query",
"required": false,
"type": "array",
"items": {
"type": "string"
"type": "string",
"readOnly": true
},
"collectionFormat": "multi"
},
{
"name": "spec.emailVerified",
"description": "EmailVerified. Flag to show if the email of the user was verified",
"description": "EmailVerified\n\nFlag to show if the email of the user was verified",
"in": "query",
"required": false,
"type": "boolean"
},
{
"name": "spec.phoneVerified",
"description": "PhoneVerified. Flag to show if phone number of the user was verified",
"description": "PhoneVerified\n\nFlag to show if phone number of the user was verified",
"in": "query",
"required": false,
"type": "boolean"
},
{
"name": "spec.recoveryUrl",
"description": "Recovery Url. Initial signup URL returned after user creation",
"description": "Recovery Url\n\nInitial signup URL returned after user creation",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "spec.lastLogin",
"description": "LastLogin. Last access date time in RFC3339 format.",
"description": "LastLogin\n\nLast access date time in RFC3339 format.",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "status.conditionType",
"description": "Condition Type. type of the status condition",
"description": "Condition Type\n\ntype of the status condition",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "status.conditionStatus",
"description": "Condition Status. status of the condition",
"description": "Condition Status\n\nstatus of the condition",
"in": "query",
"required": false,
"type": "string",
@@ -922,7 +1075,7 @@
},
{
"name": "status.lastUpdated",
"description": "Last Updated. when the condition status is last updated",
"description": "Last Updated\n\nwhen the condition status is last updated",
"in": "query",
"required": false,
"type": "string",
@@ -930,7 +1083,7 @@
},
{
"name": "status.reason",
"description": "Reason. reason of the last condition status",
"description": "Reason\n\nreason of the last condition status",
"in": "query",
"required": false,
"type": "string"
@@ -972,21 +1125,21 @@
"parameters": [
{
"name": "q",
"description": "query for filtering.",
"description": "query for filtering",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "name",
"description": "name is unique ID of a resource along with (partnerID, organizationID,\nprojectID).",
"description": "name is unique ID of a resource along with (partnerID, organizationID,\nprojectID)",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "selector",
"description": "selector is used to filter the labels of a resource.",
"description": "selector is used to filter the labels of a resource",
"in": "query",
"required": false,
"type": "string"
@@ -1023,7 +1176,7 @@
},
{
"name": "displayName",
"description": "displayName only used for update queries to set displayName (READONLY).",
"description": "displayName only used for update queries to set displayName (READONLY)",
"in": "query",
"required": false,
"type": "string"
@@ -1051,14 +1204,14 @@
},
{
"name": "ignoreScopeDefault",
"description": "ignoreScopeDefault ignores default values for partnerID, organizationID and\nprojectID.",
"description": "ignoreScopeDefault ignores default values for partnerID, organizationID and\nprojectID",
"in": "query",
"required": false,
"type": "boolean"
},
{
"name": "globalScope",
"description": "globalScope sets partnerID,organizationID,projectID = 0.",
"description": "globalScope sets partnerID,organizationID,projectID = 0",
"in": "query",
"required": false,
"type": "boolean"
@@ -1089,7 +1242,7 @@
},
{
"name": "urlScope",
"description": "urlScope is supposed to be passed in the URL as kind/HashID(value).",
"description": "urlScope is supposed to be passed in the URL as kind/HashID(value)",
"in": "query",
"required": false,
"type": "string"
@@ -1148,7 +1301,7 @@
},
{
"name": "type",
"description": "generic way to specify a type of resource, mainly for use in users endpoint.",
"description": "generic way to specify a type of resource, mainly for use in users endpoint",
"in": "query",
"required": false,
"type": "string"
@@ -1192,6 +1345,7 @@
"parameters": [
{
"name": "body",
"description": "User",
"in": "body",
"required": true,
"schema": {
@@ -1442,6 +1596,11 @@
},
"description": "Permissions provided by role",
"title": "Permissions"
},
"scope": {
"type": "string",
"description": "Scope holds information about org wide, project or namespace access",
"title": "Scope"
}
},
"description": "Permissions",
@@ -1588,20 +1747,20 @@
"groups": {
"type": "array",
"items": {
"type": "string"
"type": "string",
"readOnly": true
},
"description": "Groups the user belongs to",
"title": "Group",
"readOnly": true
"title": "Group"
},
"idpGroups": {
"type": "array",
"items": {
"type": "string"
"type": "string",
"readOnly": true
},
"description": "Idp Groups the user belongs to",
"title": "Idp Group",
"readOnly": true
"title": "Idp Group"
},
"permissions": {
"type": "array",
@@ -1653,11 +1812,11 @@
"items": {
"type": "array",
"items": {
"$ref": "#/definitions/v3User"
"$ref": "#/definitions/v3User",
"readOnly": true
},
"description": "List of the user resources",
"title": "Items",
"readOnly": true
"title": "Items"
}
},
"description": "User list",
@@ -1675,6 +1834,17 @@
}
}
},
"v3UserLoginAuditRequest": {
"type": "object",
"properties": {
"userId": {
"type": "string"
}
}
},
"v3UserLoginAuditResponse": {
"type": "object"
},
"v3UserSpec": {
"type": "object",
"properties": {
@@ -1701,20 +1871,20 @@
"groups": {
"type": "array",
"items": {
"type": "string"
"type": "string",
"readOnly": true
},
"description": "Groups the user belongs to",
"title": "Group",
"readOnly": true
"title": "Group"
},
"idpGroups": {
"type": "array",
"items": {
"type": "string"
"type": "string",
"readOnly": true
},
"description": "Idp Groups the user belongs to",
"title": "Idp Group",
"readOnly": true
"title": "Idp Group"
},
"projectNamespaceRoles": {
"type": "array",