UpdateApp returns an http.HandlerFunc that handles PUT /oauth2-provider/apps/{app}
(db database.Store, accessURL *url.URL, auditor *audit.Auditor, logger slog.Logger)
| 126 | |
| 127 | // UpdateApp returns an http.HandlerFunc that handles PUT /oauth2-provider/apps/{app} |
| 128 | func UpdateApp(db database.Store, accessURL *url.URL, auditor *audit.Auditor, logger slog.Logger) http.HandlerFunc { |
| 129 | return func(rw http.ResponseWriter, r *http.Request) { |
| 130 | var ( |
| 131 | ctx = r.Context() |
| 132 | app = httpmw.OAuth2ProviderApp(r) |
| 133 | aReq, commitAudit = audit.InitRequest[database.OAuth2ProviderApp](rw, &audit.RequestParams{ |
| 134 | Audit: *auditor, |
| 135 | Log: logger, |
| 136 | Request: r, |
| 137 | Action: database.AuditActionWrite, |
| 138 | }) |
| 139 | ) |
| 140 | aReq.Old = app |
| 141 | defer commitAudit() |
| 142 | var req codersdk.PutOAuth2ProviderAppRequest |
| 143 | if !httpapi.Read(ctx, rw, r, &req) { |
| 144 | return |
| 145 | } |
| 146 | app, err := db.UpdateOAuth2ProviderAppByID(ctx, database.UpdateOAuth2ProviderAppByIDParams{ |
| 147 | ID: app.ID, |
| 148 | UpdatedAt: dbtime.Now(), |
| 149 | Name: req.Name, |
| 150 | Icon: req.Icon, |
| 151 | CallbackURL: req.CallbackURL, |
| 152 | RedirectUris: app.RedirectUris, // Keep existing value |
| 153 | ClientType: app.ClientType, // Keep existing value |
| 154 | DynamicallyRegistered: app.DynamicallyRegistered, // Keep existing value |
| 155 | ClientSecretExpiresAt: app.ClientSecretExpiresAt, // Keep existing value |
| 156 | GrantTypes: app.GrantTypes, // Keep existing value |
| 157 | ResponseTypes: app.ResponseTypes, // Keep existing value |
| 158 | TokenEndpointAuthMethod: app.TokenEndpointAuthMethod, // Keep existing value |
| 159 | Scope: app.Scope, // Keep existing value |
| 160 | Contacts: app.Contacts, // Keep existing value |
| 161 | ClientUri: app.ClientUri, // Keep existing value |
| 162 | LogoUri: app.LogoUri, // Keep existing value |
| 163 | TosUri: app.TosUri, // Keep existing value |
| 164 | PolicyUri: app.PolicyUri, // Keep existing value |
| 165 | JwksUri: app.JwksUri, // Keep existing value |
| 166 | Jwks: app.Jwks, // Keep existing value |
| 167 | SoftwareID: app.SoftwareID, // Keep existing value |
| 168 | SoftwareVersion: app.SoftwareVersion, // Keep existing value |
| 169 | }) |
| 170 | if err != nil { |
| 171 | httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{ |
| 172 | Message: "Internal error updating OAuth2 application.", |
| 173 | Detail: err.Error(), |
| 174 | }) |
| 175 | return |
| 176 | } |
| 177 | aReq.New = app |
| 178 | httpapi.Write(ctx, rw, http.StatusOK, db2sdk.OAuth2ProviderApp(accessURL, app)) |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | // DeleteApp returns an http.HandlerFunc that handles DELETE /oauth2-provider/apps/{app} |
| 183 | func DeleteApp(db database.Store, auditor *audit.Auditor, logger slog.Logger) http.HandlerFunc { |
no test coverage detected