NFR: Misc updates to imap authentication
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 45/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- php
- Lĩnh vực
- authentication
Hướng nghiên cứu
Start in lib/IMAP.php and review the constructor and authentication flow against the proposed addEmail and authSeparator settings. Verify the username, Nextcloud user ID, email, and domain-group behavior for each objective; completion requires addressing the three listed objectives, though no test file or IMAP test server is provided.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Objectives:
- avoid creation of accounts without the domain [Bug 128] (https://github.com/nextcloud/user_external/issues/128)
- add an email address to created users automatically
- allow a separator other than '@' during the actual IMAP authentication [Bug 150] (https://github.com/nextcloud/user_external/issues/150)
Summary:
Add two new config variables
- $addEmail (arg6) true: create email address matching login if login contains '@'
- $authSeparator (arg7) replace '@' with '$authSeparator' when authenticating to the IMAP server
(Note: I don't have any server to test this against...)
update lib/IMAP.php
Collect the new variables
diff -u IMAP.php apps/user_external/lib/IMAP.php
--- IMAP.php 2022-04-29 09:29:43.573148672 -0400
+++ apps/user_external/lib/IMAP.php 2022-04-29 09:41:59.878674898 -0400
@@ -25,6 +25,8 @@
private $domain;
private $stripeDomain;
private $groupDomain;
+ private $addEmail;
+ private $authSeparator;
/**
* Create new IMAP authentication provider
@@ -36,7 +38,7 @@
* @param boolean $stripeDomain (whether to stripe the domain part from the username or not)
* @param boolean $groupDomain (whether to add the usere to a group corresponding to the domain of the address)
*/
- public function __construct($mailbox, $port = null, $sslmode = null, $domain = null, $stripeDomain = true, $groupDomain = false) {
+ public function __construct($mailbox, $port = null, $sslmode = null, $domain = null, $stripeDomain = true, $groupDomain = false, $addEmail = false, $authSeparator = null) {
parent::__construct($mailbox);
$this->mailbox = $mailbox;
$this->port = $port === null ? 143 : $port;
@@ -44,6 +46,8 @@
$this->domain = $domain === null ? '' : $domain;
$this->stripeDomain = $stripeDomain;
$this->groupDomain = $groupDomain;
+ $this->addEmail = $addEmail;
+ $this->authSeparator = $authSeparator;
}
Look for the configured authSeparator in the login field and replace it with an '@' to be used for the NC username and email.
/**
@@ -61,12 +65,21 @@
$uid = str_replace("%40", "@", $uid);
}
+ $authseparator = strlen($this->authSeparator) == 1 ? $this->authSeparator : '@';
+
+ // Replace $authseparator with '@' in case the user used the wrong separator...
+ if (!(strpos($uid, '@') !== false) && (strpos($uid, $authseparator) !== false)) {
+ $uid = str_replace($authseparator, "@", $uid);
+ }
+
Set $useremail whenever we set $username. Use $authSeparator in $username for authentication to the IMAP server (addresses [Bug 150] (https://github.com/nextcloud/user_external/issues/150), but I have no server to test against )
$pieces = explode('@', $uid);
if ($this->domain !== '') {
if (count($pieces) === 1) {
- $username = $uid . '@' . $this->domain;
+ $username = $pieces[0] . $authseparator . $this->domain;
+ $useremail = $pieces[0] . '@' . $this->domain;
} elseif (count($pieces) === 2 && $pieces[1] === $this->domain) {
- $username = $uid;
+ $username = $pieces[0] . $authseparator . $pieces[1];
+ $useremail = $pieces[0] . '@' . $pieces[1];
if ($this->stripeDomain) {
$uid = $pieces[0];
}
@@ -79,8 +92,14 @@
}
} else {
$username = $uid;
+ $useremail = $uid;
}
Force the NC user id to match the full email (addresses Bug 128 )
-
+ if ($this->stripeDomain) {
+ $uid = $pieces[0];
+ } else {
+ $uid = $useremail;
+ }
+
$groups = [];
if ($this->groupDomain && $pieces[1]) {
$groups[] = $pieces[1];
Save the user's email in NC config if there's an '@' in it and $addEmail is true
@@ -104,6 +123,10 @@
curl_close($ch);
$uid = mb_strtolower($uid);
$this->storeUser($uid, $groups);
+ if ($this->addEmail && (strpos($useremail,'@') !== false) ) {
+ $config = \OC::$server->getConfig();
+ $config->setUserValue( $uid, 'settings', 'email', $useremail);
+ }
return $uid;
} else {
\OC::$server->getLogger()->error(
- Ngôn ngữ chính
- JavaScript
- Star
- 120
- Fork
- 72
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của nextcloud/user_external
-
0. Needs triage bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
nextcloud/user_external#298 · 1 reaction ·
-
NC 35 compatibilityĐang mở0. Needs triage enhancement
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
nextcloud/user_external#311 · 6 bình luận · 6 reaction ·
-
0. Needs triage bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
nextcloud/user_external#310 · 2 bình luận ·
-
v4.0.0 released!Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 20/100
nextcloud/user_external#295 · 3 reaction ·
-
0. Needs triage bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 52/100
nextcloud/user_external#281 · 6 bình luận · 3 reaction ·
Tất cả issue của nextcloud/user_external
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
maproulette/maproulette-frontend#2944 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
jaegertracing/jaeger-ui#4618 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area:plugins enhancement platform:vscode
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
anthropics/claude-code#103166 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Add: Kids Zone LogoĐang mởcheck:failed logos:add
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
-
[workshop-sim] Improve: Add verifiable checkpoint and bridge to Step 5 (What Are Agentic Workflows?)Đang mởfeedback simulation workshop
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
githubnext/gh-aw-workshop#4715 ·
Maintainer thường phản hồi trong vòng 1 ngày