This commit is contained in:
Soumya Raikwar 2025-10-03 22:22:58 +05:30 committed by GitHub
commit 2ba9a4a2d8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 55 additions and 3 deletions

View File

@ -9366,6 +9366,11 @@ definitions:
description: Logout OIDC user session
x-omitempty: true
x-isnullable: true
oidc_auto_login:
type: boolean
description: Auto login OIDC user session to bypass login screen when already authenticated
x-omitempty: true
x-isnullable: true
robot_token_duration:
type: integer
description: The robot account token duration in days

View File

@ -120,6 +120,7 @@ const (
OIDCScope = "oidc_scope"
OIDCUserClaim = "oidc_user_claim"
OIDCLogout = "oidc_logout"
OIDCAutoLogin = "oidc_auto_login"
CfgDriverDB = "db"
NewHarborAdminName = "admin@harbor.local"

View File

@ -78,6 +78,22 @@ func (oc *OIDCController) RedirectLogin() {
oc.SendInternalServerError(err)
return
}
// Check if auto_login is enabled and add prompt=none for silent authentication
oidcSettings, err := config.OIDCSetting(oc.Context())
if err != nil {
log.Errorf("failed to get OIDC settings, error: %v", err)
oc.SendInternalServerError(err)
return
}
if oidcSettings.AutoLogin {
// Add prompt=none to attempt silent authentication
if strings.Contains(url, "?") {
url += "&prompt=none"
} else {
url += "?prompt=none"
}
}
redirectURL := oc.Ctx.Request.URL.Query().Get("redirect_url")
if !utils.IsLocalPath(redirectURL) {
log.Errorf("invalid redirect url: %v", redirectURL)

View File

@ -148,6 +148,7 @@ var (
{Name: common.OIDCAutoOnboard, Scope: UserScope, Group: OIDCGroup, DefaultValue: "false", ItemType: &BoolType{}, Description: `Auto onboard the OIDC user`},
{Name: common.OIDCExtraRedirectParms, Scope: UserScope, Group: OIDCGroup, DefaultValue: "{}", ItemType: &StringToStringMapType{}, Description: `Extra parameters to add when redirect request to OIDC provider`},
{Name: common.OIDCLogout, Scope: UserScope, Group: OIDCGroup, DefaultValue: "false", ItemType: &BoolType{}, Description: `Enable OIDC logout to log out user session from the identity provider.`},
{Name: common.OIDCAutoLogin, Scope: UserScope, Group: OIDCGroup, DefaultValue: "false", ItemType: &BoolType{}, Description: `Enable OIDC auto login to bypass the login screen when user is already authenticated with the OIDC provider.`},
{Name: common.WithTrivy, Scope: SystemScope, Group: BasicGroup, EnvKey: "WITH_TRIVY", DefaultValue: "false", ItemType: &BoolType{}, Editable: true},
// the unit of expiration is days

View File

@ -45,6 +45,7 @@ type OIDCSetting struct {
UserClaim string `json:"user_claim"`
ExtraRedirectParms map[string]string `json:"extra_redirect_parms"`
Logout bool `json:"logout"`
AutoLogin bool `json:"auto_login"`
}
// QuotaSetting wraps the settings for Quota

View File

@ -992,6 +992,32 @@
[(ngModel)]="currentConfig.oidc_logout.value" />
</clr-checkbox-wrapper>
</clr-checkbox-container>
<clr-checkbox-container>
<label for="oidcAutoLogin"
>{{ 'CONFIG.OIDC.OIDC_AUTO_LOGIN' | translate }}
<clr-tooltip>
<clr-icon
clrTooltipTrigger
shape="info-circle"
size="24"></clr-icon>
<clr-tooltip-content
clrPosition="top-right"
clrSize="lg"
*clrIfOpen>
<span>{{ 'TOOLTIP.OIDC_AUTO_LOGIN' | translate }}</span>
</clr-tooltip-content>
</clr-tooltip>
</label>
<clr-checkbox-wrapper>
<input
type="checkbox"
clrCheckbox
name="oidcAutoLogin"
id="oidcAutoLogin"
[disabled]="disabled(currentConfig.oidc_auto_login)"
[(ngModel)]="currentConfig.oidc_auto_login.value" />
</clr-checkbox-wrapper>
</clr-checkbox-container>
<clr-input-container>
<label for="oidcUserClaim"
>{{ 'CONFIG.OIDC.USER_CLAIM' | translate }}

View File

@ -67,12 +67,14 @@ export class AuthCheckGuard {
let navigatorExtra: NavigationExtras = {
queryParams: { redirect_url: state.url },
};
// if primary auth mode enabled, skip the first step
// if primary auth mode or auto login enabled, skip the first step
if (
this.appConfigService.getConfig().auth_mode ==
CONFIG_AUTH_MODE.OIDC_AUTH &&
this.appConfigService.getConfig()
.primary_auth_mode
(this.appConfigService.getConfig()
.primary_auth_mode ||
this.appConfigService.getConfig()
.oidc_auto_login)
) {
window.location.href =
'/c/oidc/login?redirect_url=' +