(e *core.RequestEvent)
| 81 | } |
| 82 | |
| 83 | func recordAuthMethods(e *core.RequestEvent) error { |
| 84 | collection, err := findAuthCollection(e) |
| 85 | if err != nil { |
| 86 | return err |
| 87 | } |
| 88 | |
| 89 | result := authMethodsResponse{ |
| 90 | Password: passwordResponse{ |
| 91 | IdentityFields: make([]string, 0, len(collection.PasswordAuth.IdentityFields)), |
| 92 | }, |
| 93 | OAuth2: oauth2Response{ |
| 94 | Providers: make([]providerInfo, 0, len(collection.OAuth2.Providers)), |
| 95 | }, |
| 96 | OTP: otpResponse{ |
| 97 | Enabled: collection.OTP.Enabled, |
| 98 | }, |
| 99 | MFA: mfaResponse{ |
| 100 | Enabled: collection.MFA.Enabled, |
| 101 | }, |
| 102 | } |
| 103 | |
| 104 | if collection.PasswordAuth.Enabled { |
| 105 | result.Password.Enabled = true |
| 106 | result.Password.IdentityFields = collection.PasswordAuth.IdentityFields |
| 107 | } |
| 108 | |
| 109 | if collection.OTP.Enabled { |
| 110 | result.OTP.Duration = collection.OTP.Duration |
| 111 | } |
| 112 | |
| 113 | if collection.MFA.Enabled { |
| 114 | result.MFA.Duration = collection.MFA.Duration |
| 115 | } |
| 116 | |
| 117 | if !collection.OAuth2.Enabled { |
| 118 | result.fillLegacyFields() |
| 119 | |
| 120 | return e.JSON(http.StatusOK, result) |
| 121 | } |
| 122 | |
| 123 | result.OAuth2.Enabled = true |
| 124 | |
| 125 | for _, config := range collection.OAuth2.Providers { |
| 126 | provider, err := config.InitProvider() |
| 127 | if err != nil { |
| 128 | e.App.Logger().Debug( |
| 129 | "Failed to setup OAuth2 provider", |
| 130 | slog.String("name", config.Name), |
| 131 | slog.String("error", err.Error()), |
| 132 | ) |
| 133 | continue // skip provider |
| 134 | } |
| 135 | |
| 136 | info := providerInfo{ |
| 137 | Name: config.Name, |
| 138 | DisplayName: provider.DisplayName(), |
| 139 | Logo: provider.Logo(), |
| 140 | State: security.RandomString(30), |
nothing calls this directly
no test coverage detected
searching dependent graphs…