Funkcjonalność dostępna w systemie od wersji 4.0.38.2

Autoryzacja zapytań

W celu autoryzacji zapytania metodą Basic Auth, należy dodać do zapytania nagłówek z kluczem Authorization i wartością w formacie Basic <zakodowane_dane_logowania>, gdzie dane logowania to ciąg znaków <login>:<hasło> zakodowany w Base64.

Przykład w aplikacji Postman

Poniżej przedstawiono kroki wykonane przy przy wysłaniu zapytania do endpointu api/documents/classes z zastosowaniem autoryzacji metodą Basic Auth w aplikacji Postman :

  1. Dodajemy nagłówek Authorization z wartością dla przykładowego loginu user i hasła password: Basic dXNlcjpwYXNzd29yZA==.
  2. Wysyłamy zapytanie i otrzymujemy wynik w przypadku, gdy:
    1. Dane logowania były poprawne - HTTP 200 i dane w formacie JSON.



    2. Dane logowania były niepoprawne - HTTP 401 oraz informacja "Authorization unsuccessful".

Konfiguracja web.xml

W przypadku problemów z autoryzacją zapytań metodą Basic Auth, należy upewnić się, że w pliku web.xml znajdują się następujące wpisy:

<filter>
   <filter-name>BasicAuthFilter</filter-name>
   <filter-class>com.suncode.pwfl.web.filter.BasicAuthFilter</filter-class>
</filter>
<filter-mapping>
   <filter-name>BasicAuthFilter</filter-name>
   <url-pattern>/api/*</url-pattern>
   <url-pattern>/plugin/*</url-pattern>
</filter-mapping>

Wpisy powinny zostać dodane przed wpisami <filter> oraz <filter-mapping> dotyczącymi filtra ActiveSessionFilter.

 

Functionality available in the system since version 4.0.38.2

Query authorization

To authorize a query using the Basic Auth method, add a header to the query with an Authorization key and a value in the format Basic <encoded_login_data>, where the login data is the string <login>:<password> encoded in Base64.

Example in Postman application

Below are the steps performed when sending a request to the api/documents/classes endpoint using Basic Auth authorization in the Postman application:

  1. Add an Authorization header with a value for the example login user and password: Basic dXNlcjpwYXNzd29yZA==.
  2. We send the request and get the result in case:
    1. The login credentials were valid - HTTP 200 and the data in JSON format.



    2. The login credentials were invalid - HTTP 401 and the message "Authorization unsuccessful".

Configure web.xml

If you have problems with Basic Auth query authorization, make sure you have the following entries in your web.xml file:

<filter>
   <filter-name>BasicAuthFilter</filter-name>
   <filter-class>com.suncode.pwfl.web.filter.BasicAuthFilter</filter-class>
</filter>
<filter-mapping>
   <filter-name>BasicAuthFilter</filter-name>
   <url-pattern>/api/*</url-pattern>
   <url-pattern>/plugin/*</url-pattern>
</filter-mapping>

The entries should be added before the <filter> and <filter-mapping> entries for the ActiveSessionFilter.