Bugzilla – Attachment 151321 Details for
Bug 23336
Add an API endpoint for checking an item out to a patron
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23336: (follow-up) Switch to using Koha::Token
Bug-23336-follow-up-Switch-to-using-KohaToken.patch (text/plain), 2.85 KB, created by
Tomás Cohen Arazi (tcohen)
on 2023-05-16 19:54:22 UTC
(
hide
)
Description:
Bug 23336: (follow-up) Switch to using Koha::Token
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2023-05-16 19:54:22 UTC
Size:
2.85 KB
patch
obsolete
>From 1bead8eb32a3d6e86c26c940502c6006db7df19e Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Tue, 16 May 2023 10:46:43 +0100 >Subject: [PATCH] Bug 23336: (follow-up) Switch to using Koha::Token > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/REST/V1/Checkouts.pm | 33 ++++++++------------------------- > 1 file changed, 8 insertions(+), 25 deletions(-) > >diff --git a/Koha/REST/V1/Checkouts.pm b/Koha/REST/V1/Checkouts.pm >index 72e88ed858b..7997941b3cb 100644 >--- a/Koha/REST/V1/Checkouts.pm >+++ b/Koha/REST/V1/Checkouts.pm >@@ -19,7 +19,6 @@ use Modern::Perl; > > use Mojo::Base 'Mojolicious::Controller'; > use Mojo::JSON; >-use Mojo::JWT; > use Digest::MD5 qw( md5_base64 ); > use Encode; > >@@ -28,6 +27,7 @@ use C4::Context; > use C4::Circulation qw( AddIssue AddRenewal CanBookBeRenewed ); > use Koha::Checkouts; > use Koha::Old::Checkouts; >+use Koha::Token; > > use Try::Tiny qw( catch try ); > >@@ -123,13 +123,9 @@ sub get_availability { > C4::Circulation::CanBookBeIssued( $patron, undef, undef, $inprocess, $ignore_reserves, > $params ); > >- my $token; >- if (keys %{$confirmation}) { >- my $claims = { map { $_ => 1 } keys %{$confirmation} }; >- my $secret = >- md5_base64( Encode::encode( 'UTF-8', C4::Context->config('pass') ) ); >- $token = Mojo::JWT->new( claims => $claims, secret => $secret )->encode; >- } >+ my $confirm_keys = join( /:/, sort keys %{$confirmation} ); >+ my $tokenizer = Koha::Token->new; >+ my $token = $tokenizer->generate_jwt({ id => $confirm_keys }); > > my $response = { > blockers => $impossible, >@@ -210,23 +206,10 @@ sub add { > # Check for existance of confirmation token > # and if exists check validity > if ( my $token = $c->validation->param('confirmation') ) { >- my $secret = >- md5_base64( >- Encode::encode( 'UTF-8', C4::Context->config('pass') ) ); >- my $claims = try { >- Mojo::JWT->new( secret => $secret )->decode($token); >- } >- catch { >- return $c->render( >- status => 403, >- openapi => { error => "Confirmation required" } >- ); >- }; >- >- # check claims match >- my $token_claims = join( / /, sort keys %{$claims} ); >- my $confirm_keys = join( / /, sort keys %{$confirmation} ); >- $confirmed = 1 if ( $token_claims eq $confirm_keys ); >+ my $confirm_keys = join( /:/, sort keys %{$confirmation} ); >+ my $tokenizer = Koha::Token->new; >+ $confirmed = $tokenizer->check_jwt( >+ { id => $confirm_keys, token => $token } ); > } > > unless ($confirmed) { >-- >2.40.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 23336
:
91632
|
91633
|
91634
|
150947
|
150948
|
150949
|
150954
|
150955
|
150956
|
150960
|
150961
|
150962
|
151253
|
151318
|
151319
|
151320
|
151321
|
151322
|
151353
|
151354
|
151355
|
151356
|
151357
|
152712
|
152713
|
152714
|
152715
|
152716
|
152938
|
152999
|
153000
|
153095
|
153096