认证服务器参考

自托管认证

Supabase 认证服务器 (GoTrue) 是一个基于 JSON Web Token (JWT) 的 API,用于管理用户和颁发访问令牌。

GoTrue 是用 Golang 编写的一个开源 API,作为处理 JAM 项目用户注册和身份验证的独立 API 服务。它基于 OAuth2 和 JWT,处理用户注册、身份验证和自定义用户数据。



获取一个用户。

get/admin/user/{user_id}

路径参数

  • user_id
    必需

    用户的 ID

响应代码

  • 200
  • 401

响应 (200)

1
{
2
"app_metadata": {
3
"property1": null,
4
"property2": null
5
},
6
"aud": "lorem",
7
"banned_until": "2021-12-31T23:34:00Z",
8
"confirmation_sent_at": "2021-12-31T23:34:00Z",
9
"confirmed_at": "2021-12-31T23:34:00Z",
10
"created_at": "2021-12-31T23:34:00Z",
11
"email": "lorem",
12
"email_change_sent_at": "2021-12-31T23:34:00Z",
13
"email_confirmed_at": "2021-12-31T23:34:00Z",
14
"id": "fbdf5a53-161e-4460-98ad-0e39408d8689",
15
"identities": [
16
{
17
"created_at": "2021-12-31T23:34:00Z",
18
"id": "lorem",
19
"identity_data": {
20
"property1": null,
21
"property2": null
22
},
23
"last_sign_in_at": "2021-12-31T23:34:00Z",
24
"provider": "lorem",
25
"updated_at": "2021-12-31T23:34:00Z",
26
"user_id": "fbdf5a53-161e-4460-98ad-0e39408d8689"
27
}
28
],
29
"invited_at": "2021-12-31T23:34:00Z",
30
"last_sign_in_at": "2021-12-31T23:34:00Z",
31
"new_email": "lorem",
32
"new_phone": "lorem",
33
"phone": "lorem",
34
"phone_change_sent_at": "2021-12-31T23:34:00Z",
35
"phone_confirmed_at": "2021-12-31T23:34:00Z",
36
"reauthentication_sent_at": "2021-12-31T23:34:00Z",
37
"recovery_sent_at": "2021-12-31T23:34:00Z",
38
"role": "lorem",
39
"updated_at": "2021-12-31T23:34:00Z",
40
"user_metadata": {
41
"property1": null,
42
"property2": null
43
}
44
}

更新一个用户。

put/admin/user/{user_id}

路径参数

  • user_id
    必需

    用户的 ID

响应代码

  • 200
  • 401

响应 (200)

1
{
2
"app_metadata": {
3
"property1": null,
4
"property2": null
5
},
6
"aud": "lorem",
7
"banned_until": "2021-12-31T23:34:00Z",
8
"confirmation_sent_at": "2021-12-31T23:34:00Z",
9
"confirmed_at": "2021-12-31T23:34:00Z",
10
"created_at": "2021-12-31T23:34:00Z",
11
"email": "lorem",
12
"email_change_sent_at": "2021-12-31T23:34:00Z",
13
"email_confirmed_at": "2021-12-31T23:34:00Z",
14
"id": "fbdf5a53-161e-4460-98ad-0e39408d8689",
15
"identities": [
16
{
17
"created_at": "2021-12-31T23:34:00Z",
18
"id": "lorem",
19
"identity_data": {
20
"property1": null,
21
"property2": null
22
},
23
"last_sign_in_at": "2021-12-31T23:34:00Z",
24
"provider": "lorem",
25
"updated_at": "2021-12-31T23:34:00Z",
26
"user_id": "fbdf5a53-161e-4460-98ad-0e39408d8689"
27
}
28
],
29
"invited_at": "2021-12-31T23:34:00Z",
30
"last_sign_in_at": "2021-12-31T23:34:00Z",
31
"new_email": "lorem",
32
"new_phone": "lorem",
33
"phone": "lorem",
34
"phone_change_sent_at": "2021-12-31T23:34:00Z",
35
"phone_confirmed_at": "2021-12-31T23:34:00Z",
36
"reauthentication_sent_at": "2021-12-31T23:34:00Z",
37
"recovery_sent_at": "2021-12-31T23:34:00Z",
38
"role": "lorem",
39
"updated_at": "2021-12-31T23:34:00Z",
40
"user_metadata": {
41
"property1": null,
42
"property2": null
43
}
44
}

删除一个用户。

delete/admin/user/{user_id}

路径参数

  • user_id
    必需

    用户的 ID

响应代码

  • 200
  • 401

响应 (200)

1
{}

列出所有用户。

get/admin/users

响应代码

  • 200
  • 401

响应 (200)

1
{
2
"aud": "lorem",
3
"users": [
4
{
5
"app_metadata": {
6
"property1": null,
7
"property2": null
8
},
9
"aud": "lorem",
10
"banned_until": "2021-12-31T23:34:00Z",
11
"confirmation_sent_at": "2021-12-31T23:34:00Z",
12
"confirmed_at": "2021-12-31T23:34:00Z",
13
"created_at": "2021-12-31T23:34:00Z",
14
"email": "lorem",
15
"email_change_sent_at": "2021-12-31T23:34:00Z",
16
"email_confirmed_at": "2021-12-31T23:34:00Z",
17
"id": "fbdf5a53-161e-4460-98ad-0e39408d8689",
18
"identities": [
19
{
20
"created_at": "2021-12-31T23:34:00Z",
21
"id": "lorem",
22
"identity_data": {
23
"property1": null,
24
"property2": null
25
},
26
"last_sign_in_at": "2021-12-31T23:34:00Z",
27
"provider": "lorem",
28
"updated_at": "2021-12-31T23:34:00Z",
29
"user_id": "fbdf5a53-161e-4460-98ad-0e39408d8689"
30
}
31
],
32
"invited_at": "2021-12-31T23:34:00Z",
33
"last_sign_in_at": "2021-12-31T23:34:00Z",
34
"new_email": "lorem",
35
"new_phone": "lorem",
36
"phone": "lorem",
37
"phone_change_sent_at": "2021-12-31T23:34:00Z",
38
"phone_confirmed_at": "2021-12-31T23:34:00Z",
39
"reauthentication_sent_at": "2021-12-31T23:34:00Z",
40
"recovery_sent_at": "2021-12-31T23:34:00Z",
41
"role": "lorem",
42
"updated_at": "2021-12-31T23:34:00Z",
43
"user_metadata": {
44
"property1": null,
45
"property2": null
46
}
47
}
48
]
49
}

返回创建的用户。

post/admin/users

正文

  • app_metadata
    可选
    object
  • aud
    可选
    字符串
  • ban_duration
    可选
    字符串
  • email
    可选
    字符串
  • email_confirm
    可选
    boolean
  • password
    可选
    字符串
  • phone
    可选
    字符串
  • phone_confirm
    可选
    boolean
  • role
    可选
    字符串
  • user_metadata
    可选
    object

响应代码

  • 200
  • 401

响应 (200)

1
{
2
"app_metadata": {
3
"property1": null,
4
"property2": null
5
},
6
"aud": "lorem",
7
"banned_until": "2021-12-31T23:34:00Z",
8
"confirmation_sent_at": "2021-12-31T23:34:00Z",
9
"confirmed_at": "2021-12-31T23:34:00Z",
10
"created_at": "2021-12-31T23:34:00Z",
11
"email": "lorem",
12
"email_change_sent_at": "2021-12-31T23:34:00Z",
13
"email_confirmed_at": "2021-12-31T23:34:00Z",
14
"id": "fbdf5a53-161e-4460-98ad-0e39408d8689",
15
"identities": [
16
{
17
"created_at": "2021-12-31T23:34:00Z",
18
"id": "lorem",
19
"identity_data": {
20
"property1": null,
21
"property2": null
22
},
23
"last_sign_in_at": "2021-12-31T23:34:00Z",
24
"provider": "lorem",
25
"updated_at": "2021-12-31T23:34:00Z",
26
"user_id": "fbdf5a53-161e-4460-98ad-0e39408d8689"
27
}
28
],
29
"invited_at": "2021-12-31T23:34:00Z",
30
"last_sign_in_at": "2021-12-31T23:34:00Z",
31
"new_email": "lorem",
32
"new_phone": "lorem",
33
"phone": "lorem",
34
"phone_change_sent_at": "2021-12-31T23:34:00Z",
35
"phone_confirmed_at": "2021-12-31T23:34:00Z",
36
"reauthentication_sent_at": "2021-12-31T23:34:00Z",
37
"recovery_sent_at": "2021-12-31T23:34:00Z",
38
"role": "lorem",
39
"updated_at": "2021-12-31T23:34:00Z",
40
"user_metadata": {
41
"property1": null,
42
"property2": null
43
}
44
}

接收来自外部提供商的重定向,在 OAuth 身份验证过程开始时启动创建访问令牌和刷新令牌的过程。

get/callback

响应代码

  • 302

gotrue 的 healthcheck 端点。返回当前 gotrue 版本。

get/health

响应代码

  • 200

响应 (200)

1
{
2
"description": "lorem",
3
"name": "lorem",
4
"version": "lorem"
5
}


注销用户。

post/logout

响应代码

  • 204

响应 (204)

1
{}

电子邮件或电话的无密码登录方法。

post/otp

正文

  • create_user
    可选
    boolean
  • data
    可选
    object
  • email
    可选
    字符串
  • phone
    可选
    字符串

响应代码

  • 200

响应 (200)

1
{}


返回 gotrue 服务器的配置设置。

get/settings

响应代码

  • 200

响应 (200)

1
{
2
"disable_signup": true,
3
"external": {
4
"apple": true,
5
"azure": true,
6
"bitbucket": true,
7
"discord": true,
8
"email": true,
9
"facebook": true,
10
"github": true,
11
"gitlab": true,
12
"google": true,
13
"keycloak": true,
14
"linkedin": true,
15
"notion": true,
16
"phone": true,
17
"saml": true,
18
"slack": true,
19
"spotify": true,
20
"twitch": true,
21
"twitter": true,
22
"workos": true,
23
"zoom": true
24
},
25
"mailer_autoconfirm": true,
26
"phone_autoconfirm": true,
27
"sms_provider": "lorem"
28
}

使用电子邮件或电话的基于密码的注册。

post/signup

正文

  • data
    可选
    object
  • email
    可选
    字符串
  • password
    可选
    字符串
  • phone
    可选
    字符串

响应代码

  • 200

响应 (200)

1
{
2
"app_metadata": {
3
"property1": null,
4
"property2": null
5
},
6
"aud": "lorem",
7
"banned_until": "2021-12-31T23:34:00Z",
8
"confirmation_sent_at": "2021-12-31T23:34:00Z",
9
"confirmed_at": "2021-12-31T23:34:00Z",
10
"created_at": "2021-12-31T23:34:00Z",
11
"email": "lorem",
12
"email_change_sent_at": "2021-12-31T23:34:00Z",
13
"email_confirmed_at": "2021-12-31T23:34:00Z",
14
"id": "fbdf5a53-161e-4460-98ad-0e39408d8689",
15
"identities": [
16
{
17
"created_at": "2021-12-31T23:34:00Z",
18
"id": "lorem",
19
"identity_data": {
20
"property1": null,
21
"property2": null
22
},
23
"last_sign_in_at": "2021-12-31T23:34:00Z",
24
"provider": "lorem",
25
"updated_at": "2021-12-31T23:34:00Z",
26
"user_id": "fbdf5a53-161e-4460-98ad-0e39408d8689"
27
}
28
],
29
"invited_at": "2021-12-31T23:34:00Z",
30
"last_sign_in_at": "2021-12-31T23:34:00Z",
31
"new_email": "lorem",
32
"new_phone": "lorem",
33
"phone": "lorem",
34
"phone_change_sent_at": "2021-12-31T23:34:00Z",
35
"phone_confirmed_at": "2021-12-31T23:34:00Z",
36
"reauthentication_sent_at": "2021-12-31T23:34:00Z",
37
"recovery_sent_at": "2021-12-31T23:34:00Z",
38
"role": "lorem",
39
"updated_at": "2021-12-31T23:34:00Z",
40
"user_metadata": {
41
"property1": null,
42
"property2": null
43
}
44
}

使用密码登录用户。

post/token?grant_type=password

正文

  • email
    可选
    字符串
  • password
    可选
    字符串
  • phone
    可选
    字符串

响应代码

  • 200

响应 (200)

1
{
2
"access_token": "lorem",
3
"expires_in": 42,
4
"refresh_token": "lorem",
5
"token_type": "lorem",
6
"user": {
7
"app_metadata": {
8
"property1": null,
9
"property2": null
10
},
11
"aud": "lorem",
12
"banned_until": "2021-12-31T23:34:00Z",
13
"confirmation_sent_at": "2021-12-31T23:34:00Z",
14
"confirmed_at": "2021-12-31T23:34:00Z",
15
"created_at": "2021-12-31T23:34:00Z",
16
"email": "lorem",
17
"email_change_sent_at": "2021-12-31T23:34:00Z",
18
"email_confirmed_at": "2021-12-31T23:34:00Z",
19
"id": "fbdf5a53-161e-4460-98ad-0e39408d8689",
20
"identities": [
21
{
22
"created_at": "2021-12-31T23:34:00Z",
23
"id": "lorem",
24
"identity_data": {
25
"property1": null,
26
"property2": null
27
},
28
"last_sign_in_at": "2021-12-31T23:34:00Z",
29
"provider": "lorem",
30
"updated_at": "2021-12-31T23:34:00Z",
31
"user_id": "fbdf5a53-161e-4460-98ad-0e39408d8689"
32
}
33
],
34
"invited_at": "2021-12-31T23:34:00Z",
35
"last_sign_in_at": "2021-12-31T23:34:00Z",
36
"new_email": "lorem",
37
"new_phone": "lorem",
38
"phone": "lorem",
39
"phone_change_sent_at": "2021-12-31T23:34:00Z",
40
"phone_confirmed_at": "2021-12-31T23:34:00Z",
41
"reauthentication_sent_at": "2021-12-31T23:34:00Z",
42
"recovery_sent_at": "2021-12-31T23:34:00Z",
43
"role": "lorem",
44
"updated_at": "2021-12-31T23:34:00Z",
45
"user_metadata": {
46
"property1": null,
47
"property2": null
48
}
49
}
50
}

刷新用户的刷新令牌。

post/token?grant_type=refresh_token

正文

  • refresh_token
    可选
    字符串

响应代码

  • 200

响应 (200)

1
{
2
"access_token": "lorem",
3
"expires_in": 42,
4
"refresh_token": "lorem",
5
"token_type": "lorem",
6
"user": {
7
"app_metadata": {
8
"property1": null,
9
"property2": null
10
},
11
"aud": "lorem",
12
"banned_until": "2021-12-31T23:34:00Z",
13
"confirmation_sent_at": "2021-12-31T23:34:00Z",
14
"confirmed_at": "2021-12-31T23:34:00Z",
15
"created_at": "2021-12-31T23:34:00Z",
16
"email": "lorem",
17
"email_change_sent_at": "2021-12-31T23:34:00Z",
18
"email_confirmed_at": "2021-12-31T23:34:00Z",
19
"id": "fbdf5a53-161e-4460-98ad-0e39408d8689",
20
"identities": [
21
{
22
"created_at": "2021-12-31T23:34:00Z",
23
"id": "lorem",
24
"identity_data": {
25
"property1": null,
26
"property2": null
27
},
28
"last_sign_in_at": "2021-12-31T23:34:00Z",
29
"provider": "lorem",
30
"updated_at": "2021-12-31T23:34:00Z",
31
"user_id": "fbdf5a53-161e-4460-98ad-0e39408d8689"
32
}
33
],
34
"invited_at": "2021-12-31T23:34:00Z",
35
"last_sign_in_at": "2021-12-31T23:34:00Z",
36
"new_email": "lorem",
37
"new_phone": "lorem",
38
"phone": "lorem",
39
"phone_change_sent_at": "2021-12-31T23:34:00Z",
40
"phone_confirmed_at": "2021-12-31T23:34:00Z",
41
"reauthentication_sent_at": "2021-12-31T23:34:00Z",
42
"recovery_sent_at": "2021-12-31T23:34:00Z",
43
"role": "lorem",
44
"updated_at": "2021-12-31T23:34:00Z",
45
"user_metadata": {
46
"property1": null,
47
"property2": null
48
}
49
}
50
}

获取已登录用户的信息。

get/user

响应代码

  • 200
  • 401

响应 (200)

1
{
2
"app_metadata": {
3
"property1": null,
4
"property2": null
5
},
6
"aud": "lorem",
7
"banned_until": "2021-12-31T23:34:00Z",
8
"confirmation_sent_at": "2021-12-31T23:34:00Z",
9
"confirmed_at": "2021-12-31T23:34:00Z",
10
"created_at": "2021-12-31T23:34:00Z",
11
"email": "lorem",
12
"email_change_sent_at": "2021-12-31T23:34:00Z",
13
"email_confirmed_at": "2021-12-31T23:34:00Z",
14
"id": "fbdf5a53-161e-4460-98ad-0e39408d8689",
15
"identities": [
16
{
17
"created_at": "2021-12-31T23:34:00Z",
18
"id": "lorem",
19
"identity_data": {
20
"property1": null,
21
"property2": null
22
},
23
"last_sign_in_at": "2021-12-31T23:34:00Z",
24
"provider": "lorem",
25
"updated_at": "2021-12-31T23:34:00Z",
26
"user_id": "fbdf5a53-161e-4460-98ad-0e39408d8689"
27
}
28
],
29
"invited_at": "2021-12-31T23:34:00Z",
30
"last_sign_in_at": "2021-12-31T23:34:00Z",
31
"new_email": "lorem",
32
"new_phone": "lorem",
33
"phone": "lorem",
34
"phone_change_sent_at": "2021-12-31T23:34:00Z",
35
"phone_confirmed_at": "2021-12-31T23:34:00Z",
36
"reauthentication_sent_at": "2021-12-31T23:34:00Z",
37
"recovery_sent_at": "2021-12-31T23:34:00Z",
38
"role": "lorem",
39
"updated_at": "2021-12-31T23:34:00Z",
40
"user_metadata": {
41
"property1": null,
42
"property2": null
43
}
44
}

返回更新后的用户。

put/user

正文

  • app_metadata
    可选
    object
  • data
    可选
    object
  • email
    可选
    字符串
  • nonce
    可选
    字符串
  • password
    可选
    字符串
  • phone
    可选
    字符串

响应代码

  • 200
  • 401

响应 (200)

1
{
2
"app_metadata": {
3
"property1": null,
4
"property2": null
5
},
6
"aud": "lorem",
7
"banned_until": "2021-12-31T23:34:00Z",
8
"confirmation_sent_at": "2021-12-31T23:34:00Z",
9
"confirmed_at": "2021-12-31T23:34:00Z",
10
"created_at": "2021-12-31T23:34:00Z",
11
"email": "lorem",
12
"email_change_sent_at": "2021-12-31T23:34:00Z",
13
"email_confirmed_at": "2021-12-31T23:34:00Z",
14
"id": "fbdf5a53-161e-4460-98ad-0e39408d8689",
15
"identities": [
16
{
17
"created_at": "2021-12-31T23:34:00Z",
18
"id": "lorem",
19
"identity_data": {
20
"property1": null,
21
"property2": null
22
},
23
"last_sign_in_at": "2021-12-31T23:34:00Z",
24
"provider": "lorem",
25
"updated_at": "2021-12-31T23:34:00Z",
26
"user_id": "fbdf5a53-161e-4460-98ad-0e39408d8689"
27
}
28
],
29
"invited_at": "2021-12-31T23:34:00Z",
30
"last_sign_in_at": "2021-12-31T23:34:00Z",
31
"new_email": "lorem",
32
"new_phone": "lorem",
33
"phone": "lorem",
34
"phone_change_sent_at": "2021-12-31T23:34:00Z",
35
"phone_confirmed_at": "2021-12-31T23:34:00Z",
36
"reauthentication_sent_at": "2021-12-31T23:34:00Z",
37
"recovery_sent_at": "2021-12-31T23:34:00Z",
38
"role": "lorem",
39
"updated_at": "2021-12-31T23:34:00Z",
40
"user_metadata": {
41
"property1": null,
42
"property2": null
43
}
44
}

验证注册。

post/verify

正文

  • email
    可选
    字符串
  • phone
    可选
    字符串
  • redirect_to
    可选
    字符串
  • token
    可选
    字符串
  • type
    可选
    字符串