Fix passwordless login on official bitwarden instance

This commit is contained in:
Bernd Schoolmann 2023-09-11 15:05:30 +02:00
parent 193fa60475
commit ef5083cfb4
No known key found for this signature in database
3 changed files with 8 additions and 1 deletions

View File

@ -144,7 +144,7 @@ func LoginWithDevice(ctx context.Context, email string, cfg *config.Config, vaul
case <-timeoutChan:
return LoginResponseToken{}, crypto.MasterKey{}, "", fmt.Errorf("timed out waiting for device to be authorized")
default:
authRequestData, err := GetAuthRequest(ctx, data.ID, cfg)
authRequestData, err := GetAuthResponse(ctx, accessCode, data.ID, cfg)
if err != nil {
log.Error("Could not get auth request: %s", err.Error())
}

View File

@ -99,6 +99,7 @@ func makeAuthenticatedHTTPRequest(ctx context.Context, req *http.Request, recv i
if token, ok := ctx.Value(AuthToken{}).(string); ok {
req.Header.Set("Authorization", "Bearer "+token)
}
req.Header.Set("device-type", deviceType())
res, err := httpClient.Do(req)
if err != nil {

View File

@ -104,3 +104,9 @@ func CreateAuthRequest(ctx context.Context, code string, deviceIdentifier string
return authrequestData, nil
}
}
func GetAuthResponse(ctx context.Context, code string, requestUUID string, config *config.Config) (AuthRequestData, error) {
var authRequest AuthRequestData
err := authenticatedHTTPGet(ctx, config.ConfigFile.ApiUrl+"/auth-requests/"+requestUUID+"/response?code="+code, &authRequest)
return authRequest, err
}