diff --git a/Events.php b/Events.php index fdbf4f3..5642ad3 100644 --- a/Events.php +++ b/Events.php @@ -31,6 +31,7 @@ public static function onBeforeRequest($event) // Auth ['pattern' => 'auth/login', 'route' => 'rest/auth/auth/index', 'verb' => ['POST']], + ['pattern' => 'auth/impersonate', 'route' => 'rest/auth/auth/impersonate', 'verb' => ['POST']], ['pattern' => 'auth/current', 'route' => 'rest/auth/auth/current', 'verb' => ['GET', 'HEAD']], // User: Default Controller diff --git a/components/BaseController.php b/components/BaseController.php index b5968bd..7c64741 100644 --- a/components/BaseController.php +++ b/components/BaseController.php @@ -7,6 +7,7 @@ namespace humhub\modules\rest\components; +use humhub\modules\rest\components\auth\ImpersonateAuth; use Yii; use yii\data\Pagination; use yii\db\ActiveQuery; @@ -75,6 +76,9 @@ public function behaviors() return null; }, ]] : [], + [[ + 'class' => ImpersonateAuth::class, + ]] ), ], ], parent::behaviors()); diff --git a/components/auth/ImpersonateAuth.php b/components/auth/ImpersonateAuth.php new file mode 100644 index 0000000..c996420 --- /dev/null +++ b/components/auth/ImpersonateAuth.php @@ -0,0 +1,59 @@ +getHeaders()->get($this->header); + + if ($authHeader !== null) { + if ($this->pattern !== null) { + if (preg_match($this->pattern, $authHeader, $matches)) { + $authHeader = $matches[1]; + } else { + return null; + } + + if (!StringHelper::startsWith($authHeader, 'impersonate-')) { + return null; + } + } + + $accessToken = ImpersonateAuthToken::find() + ->where(['token' => $authHeader]) + ->andWhere(['>', 'expiration', new Expression('NOW()')]) + ->one(); + + if ($accessToken && ($identity = $accessToken->user)) { + $user->login($identity); + } else { + $identity = null; + } + + if ($identity === null) { + $this->challenge($response); + $this->handleFailure($response); + } + + return $identity; + } + + return null; + } +} diff --git a/controllers/auth/AuthController.php b/controllers/auth/AuthController.php index fd7442e..99212cb 100644 --- a/controllers/auth/AuthController.php +++ b/controllers/auth/AuthController.php @@ -10,18 +10,21 @@ use Firebase\JWT\JWT; use humhub\modules\rest\components\BaseController; use humhub\modules\rest\definitions\UserDefinitions; +use humhub\modules\rest\models\ImpersonateAuthToken; use humhub\modules\rest\models\JwtAuthForm; use humhub\modules\user\models\forms\Login; use humhub\modules\user\models\User; use humhub\modules\user\services\AuthClientService; use Yii; +use yii\web\ForbiddenHttpException; use yii\web\JsonParser; +use yii\web\NotFoundHttpException; class AuthController extends BaseController { public function beforeAction($action) { - if ($action->id == 'current') { + if (in_array($action->id, ['current', 'impersonate'])) { return parent::beforeAction($action); } @@ -92,4 +95,30 @@ public function actionCurrent() return UserDefinitions::getUser($user); } + + public function actionImpersonate() + { + if (!Yii::$app->user->isAdmin()) { + throw new ForbiddenHttpException(); + } + + $user = User::findOne(['id' => Yii::$app->request->getBodyParam('userId')]); + + if ($user === null) { + throw new NotFoundHttpException(); + } + + if ($token = ImpersonateAuthToken::findOne(['user_id' => $user->id])) { + $token->delete(); + } + + $token = new ImpersonateAuthToken(); + $token->user_id = $user->id; + $token->save(); + + return [ + 'token' => $token->token, + 'expires' => $token->expiration, + ]; + } } diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 4f88f47..28a87cb 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -6,6 +6,7 @@ Changelog - Fix #110: Fix PHP Error in UserDefinition - Enh #106: Allow to set `authclient` and `authclient_id` on user creating and updating - Enh #112: Added support of HttpBearer and QueryParam auth methods +- Enh #117: Added support of user Impersonate 0.8.0 (March 10, 2023) ---------------------- diff --git a/docs/html/activity.html b/docs/html/activity.html index edd5bf8..1ac2a12 100644 --- a/docs/html/activity.html +++ b/docs/html/activity.html @@ -12,7 +12,7 @@ margin: 0; } - -

HumHub - Activity API (1.0.0)

Download OpenAPI specification:Download

E-mail: info@humhub.com License: AGPLv2

Welcome to the HumHub activity module API reference.

-

Authentication

Bearer

Security Scheme Type JWT

BasicAuth

Security Scheme Type HTTP
HTTP Authorization Scheme basic

Activity

API to access activity information.

-

Find all global activity

query Parameters
page
string >= 0

The number of page of the result set.

-
limit
string [ 1 .. 50 ]
Default: 20

The numbers of items to return per page.

-

Responses

Response samples

Content type
{
  • "total": 76,
  • "page": 1,
  • "pages": 8,
  • "links": {
    },
  • "results": [
    ]
}

Get activity by id

path Parameters
id
required
integer

The id of activity

-

Responses

Response samples

Content type
{
  • "id": 32,
  • "class": "humhub\\modules\\space\\activities\\MemberAdded",
  • "content": {
    },
  • "originator": {},
  • "source": {},
  • "createdAt": "2019-03-05 15:35:02"
}

Get all activities by container

path Parameters
containerId
required
integer

The id of container

-
query Parameters
page
string >= 0

The number of page of the result set.

-
limit
string [ 1 .. 50 ]
Default: 20

The numbers of items to return per page.

-

Responses

Response samples

Content type
{
  • "total": 76,
  • "page": 1,
  • "pages": 8,
  • "links": {
    },
  • "results": [
    ]
}
+ " fill="currentColor">

HumHub - Activity API (1.0.0)

Download OpenAPI specification:Download

E-mail: info@humhub.com License: AGPLv2

Welcome to the HumHub activity module API reference.

+

Activity

API to access activity information.

+

Find all global activity

query Parameters
page
string >= 0

The number of page of the result set.

+
limit
string [ 1 .. 50 ]
Default: 20

The numbers of items to return per page.

+

Responses

Response samples

Content type
{
  • "total": 76,
  • "page": 1,
  • "pages": 8,
  • "links": {
    },
  • "results": [
    ]
}

Get activity by id

path Parameters
id
required
integer

The id of activity

+

Responses

Response samples

Content type
{
  • "id": 32,
  • "class": "humhub\\modules\\space\\activities\\MemberAdded",
  • "content": {
    },
  • "originator": {},
  • "source": {},
  • "createdAt": "2019-03-05 15:35:02"
}

Get all activities by container

path Parameters
containerId
required
integer

The id of container

+
query Parameters
page
string >= 0

The number of page of the result set.

+
limit
string [ 1 .. 50 ]
Default: 20

The numbers of items to return per page.

+

Responses

Response samples

Content type
{
  • "total": 76,
  • "page": 1,
  • "pages": 8,
  • "links": {
    },
  • "results": [
    ]
}
-

HumHub - Auth API (1.0.0)

Download OpenAPI specification:Download

E-mail: info@humhub.com License: AGPLv2

Welcome to the HumHub auth module API reference.

-

Authentication

Login in the application

Request Body schema: application/json

Credentials for login in app

-
username
required
string

Your username or email address

-
password
required
string

Responses

Request samples

Content type
application/json
{
  • "username": "username@example.com",
  • "password": "password"
}

Response samples

Content type
{
  • "code": 200,
  • "message": "string",
  • "auth_token": "eyJ0eXAiOiJKV1QiLC .... tE_7_rLSX3vA",
  • "expired_at": "string"
}

User

Get current user

Responses

Response samples

Content type
application/json
{
  • "id": 14,
  • "guid": "cd081891-d2e2-40d5-84a4-b47309e71c80",
  • "display_name": "John Doe",
  • "account": {
    },
  • "profile": {
    }
}
+ " fill="currentColor">

HumHub - Auth API (1.0.0)

Download OpenAPI specification:Download

E-mail: info@humhub.com License: AGPLv2

Welcome to the HumHub auth module API reference.

+

Authentication

Login in the application

Request Body schema: application/json

Credentials for login in app

+
username
required
string

Your username or email address

+
password
required
string

Responses

Request samples

Content type
application/json
{
  • "username": "username@example.com",
  • "password": "password"
}

Response samples

Content type
{
  • "code": 200,
  • "message": "string",
  • "auth_token": "eyJ0eXAiOiJKV1QiLC .... tE_7_rLSX3vA",
  • "expired_at": "string"
}

User

Get current user

Responses

Response samples

Content type
application/json
{
  • "id": 14,
  • "guid": "cd081891-d2e2-40d5-84a4-b47309e71c80",
  • "display_name": "John Doe",
  • "account": {
    },
  • "profile": {
    }
}

Impersonate user

Request Body schema: application/json

id of user to Impersonate

+
userId
required
integer

id of user to Impersonate

+

Responses

Request samples

Content type
application/json
{
  • "userId": 1
}

Response samples

Content type
application/json
{
  • "token": "impersonate-YvyEVcbzCvg0wLjb9yXylj1bkbotlCwkKjNKTZD9xeMO86o1G-V9p-wklm5pUdXhdkSGj5dk-l",
  • "expires": 1681671865
}
-

HumHub - Content API (1.0.0)

Download OpenAPI specification:Download

E-mail: info@humhub.com License: AGPLv2

Welcome to the HumHub comment module API reference.

-

Authentication

Bearer

Security Scheme Type JWT

BasicAuth

Security Scheme Type HTTP
HTTP Authorization Scheme basic

Find comments by object

query Parameters
objectModel
required
string

The object model class name

-
objectId
required
integer

The primary key of the object

-

Responses

Response samples

Content type
application/json
{
  • "total": 76,
  • "page": 1,
  • "pages": 8,
  • "links": {
    },
  • "results": [
    ]
}

Find comments by content

path Parameters
id
required
integer

The primary key of the content

-

Responses

Response samples

Content type
application/json
{
  • "total": 76,
  • "page": 1,
  • "pages": 8,
  • "links": {
    },
  • "results": [
    ]
}

Create a comment

Request Body schema: application/json

The comment data

-
objectModel
required
string
objectId
required
integer <int64>
required
object (Comment)

Responses

Request samples

Content type
application/json
{
  • "objectModel": "humhub\\modules\\post\\models\\Post",
  • "objectId": 123,
  • "Comment": {
    }
}

Response samples

Content type
application/json
{
  • "id": 14,
  • "message": "Calvin Klein – Between love and madness lies obsession.",
  • "objectModel": "humhub\\modules\\post\\models\\Post",
  • "objectId": 123,
  • "createdBy": {},
  • "createdAt": "2018-08-09 14:22:03",
  • "commentsCount": 5,
  • "comments": [
    ]
}

Get comment by id

path Parameters
id
required
integer

The id of the comment

-

Responses

Response samples

Content type
application/json
{
  • "id": 14,
  • "message": "Calvin Klein – Between love and madness lies obsession.",
  • "objectModel": "humhub\\modules\\post\\models\\Post",
  • "objectId": 123,
  • "createdBy": {},
  • "createdAt": "2018-08-09 14:22:03",
  • "commentsCount": 5,
  • "comments": [
    ]
}

Update a comment by id

path Parameters
id
required
integer

Id of the updated comment

-
Request Body schema: application/json

The comment data

-
required
object (Comment)

Responses

Request samples

Content type
application/json
{
  • "Comment": {
    }
}

Response samples

Content type
application/json
{
  • "id": 14,
  • "message": "Calvin Klein – Between love and madness lies obsession.",
  • "objectModel": "humhub\\modules\\post\\models\\Post",
  • "objectId": 123,
  • "createdBy": {},
  • "createdAt": "2018-08-09 14:22:03",
  • "commentsCount": 5,
  • "comments": [
    ]
}

Deletes a comment by id

path Parameters
id
required
integer

The id of comment

-

Responses

+ " fill="currentColor">

HumHub - Content API (1.0.0)

Download OpenAPI specification:Download

E-mail: info@humhub.com License: AGPLv2

Welcome to the HumHub comment module API reference.

+

Find comments by object

query Parameters
objectModel
required
string

The object model class name

+
objectId
required
integer

The primary key of the object

+

Responses

Response samples

Content type
application/json
{
  • "total": 76,
  • "page": 1,
  • "pages": 8,
  • "links": {
    },
  • "results": [
    ]
}

Find comments by content

path Parameters
id
required
integer

The primary key of the content

+

Responses

Response samples

Content type
application/json
{
  • "total": 76,
  • "page": 1,
  • "pages": 8,
  • "links": {
    },
  • "results": [
    ]
}

Create a comment

Request Body schema: application/json

The comment data

+
objectModel
required
string
objectId
required
integer <int64>
required
object (Comment)

Responses

Request samples

Content type
application/json
{
  • "objectModel": "humhub\\modules\\post\\models\\Post",
  • "objectId": 123,
  • "Comment": {
    }
}

Response samples

Content type
application/json
{
  • "id": 14,
  • "message": "Calvin Klein – Between love and madness lies obsession.",
  • "objectModel": "humhub\\modules\\post\\models\\Post",
  • "objectId": 123,
  • "createdBy": {},
  • "createdAt": "2018-08-09 14:22:03",
  • "commentsCount": 5,
  • "comments": [
    ]
}

Get comment by id

path Parameters
id
required
integer

The id of the comment

+

Responses

Response samples

Content type
application/json
{
  • "id": 14,
  • "message": "Calvin Klein – Between love and madness lies obsession.",
  • "objectModel": "humhub\\modules\\post\\models\\Post",
  • "objectId": 123,
  • "createdBy": {},
  • "createdAt": "2018-08-09 14:22:03",
  • "commentsCount": 5,
  • "comments": [
    ]
}

Update a comment by id

path Parameters
id
required
integer

Id of the updated comment

+
Request Body schema: application/json

The comment data

+
required
object (Comment)

Responses

Request samples

Content type
application/json
{
  • "Comment": {
    }
}

Response samples

Content type
application/json
{
  • "id": 14,
  • "message": "Calvin Klein – Between love and madness lies obsession.",
  • "objectModel": "humhub\\modules\\post\\models\\Post",
  • "objectId": 123,
  • "createdBy": {},
  • "createdAt": "2018-08-09 14:22:03",
  • "commentsCount": 5,
  • "comments": [
    ]
}

Deletes a comment by id

path Parameters
id
required
integer

The id of comment

+

Responses

-

Download OpenAPI specification:Download

Authentication

Bearer

Security Scheme Type JWT

BasicAuth

Security Scheme Type HTTP
HTTP Authorization Scheme basic
+ " fill="currentColor">

Download OpenAPI specification:Download

-

HumHub - File API (1.0.0)

Download OpenAPI specification:Download

E-mail: info@humhub.com License: AGPLv2

Welcome to the HumHub file module API reference.

-

Authentication

Bearer

Security Scheme Type JWT

BasicAuth

Security Scheme Type HTTP
HTTP Authorization Scheme basic

Downloads a file by id

path Parameters
id
required
integer

The id of the file to download

-

Responses

+ " fill="currentColor">

HumHub - File API (1.0.0)

Download OpenAPI specification:Download

E-mail: info@humhub.com License: AGPLv2

Welcome to the HumHub file module API reference.

+

Downloads a file by id

path Parameters
id
required
integer

The id of the file to download

+

Responses

-

HumHub - Like API (1.0.0)

Download OpenAPI specification:Download

E-mail: info@humhub.com License: AGPLv2

Welcome to the HumHub like module API reference.

-

Authentication

Bearer

Security Scheme Type JWT

BasicAuth

Security Scheme Type HTTP
HTTP Authorization Scheme basic

Get like by id

path Parameters
id
required
integer

The id of the like

-

Responses

Response samples

Content type
application/json
{}

Deletes a like by id

path Parameters
id
required
integer

The id of the like

-

Responses

Get all likes by content id

query Parameters
model
required
string

The model record class

-
pk
required
integer

The primary key of the record

-

Responses

Response samples

Content type
application/json
{
  • "total": 76,
  • "page": 1,
  • "pages": 8,
  • "links": {
    },
  • "results": []
}
+ " fill="currentColor">

HumHub - Like API (1.0.0)

Download OpenAPI specification:Download

E-mail: info@humhub.com License: AGPLv2

Welcome to the HumHub like module API reference.

+

Get like by id

path Parameters
id
required
integer

The id of the like

+

Responses

Response samples

Content type
application/json
{}

Deletes a like by id

path Parameters
id
required
integer

The id of the like

+

Responses

Get all likes by content id

query Parameters
model
required
string

The model record class

+
pk
required
integer

The primary key of the record

+

Responses

Response samples

Content type
application/json
{
  • "total": 76,
  • "page": 1,
  • "pages": 8,
  • "links": {
    },
  • "results": []
}
-

HumHub - Notification API (1.0.0)

Download OpenAPI specification:Download

E-mail: info@humhub.com License: AGPLv2

Welcome to the HumHub notification module API reference.

-

Authentication

Bearer

Security Scheme Type JWT

BasicAuth

Security Scheme Type HTTP
HTTP Authorization Scheme basic

Notification

API to access notification information.

-

Find all user notifications

query Parameters
page
string >= 0

The number of page of the result set.

-
limit
string [ 1 .. 50 ]
Default: 20

The numbers of items to return per page.

-
excludeFilters
Array of strings
Items Enum: "admin" "calendar" "task" "task_reminder" "comments" "content_created" "like" "space_member" "followed" "mentioned"

Filters to exclude notifications from result.

-

Responses

Response samples

Content type
{
  • "total": 76,
  • "page": 1,
  • "pages": 8,
  • "links": {
    },
  • "results": [
    ]
}

Get notification by id

path Parameters
id
required
integer

The id of notification

-

Responses

Response samples

Content type
{
  • "id": 32,
  • "class": "humhub\\modules\\content\\notifications\\ContentCreated",
  • "output": "<strong>John Smith</strong> created post \"Calvin Klein – Between love and madness lies obsession.\"",
  • "originator": {},
  • "source": {},
  • "createdAt": "2019-03-05 15:35:02"
}

Find unseen user notifications

query Parameters
page
string >= 0

The number of page of the result set.

-
limit
string [ 1 .. 50 ]
Default: 20

The numbers of items to return per page.

-

Responses

Response samples

Content type
{
  • "total": 76,
  • "page": 1,
  • "pages": 8,
  • "links": {
    },
  • "results": [
    ]
}

Mark all notifications as seen

Responses

Response samples

Content type
{
  • "code": 200,
  • "message": "All notifications successfully marked as seen"
}
+ " fill="currentColor">

HumHub - Notification API (1.0.0)

Download OpenAPI specification:Download

E-mail: info@humhub.com License: AGPLv2

Welcome to the HumHub notification module API reference.

+

Notification

API to access notification information.

+

Find all user notifications

query Parameters
page
string >= 0

The number of page of the result set.

+
limit
string [ 1 .. 50 ]
Default: 20

The numbers of items to return per page.

+
excludeFilters
Array of strings
Items Enum: "admin" "calendar" "task" "task_reminder" "comments" "content_created" "like" "space_member" "followed" "mentioned"

Filters to exclude notifications from result.

+

Responses

Response samples

Content type
{
  • "total": 76,
  • "page": 1,
  • "pages": 8,
  • "links": {
    },
  • "results": [
    ]
}

Get notification by id

path Parameters
id
required
integer

The id of notification

+

Responses

Response samples

Content type
{
  • "id": 32,
  • "class": "humhub\\modules\\content\\notifications\\ContentCreated",
  • "output": "<strong>John Smith</strong> created post \"Calvin Klein – Between love and madness lies obsession.\"",
  • "originator": {},
  • "source": {
    },
  • "createdAt": "2019-03-05 15:35:02"
}

Find unseen user notifications

query Parameters
page
string >= 0

The number of page of the result set.

+
limit
string [ 1 .. 50 ]
Default: 20

The numbers of items to return per page.

+

Responses

Response samples

Content type
{
  • "total": 76,
  • "page": 1,
  • "pages": 8,
  • "links": {
    },
  • "results": [
    ]
}

Mark all notifications as seen

Responses

Response samples

Content type
{
  • "code": 200,
  • "message": "All notifications successfully marked as seen"
}
-

HumHub - Post API (1.0.0)

Download OpenAPI specification:Download

E-mail: info@humhub.com License: AGPLv2

Welcome to the HumHub post module API reference.

-

Authentication

Bearer

Security Scheme Type JWT

BasicAuth

Security Scheme Type HTTP
HTTP Authorization Scheme basic

Find all posts by container

path Parameters
id
required
integer

ID of content container

-
query Parameters
topics
string
Example: topics=Music,Dancing

Coma separated list of topics to filter

-
page
string >= 0

The number of page of the result set.

-
limit
string [ 1 .. 50 ]
Default: 20

The numbers of items to return per page.

-

Responses

Response samples

Content type
{
  • "total": 76,
  • "page": 1,
  • "pages": 8,
  • "links": {
    },
  • "results": [
    ]
}

Creates a new post

path Parameters
id
required
integer

ID of content container to post to

-
Request Body schema: application/json

The post

-
required
object (Post)

Responses

Request samples

Content type
application/json
{
  • "data": {
    }
}

Response samples

Content type
application/json
{
  • "id": 14,
  • "message": "Calvin Klein – Between love and madness lies obsession.",
  • "content": {}
}

Find all posts

query Parameters
page
string >= 0

The number of page of the result set.

-
limit
string [ 1 .. 50 ]
Default: 20

The numbers of items to return per page.

-

Responses

Response samples

Content type
{
  • "total": 76,
  • "page": 1,
  • "pages": 8,
  • "links": {
    },
  • "results": [
    ]
}

Get post by id

path Parameters
id
required
integer

The id of the post

-

Responses

Response samples

Content type
application/json
{
  • "id": 14,
  • "message": "Calvin Klein – Between love and madness lies obsession.",
  • "content": {}
}

Updates a post by id

path Parameters
id
required
integer

The id of post

-
Request Body schema: application/json

The post

-
required
object (Post)

Responses

Request samples

Content type
application/json
{
  • "data": {
    }
}

Response samples

Content type
application/json
{
  • "id": 14,
  • "message": "Calvin Klein – Between love and madness lies obsession.",
  • "content": {}
}

Deletes a post by id

path Parameters
id
required
integer

The id of post

-

Responses

Upload files to Post by id

path Parameters
id
required
integer

The id of the Post

-
Request Body schema: multipart/form-data
hiddenInStream
Array of any[ items ]

Names of the attached files which should be hidden in stream

-
files
required
Array of file[ items ]

The files to upload.

-

Responses

Response samples

Content type
application/json
{}
+ " fill="currentColor">

HumHub - Post API (1.0.0)

Download OpenAPI specification:Download

E-mail: info@humhub.com License: AGPLv2

Welcome to the HumHub post module API reference.

+

Find all posts by container

path Parameters
id
required
integer

ID of content container

+
query Parameters
topics
string
Example: topics=Music,Dancing

Coma separated list of topics to filter

+
page
string >= 0

The number of page of the result set.

+
limit
string [ 1 .. 50 ]
Default: 20

The numbers of items to return per page.

+

Responses

Response samples

Content type
{
  • "total": 76,
  • "page": 1,
  • "pages": 8,
  • "links": {
    },
  • "results": [
    ]
}

Creates a new post

path Parameters
id
required
integer

ID of content container to post to

+
Request Body schema: application/json

The post

+
required
object (Post)

Responses

Request samples

Content type
application/json
{
  • "data": {
    }
}

Response samples

Content type
application/json
{
  • "id": 14,
  • "message": "Calvin Klein – Between love and madness lies obsession.",
  • "content": {
    }
}

Find all posts

query Parameters
page
string >= 0

The number of page of the result set.

+
limit
string [ 1 .. 50 ]
Default: 20

The numbers of items to return per page.

+

Responses

Response samples

Content type
{
  • "total": 76,
  • "page": 1,
  • "pages": 8,
  • "links": {
    },
  • "results": [
    ]
}

Get post by id

path Parameters
id
required
integer

The id of the post

+

Responses

Response samples

Content type
application/json
{
  • "id": 14,
  • "message": "Calvin Klein – Between love and madness lies obsession.",
  • "content": {
    }
}

Updates a post by id

path Parameters
id
required
integer

The id of post

+
Request Body schema: application/json

The post

+
required
object (Post)

Responses

Request samples

Content type
application/json
{
  • "data": {
    }
}

Response samples

Content type
application/json
{
  • "id": 14,
  • "message": "Calvin Klein – Between love and madness lies obsession.",
  • "content": {
    }
}

Deletes a post by id

path Parameters
id
required
integer

The id of post

+

Responses

Upload files to Post by id

path Parameters
id
required
integer

The id of the Post

+
Request Body schema: multipart/form-data
hiddenInStream
Array of any

Names of the attached files which should be hidden in stream

+
files
required
Array of file

The files to upload.

+

Responses

Response samples

Content type
application/json
{}
-

HumHub - Topic API (1.0.0)

Download OpenAPI specification:Download

E-mail: info@humhub.com License: AGPLv2

Welcome to the HumHub topic module API reference.

-

Authentication

Bearer

Security Scheme Type JWT

BasicAuth

Security Scheme Type HTTP
HTTP Authorization Scheme basic

Topic

API to access and manage topic information.

-

Find all topics

query Parameters
page
string >= 0

The number of page of the result set.

-
limit
string [ 1 .. 50 ]
Default: 20

The numbers of items to return per page.

-

Responses

Response samples

Content type
{
  • "total": 76,
  • "page": 1,
  • "results": [
    ]
}

Get topic by id

path Parameters
id
required
integer

The id of topic

-

Responses

Response samples

Content type
{
  • "id": 1,
  • "name": "Api topic"
}

Update existing topic

path Parameters
id
required
integer

The id of topic

-
Request Body schema: application/json

Topic name

-
name
string

Responses

Request samples

Content type
application/json
{
  • "name": "Api topic"
}

Response samples

Content type
{
  • "id": 1,
  • "name": "Api topic"
}

Delete topic by id

path Parameters
id
required
integer

The id of topic

-

Responses

Response samples

Content type
{
  • "code": 200,
  • "message": "Topic successfully deleted!"
}

Get all topics by container

path Parameters
containerId
required
integer

The id of container

-
query Parameters
page
string >= 0

The number of page of the result set.

-
limit
string [ 1 .. 50 ]
Default: 20

The numbers of items to return per page.

-

Responses

Response samples

Content type
{
  • "total": 76,
  • "page": 1,
  • "results": [
    ]
}

Create new topic

path Parameters
containerId
required
integer

The id of container

-
Request Body schema: application/json

Topic info

-
name
required
string

Responses

Request samples

Content type
application/json
{
  • "name": "Api topic"
}

Response samples

Content type
{
  • "id": 1,
  • "name": "Api topic"
}
+ " fill="currentColor">

HumHub - Topic API (1.0.0)

Download OpenAPI specification:Download

E-mail: info@humhub.com License: AGPLv2

Welcome to the HumHub topic module API reference.

+

Topic

API to access and manage topic information.

+

Find all topics

query Parameters
page
string >= 0

The number of page of the result set.

+
limit
string [ 1 .. 50 ]
Default: 20

The numbers of items to return per page.

+

Responses

Response samples

Content type
{
  • "total": 76,
  • "page": 1,
  • "results": [
    ]
}

Get topic by id

path Parameters
id
required
integer

The id of topic

+

Responses

Response samples

Content type
{
  • "id": 1,
  • "name": "Api topic"
}

Update existing topic

path Parameters
id
required
integer

The id of topic

+
Request Body schema: application/json

Topic name

+
name
string

Responses

Request samples

Content type
application/json
{
  • "name": "Api topic"
}

Response samples

Content type
{
  • "id": 1,
  • "name": "Api topic"
}

Delete topic by id

path Parameters
id
required
integer

The id of topic

+

Responses

Response samples

Content type
{
  • "code": 200,
  • "message": "Topic successfully deleted!"
}

Get all topics by container

path Parameters
containerId
required
integer

The id of container

+
query Parameters
page
string >= 0

The number of page of the result set.

+
limit
string [ 1 .. 50 ]
Default: 20

The numbers of items to return per page.

+

Responses

Response samples

Content type
{
  • "total": 76,
  • "page": 1,
  • "results": [
    ]
}

Create new topic

path Parameters
containerId
required
integer

The id of container

+
Request Body schema: application/json

Topic info

+
name
required
string

Responses

Request samples

Content type
application/json
{
  • "name": "Api topic"
}

Response samples

Content type
{
  • "id": 1,
  • "name": "Api topic"
}