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

(-)a/C4/Letters.pm (-5 lines)
Lines 1604-1614 sub _process_tt { Link Here
1604
    $content = add_tt_filters( $content );
1604
    $content = add_tt_filters( $content );
1605
    $content = qq|[% USE KohaDates %][% USE Remove_MARC_punctuation %]$content|;
1605
    $content = qq|[% USE KohaDates %][% USE Remove_MARC_punctuation %]$content|;
1606
1606
1607
    if ( $content =~ m|\[% otp_token %\]| ) {
1608
        my $patron = Koha::Patrons->find(C4::Context->userenv->{number});
1609
        $tt_params->{otp_token} = Koha::Auth::TwoFactorAuth->new({patron => $patron})->code;
1610
    }
1611
1612
    my $output;
1607
    my $output;
1613
    $template->process( \$content, $tt_params, \$output ) || croak "ERROR PROCESSING TEMPLATE: " . $template->error();
1608
    $template->process( \$content, $tt_params, \$output ) || croak "ERROR PROCESSING TEMPLATE: " . $template->error();
1614
1609
(-)a/Koha/REST/V1/Auth.pm (-3 / +4 lines)
Lines 82-88 sub under { Link Here
82
        }
82
        }
83
83
84
        if ( $c->req->url->to_abs->path eq '/api/v1/oauth/token' ) {
84
        if ( $c->req->url->to_abs->path eq '/api/v1/oauth/token' ) {
85
            #|| $c->req->url->to_abs->path eq '/api/v1/auth/send_otp_token' ) {
86
            # Requesting a token shouldn't go through the API authenticaction chain
85
            # Requesting a token shouldn't go through the API authenticaction chain
87
            $status = 1;
86
            $status = 1;
88
        }
87
        }
Lines 235-241 sub authenticate_api_request { Link Here
235
            if ( $c->req->url->to_abs->path eq '/api/v1/auth/send_otp_token' ) {
234
            if ( $c->req->url->to_abs->path eq '/api/v1/auth/send_otp_token' ) {
236
                $user = Koha::Patrons->find( $session->param('number') );
235
                $user = Koha::Patrons->find( $session->param('number') );
237
                $cookie_auth = 1;
236
                $cookie_auth = 1;
238
                $pending_auth = 1;
237
            } else {
238
                Koha::Exceptions::Authentication::Required->throw(
239
                    error => 'Authentication failure.'
240
                );
239
            }
241
            }
240
        }
242
        }
241
        elsif ($status eq "maintenance") {
243
        elsif ($status eq "maintenance") {
Lines 271-277 sub authenticate_api_request { Link Here
271
         ( $params->{is_public} and
273
         ( $params->{is_public} and
272
          ( C4::Context->preference('RESTPublicAnonymousRequests') or
274
          ( C4::Context->preference('RESTPublicAnonymousRequests') or
273
            $user) or $params->{is_plugin} )
275
            $user) or $params->{is_plugin} )
274
        or $pending_auth
275
    ) {
276
    ) {
276
        # We do not need any authorization
277
        # We do not need any authorization
277
        # Check the parameters
278
        # Check the parameters
(-)a/Koha/REST/V1/TwoFactorAuth.pm (+2 lines)
Lines 45-54 sub send_otp_token { Link Here
45
45
46
    return try {
46
    return try {
47
47
48
        my $code = Koha::Auth::TwoFactorAuth->new({patron => $patron})->code;
48
        my $letter = C4::Letters::GetPreparedLetter(
49
        my $letter = C4::Letters::GetPreparedLetter(
49
            module      => 'members',
50
            module      => 'members',
50
            letter_code => '2FA_OTP_TOKEN',
51
            letter_code => '2FA_OTP_TOKEN',
51
            branchcode  => $patron->branchcode,
52
            branchcode  => $patron->branchcode,
53
            substitute  => { otp_token => $code },
52
            tables      => {
54
            tables      => {
53
                borrowers => $patron->unblessed,
55
                borrowers => $patron->unblessed,
54
            }
56
            }
(-)a/api/v1/swagger/paths/auth.yaml (-1 / +3 lines)
Lines 36-38 Link Here
36
          * `internal_server_error`
36
          * `internal_server_error`
37
        schema:
37
        schema:
38
          $ref: "../swagger.yaml#/definitions/error"
38
          $ref: "../swagger.yaml#/definitions/error"
39
- 
39
    x-koha-authorization:
40
      permissions:
41
        catalogue: "1"

Return to bug 28787