View | Details | Raw Unified | Return to bug 23146
Collapse All | Expand All

(-)a/Koha/REST/V1/Auth.pm (-1 / +7 lines)
Lines 71-77 sub under { Link Here
71
                "Configuration prevents the usage of this endpoint by unprivileged users");
71
                "Configuration prevents the usage of this endpoint by unprivileged users");
72
        }
72
        }
73
73
74
        $status = authenticate_api_request($c);
74
        if ( $c->req->url->to_string eq '/api/v1/oauth/token' ) {
75
            # Requesting a token shouldn't go through the API authenticaction chain
76
            $status = 1;
77
        }
78
        else {
79
            $status = authenticate_api_request($c);
80
        }
75
81
76
    } catch {
82
    } catch {
77
        unless (blessed($_)) {
83
        unless (blessed($_)) {
(-)a/Koha/REST/V1/OAuth.pm (-3 / +20 lines)
Lines 21-26 use Module::Load::Conditional; Link Here
21
21
22
use C4::Context;
22
use C4::Context;
23
use Koha::OAuth;
23
use Koha::OAuth;
24
use MIME::Base64;
24
25
25
use Mojo::Base 'Mojolicious::Controller';
26
use Mojo::Base 'Mojolicious::Controller';
26
27
Lines 53-60 sub token { Link Here
53
        return $c->render(status => 400, openapi => {error => 'Unimplemented grant type'});
54
        return $c->render(status => 400, openapi => {error => 'Unimplemented grant type'});
54
    }
55
    }
55
56
56
    my $client_id = $c->validation->param('client_id');
57
    my $client_id;
57
    my $client_secret = $c->validation->param('client_secret');
58
    my $client_secret;
59
60
    my $authorization_header = $c->req->headers->authorization;
61
62
    if ( $authorization_header and $authorization_header =~ /^Basic / ) {
63
        my ( $type, $credentials ) = split / /, $authorization_header;
64
65
        unless ($credentials) {
66
            Koha::Exceptions::Authentication::Required->throw( error => 'Authentication failure.' );
67
        }
68
69
        my $decoded_credentials = decode_base64( $credentials );
70
        ( $client_id, $client_secret ) = split( /:/, $decoded_credentials, 2 );
71
    }
72
    else {
73
        $client_id = $c->validation->param('client_id');
74
        $client_secret = $c->validation->param('client_secret');
75
    }
58
76
59
    my $cb = "${grant_type}_grant";
77
    my $cb = "${grant_type}_grant";
60
    my $server = Net::OAuth2::AuthorizationServer->new;
78
    my $server = Net::OAuth2::AuthorizationServer->new;
61
- 

Return to bug 23146