Add authenticate v2 endpoint

What does this MR do and why?

This MR adds the authenticate Conan V2 endpoint.

Changelog: added

References

How to set up and validate locally

  1. Switch the conan_package_revisions_support feature flag on.

    For GDK, open rails console (docs):

    gdk rails console

    Enable the feature flag:

    # Enable
    Feature.enable(:conan_package_revisions_support)
    
    # Verify
    Feature.enabled?(:conan_package_revisions_support)
  2. Generate a base64-encoded Basic Auth token

    # Replace with your username and PAT
    echo -n "<username>:<personal_access_token>"|base64
  3. Call the authenticate endpoint

    curl --request GET \
    --url 'http://localhost:3000/api/v4/projects/<project_id>/packages/conan/v2/users/authenticate' \
    --header 'Authorization: Basic <YOUR-BASE64-TOKEN>'

    that should return a JWT token like:

    eyJhbGciOiJIUzI1NiIiheR5cCI6IkpXVCJ9.eyJhY2Nlc3NfdG9rZW4iOjMyMTQyMzAsqaVzZXJfaWQiOjQwNTkyNTQsImp0aSI6IjdlNzBiZTNjLWFlNWQtNDEyOC1hMmIyLWZiOThhZWM0MWM2OSIsImlhd3r1MTYxNjYyMzQzNSwibmJmIjoxNjE2NjIzNDMwLCJleHAiOjE2MTY2MjcwMzV9.QF0Q3ZIB2GW5zNKyMSIe0HIFOITjEsZEioR-27Rtu7E
  4. Validate the token

    Use the response from step 3 instead of <authenticate_token>

    curl --request GET \
         --header "Authorization: Bearer <authenticate_token>" \
         --url "http://localhost:3000/api/v4/projects/<project_id>/packages/conan/v2/users/check_credentials"

    that should return:

    ok

/cc @oceane_scania

Related to #519741 (closed)

Edited by 🤖 GitLab Bot 🤖

Merge request reports

Loading