🐛 Bug fixes on multi-factors based authentication

This commit is contained in:
LittleSheep 2024-10-13 14:02:48 +08:00
parent 6ea4850459
commit 68b4390edf
3 changed files with 9 additions and 11 deletions

View File

@ -4,12 +4,10 @@
<option name="autoReloadType" value="ALL" /> <option name="autoReloadType" value="ALL" />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":sparkles: Allow user view and remove notification subscriptions"> <list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":recycle: Improve notifications mark read system">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/models/notifications.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/models/notifications.go" afterDir="false" /> <change beforePath="$PROJECT_DIR$/pkg/internal/models/auth.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/models/auth.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/server/api/notifications_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/server/api/notifications_api.go" afterDir="false" /> <change beforePath="$PROJECT_DIR$/pkg/internal/services/ticket.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/ticket.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/services/accounts.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/accounts.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/services/cleaner.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/cleaner.go" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -156,7 +154,6 @@
</option> </option>
</component> </component>
<component name="VcsManagerConfiguration"> <component name="VcsManagerConfiguration">
<MESSAGE value=":bug: Fix query issue" />
<MESSAGE value=":bug: Fix compare perm node panic" /> <MESSAGE value=":bug: Fix compare perm node panic" />
<MESSAGE value=":bug: Fix compare perm node function" /> <MESSAGE value=":bug: Fix compare perm node function" />
<MESSAGE value=":sparkles: Bot related bot key apis" /> <MESSAGE value=":sparkles: Bot related bot key apis" />
@ -181,7 +178,8 @@
<MESSAGE value=":recycle: Single table to store auth preferences" /> <MESSAGE value=":recycle: Single table to store auth preferences" />
<MESSAGE value=":bug: Trying to prevent send same notification to the same user in batch" /> <MESSAGE value=":bug: Trying to prevent send same notification to the same user in batch" />
<MESSAGE value=":sparkles: Allow user view and remove notification subscriptions" /> <MESSAGE value=":sparkles: Allow user view and remove notification subscriptions" />
<option name="LAST_COMMIT_MESSAGE" value=":sparkles: Allow user view and remove notification subscriptions" /> <MESSAGE value=":recycle: Improve notifications mark read system" />
<option name="LAST_COMMIT_MESSAGE" value=":recycle: Improve notifications mark read system" />
</component> </component>
<component name="VgoProject"> <component name="VgoProject">
<settings-migrated>true</settings-migrated> <settings-migrated>true</settings-migrated>

View File

@ -8,7 +8,7 @@ import (
) )
type AuthConfig struct { type AuthConfig struct {
MaximumAuthSteps int `json:"maximum_auth_steps" validate:"required,min=1"` MaximumAuthSteps int `json:"maximum_auth_steps"`
} }
type AuthFactorType = int8 type AuthFactorType = int8

View File

@ -15,7 +15,7 @@ import (
const InternalTokenAudience = "solar-network" const InternalTokenAudience = "solar-network"
// DetectRisk is used for detect user environment is suitable for no multi-factor authenticate or not. // DetectRisk is used for detect user environment is suitable for no multifactorial authenticating or not.
// Return the remaining steps, value is from 1 to 2, may appear 3 if user enabled the third-authentication-factor. // Return the remaining steps, value is from 1 to 2, may appear 3 if user enabled the third-authentication-factor.
func DetectRisk(user models.Account, ip, ua string) int { func DetectRisk(user models.Account, ip, ua string) int {
var clue int64 var clue int64
@ -25,11 +25,11 @@ func DetectRisk(user models.Account, ip, ua string) int {
Model(models.AuthTicket{}). Model(models.AuthTicket{}).
Count(&clue).Error; err == nil { Count(&clue).Error; err == nil {
if clue >= 1 { if clue >= 1 {
return 1 return 3
} }
} }
return 2 return 3
} }
// PickTicketAttempt is trying to pick up the ticket that hasn't completed but created by a same client (identify by ip address). // PickTicketAttempt is trying to pick up the ticket that hasn't completed but created by a same client (identify by ip address).