Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(auth): add social login feature (#840) #854

Merged
merged 4 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 78 additions & 2 deletions conf/artalk.example.simple.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,84 @@ admin_notify:
channel_secret: ""
channel_access_token: ""
receivers:
- USER_ID_1
- GROUP_ID_1
- "USER_ID_1"
- "GROUP_ID_1"
auth:
enabled: false
anonymous: true
callback: "http://localhost:23366/api/v2/auth/{provider}/callback"
email:
enabled: true
verify_subject: "Your Code - {{code}}"
verify_tpl: default
github:
enabled: false
client_id: ""
client_secret: ""
gitlab:
enabled: false
client_id: ""
client_secret: ""
gitea:
enabled: false
client_id: ""
client_secret: ""
google:
enabled: false
client_id: ""
client_secret: ""
mastodon:
enabled: false
client_id: ""
client_secret: ""
twitter:
enabled: false
client_id: ""
client_secret: ""
facebook:
enabled: false
client_id: ""
client_secret: ""
discord:
enabled: false
client_id: ""
client_secret: ""
steam:
enabled: false
api_key: ""
apple:
enabled: false
client_id: ""
client_secret: ""
microsoft:
enabled: false
client_id: ""
client_secret: ""
wechat:
enabled: false
client_id: ""
client_secret: ""
tiktok:
enabled: false
client_id: ""
client_secret: ""
slack:
enabled: false
client_id: ""
client_secret: ""
line:
enabled: false
client_id: ""
client_secret: ""
patreon:
enabled: false
client_id: ""
client_secret: ""
auth0:
enabled: false
client_id: ""
client_secret: ""
domain: ""
frontend:
placeholder: ""
noComment: ""
Expand Down
102 changes: 102 additions & 0 deletions conf/artalk.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,108 @@ admin_notify:
- USER_ID_1
- GROUP_ID_1

# Social Login
auth:
# Enable Social Login
enabled: false
# Allow anonymous commenting (Allow skipping verification, only fill in an anonymous nickname and email)
anonymous: true
# Callback URL (https://example.com/api/v2/auth/{provider}/callback)
callback: "http://localhost:23366/api/v2/auth/{provider}/callback"
# Email
email:
# Enable email password login
enabled: true
# Verification email subject
verify_subject: "Your Code - {{code}}"
# Verification email template (set to file path to use custom template)
verify_tpl: default
# GitHub
github:
enabled: false
client_id: ""
client_secret: ""
# GitLab
gitlab:
enabled: false
client_id: ""
client_secret: ""
# Gitea
gitea:
enabled: false
client_id: ""
client_secret: ""
# Google
google:
enabled: false
client_id: ""
client_secret: ""
# Mastodon
mastodon:
enabled: false
client_id: ""
client_secret: ""
# Twitter
twitter:
enabled: false
client_id: ""
client_secret: ""
# Facebook
facebook:
enabled: false
client_id: ""
client_secret: ""
# Discord
discord:
enabled: false
client_id: ""
client_secret: ""
# Steam
steam:
enabled: false
api_key: ""
# Apple
apple:
enabled: false
client_id: ""
client_secret: ""
# Microsoft
microsoft:
enabled: false
client_id: ""
client_secret: ""
# WeChat
wechat:
enabled: false
client_id: ""
client_secret: ""
# Tiktok
tiktok:
enabled: false
client_id: ""
client_secret: ""
# Slack
slack:
enabled: false
client_id: ""
client_secret: ""
# Line
line:
enabled: false
client_id: ""
client_secret: ""
# Patreon
patreon:
enabled: false
client_id: ""
client_secret: ""
# Auth0
auth0:
enabled: false
client_id: ""
client_secret: ""
domain: ""

# UI Settings
frontend:
# Comment box placeholder
Expand Down
102 changes: 102 additions & 0 deletions conf/artalk.example.zh-CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,108 @@ admin_notify:
- USER_ID_1
- GROUP_ID_1

# 社交登录
auth:
# 启用社交登录
enabled: false
# 允许匿名评论 (允许跳过验证,仅填写匿名的昵称和邮箱)
anonymous: true
# 回调地址 (https://example.com/api/v2/auth/{provider}/callback)
callback: "http://localhost:23366/api/v2/auth/{provider}/callback"
# Email
email:
# 启用邮箱密码登录
enabled: true
# 邮箱验证邮件标题
verify_subject: "您的验证码是 - {{code}}"
# 邮箱验证邮件模板 (填入文件路径使用自定义模板)
verify_tpl: default
# GitHub
github:
enabled: false
client_id: ""
client_secret: ""
# GitLab
gitlab:
enabled: false
client_id: ""
client_secret: ""
# Gitea
gitea:
enabled: false
client_id: ""
client_secret: ""
# Google
google:
enabled: false
client_id: ""
client_secret: ""
# Mastodon
mastodon:
enabled: false
client_id: ""
client_secret: ""
# Twitter
twitter:
enabled: false
client_id: ""
client_secret: ""
# Facebook
facebook:
enabled: false
client_id: ""
client_secret: ""
# Discord
discord:
enabled: false
client_id: ""
client_secret: ""
# Steam
steam:
enabled: false
api_key: ""
# Apple
apple:
enabled: false
client_id: ""
client_secret: ""
# Microsoft
microsoft:
enabled: false
client_id: ""
client_secret: ""
# 微信
wechat:
enabled: false
client_id: ""
client_secret: ""
# Tiktok
tiktok:
enabled: false
client_id: ""
client_secret: ""
# Slack
slack:
enabled: false
client_id: ""
client_secret: ""
# Line
line:
enabled: false
client_id: ""
client_secret: ""
# Patreon
patreon:
enabled: false
client_id: ""
client_secret: ""
# Auth0
auth0:
enabled: false
client_id: ""
client_secret: ""
domain: ""

# 界面配置
frontend:
# 评论框占位文字
Expand Down
1 change: 1 addition & 0 deletions docs/docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export default defineConfig({
{ text: '侧边栏', link: '/guide/frontend/sidebar.md' },
{ text: '邮件通知', link: '/guide/backend/email.md' },
{ text: '多元推送', link: '/guide/backend/admin_notify.md' },
{ text: '社交登录', link: '/guide/frontend/auth.md' },
{ text: '评论审核', link: '/guide/backend/moderator.md' },
{ text: '验证码', link: '/guide/backend/captcha.md' },
{ text: '图片上传', link: '/guide/backend/img-upload.md' },
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/guide/backend/img-upload.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Artalk 提供图片上传功能,支持限制图片大小、上传频率等,

## 配置文件

完整的 `img-upload` 配置如下:
完整的 `img_upload` 配置如下:

```yaml
# 图片上传
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/guide/deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ docker exec -it artalk artalk admin
<!-- Artalk -->
<div id="Comments"></div>
<script>
Artalk.init({
Artalk.init({
el: '#Comments', // 绑定元素的 Selector
pageKey: '/post/1', // 固定链接 (留空自动获取)
pageTitle: '关于引入 Artalk 的这档子事', // 页面标题 (留空自动获取)
server: 'http://your_domain:8080', // 后端地址
site: 'Artalk 的博客', // 你的站点名
})
})
</script>
```
<!-- prettier-ignore-end -->
Expand Down
Loading