xs/auth.xs

filter: Statementstmt 98.0% 148 / 151 Branchbran 60.6% 108 / 178 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 77.8% 256 / 329 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« include/punk/punk_ratelimit.h ↑ Summary include/punk/punk_dbi.h »
1 MODULE = Punk PACKAGE = Punk::Context
2  
3 PROTOTYPES: DISABLE
4  
5 # The authentication context surface, all C (punk_auth.h): login/logout/
6 # auth_id are a session load and a hash write; current_user loads through
7 # the configured model and the await seam; check_password fronts the KDF
8 # with the dummy-verify rule; the token pair carries the delete-first spend
9 # order. lib/Punk/Auth.pm is documentation only.
10  
11 # $c->login($user_or_id): record the signed-in user in the session. A hashref
12 # uses its id field (the auth fields map); anything else is the id itself.
13 # Chains.
14 SV *
15 login(self, user)
16 SV *self
17 SV *user
18 CODE:
19 {
20 35 HV *cfg = pauth_cfg(aTHX_ self);
21 35 SV *id = NULL, *sess;
22 STRLEN kl;
23 const char *key;
24 35 ▶ if (!cfg)
Branch: 1 branch
BranchTrueFalseTotal
if (!cfg) 1 34 35
25 1 croak("Punk: login needs the auth keyword (add `auth ...`)");
26 34 ▶ if (SvROK(user) && SvTYPE(SvRV(user)) == SVt_PVHV) {
Branch: 2 branches
BranchTrueFalseTotal
if (SvROK(user) && SvTYPE(SvRV(user)) == SVt_PVHV) { 20 14 34
if (SvROK(user) && SvTYPE(SvRV(user)) == SVt_PVHV) { 20 0 20
27 20 HV *u = (HV *)SvRV(user);
28 STRLEN idl;
29 20 const char *idf = pauth_field(aTHX_ cfg, "id", "id", &idl);
30 20 SV **e = hv_fetch(u, idf, (I32)idl, 0);
31 20 ▶ if (!(e && *e && SvOK(*e)))
Branch: 3 branches
BranchTrueFalseTotal
if (!(e && *e && SvOK(*e))) 19 1 20
if (!(e && *e && SvOK(*e))) 19 0 19
if (!(e && *e && SvOK(*e))) 0 19 19
32 1 croak("Punk: login was handed a user with no '%s'", idf);
33 19 id = *e;
34 }
35 14 ▶ else if (SvOK(user)) id = user;
Branch: 1 branch
BranchTrueFalseTotal
else if (SvOK(user)) id = user; 13 1 14
36 1 else croak("Punk: login needs a user row or id");
37 32 ▶ if (!pauth_id_ok(aTHX_ id))
Branch: 1 branch
BranchTrueFalseTotal
if (!pauth_id_ok(aTHX_ id)) 3 29 32
38 3 croak("Punk: login needs a user id that is not empty and not 0");
39  
40 29 key = ps_cfg_str(aTHX_ cfg, "session_key", "user_id", &kl);
41 29 sess = ps_load(aTHX_ self);
42 29 ▶ if (sess && SvROK(sess) && SvTYPE(SvRV(sess)) == SVt_PVHV) {
Branch: 3 branches
BranchTrueFalseTotal
if (sess && SvROK(sess) && SvTYPE(SvRV(sess)) == SVt_PVHV) { 29 0 29
if (sess && SvROK(sess) && SvTYPE(SvRV(sess)) == SVt_PVHV) { 29 0 29
if (sess && SvROK(sess) && SvTYPE(SvRV(sess)) == SVt_PVHV) { 29 0 29
43 29 (void)hv_store((HV *)SvRV(sess), key, (I32)kl, newSVsv(id), 0);
44 /* the CSRF token minted for the anonymous session goes with it:
45 * one planted before the login would otherwise validate for the
46 * user after it */
47 29 (void)hv_delete((HV *)SvRV(sess), "punk.csrf", 9, G_DISCARD);
48 }
49 29 ▶ if (sess) SvREFCNT_dec(sess);
Branch: 1 branch
BranchTrueFalseTotal
if (sess) SvREFCNT_dec(sess); 29 0 29
50 {
51 29 HV *stash = ps_stash(aTHX_ pcx_av(aTHX_ self));
52 /* a fresh login invalidates this request's memoized user */
53 29 (void)hv_delete(stash, "punk.auth", 9, G_DISCARD);
54 /* A login is the privilege boundary, so a stored session gets a
55 * new id here: one planted in the browser before the login must
56 * not be the name of the session after it. */
57 29 ps_mark_rotate(aTHX_ self, ps_cfg(aTHX_ self), stash);
58 /* ...and it outranks a logout earlier in the same request, whose
59 * deletion cookie would otherwise be the only thing written. */
60 29 (void)hv_delete(stash, "punk.session.expire", 19, G_DISCARD);
61 }
62 29 RETVAL = newSVsv(self);
63 }
64 OUTPUT:
65 RETVAL
66  
67 # $c->logout: empty the session and delete its cookie (session_expire), and
68 # forget the memoized user. Chains.
69 SV *
70 logout(self)
71 SV *self
72 CODE:
73 {
74 6 SV *r = pcx_call_meth(aTHX_ self, "session_expire", NULL, 0, 1);
75 6 ▶ if (r) SvREFCNT_dec(r);
Branch: 1 branch
BranchTrueFalseTotal
if (r) SvREFCNT_dec(r); 6 0 6
76 {
77 6 HV *stash = ps_stash(aTHX_ pcx_av(aTHX_ self));
78 6 (void)hv_delete(stash, "punk.auth", 9, G_DISCARD);
79 }
80 6 RETVAL = newSVsv(self);
81 }
82 OUTPUT:
83 RETVAL
84  
85 # $c->auth_id: the signed-in user id straight off the session - no database.
86 # The oauth2_server authenticate shape: an id, or undef.
87 SV *
88 auth_id(self)
89 SV *self
90 CODE:
91 {
92 17 HV *cfg = pauth_cfg(aTHX_ self);
93 SV *id;
94 17 ▶ if (!cfg)
Branch: 1 branch
BranchTrueFalseTotal
if (!cfg) 1 16 17
95 1 croak("Punk: auth_id needs the auth keyword (add `auth ...`)");
96 16 id = pauth_session_id(aTHX_ self, cfg);
97 16 ▶ RETVAL = id ? id : &PL_sv_undef;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = id ? id : &PL_sv_undef; 10 6 16
98 }
99 OUTPUT:
100 RETVAL
101  
102 # $c->current_user: the signed-in user's row, loaded once per request and
103 # memoized; undef when nobody is signed in or the row is gone.
104 SV *
105 current_user(self)
106 SV *self
107 CODE:
108 {
109 12 HV *cfg = pauth_cfg(aTHX_ self);
110 SV *user;
111 12 ▶ if (!cfg)
Branch: 1 branch
BranchTrueFalseTotal
if (!cfg) 1 11 12
112 1 croak("Punk: current_user needs the auth keyword "
113 "(add `auth ...`)");
114 11 user = pauth_current_user(aTHX_ self, cfg);
115 11 ▶ RETVAL = user ? user : &PL_sv_undef;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = user ? user : &PL_sv_undef; 10 1 11
116 }
117 OUTPUT:
118 RETVAL
119  
120 # $c->check_password($user, $password): true only for a real match. With no
121 # user or no stored hash the same PBKDF2 work is burned before returning
122 # false, so login response time cannot say which emails exist.
123 IV
124 check_password(self, user, password)
125 SV *self
126 SV *user
127 SV *password
128 CODE:
129 {
130 4 HV *cfg = pauth_cfg(aTHX_ self);
131 4 SV *stored = NULL;
132 4 U32 iterations = 0;
133 STRLEN pfl;
134 const char *pf;
135 4 ▶ if (!cfg)
Branch: 1 branch
BranchTrueFalseTotal
if (!cfg) 1 3 4
136 1 croak("Punk: check_password needs the auth keyword "
137 "(add `auth ...`)");
138 3 pf = pauth_field(aTHX_ cfg, "password", "password_hash", &pfl);
139 {
140 3 SV **it = hv_fetchs(cfg, "iterations", 0);
141 3 ▶ if (it && *it && SvOK(*it) && SvIV(*it) > 0)
Branch: 4 branches
BranchTrueFalseTotal
if (it && *it && SvOK(*it) && SvIV(*it) > 0) 0 3 3
if (it && *it && SvOK(*it) && SvIV(*it) > 0) 0 0 0
if (it && *it && SvOK(*it) && SvIV(*it) > 0) 0 0 0
if (it && *it && SvOK(*it) && SvIV(*it) > 0) 0 0 0
142 0 iterations = (U32)SvIV(*it);
143 else {
144 3 SV *g = get_sv("Punk::Auth::Password::ITERATIONS", 0);
145 3 ▶ if (g && SvOK(g) && SvIV(g) > 0) iterations = (U32)SvIV(g);
Branch: 3 branches
BranchTrueFalseTotal
if (g && SvOK(g) && SvIV(g) > 0) iterations = (U32)SvIV(g); 3 0 3
if (g && SvOK(g) && SvIV(g) > 0) iterations = (U32)SvIV(g); 3 0 3
if (g && SvOK(g) && SvIV(g) > 0) iterations = (U32)SvIV(g); 3 0 3
146 }
147 }
148 3 ▶ if (SvROK(user) && SvTYPE(SvRV(user)) == SVt_PVHV) {
Branch: 2 branches
BranchTrueFalseTotal
if (SvROK(user) && SvTYPE(SvRV(user)) == SVt_PVHV) { 2 1 3
if (SvROK(user) && SvTYPE(SvRV(user)) == SVt_PVHV) { 2 0 2
149 2 SV **e = hv_fetch((HV *)SvRV(user), pf, (I32)pfl, 0);
150 2 ▶ if (e && *e && SvOK(*e) && SvCUR(*e)) stored = *e;
Branch: 4 branches
BranchTrueFalseTotal
if (e && *e && SvOK(*e) && SvCUR(*e)) stored = *e; 2 0 2
if (e && *e && SvOK(*e) && SvCUR(*e)) stored = *e; 2 0 2
if (e && *e && SvOK(*e) && SvCUR(*e)) stored = *e; 2 0 2
if (e && *e && SvOK(*e) && SvCUR(*e)) stored = *e; 2 0 2
151 }
152 3 ▶ if (!stored) {
Branch: 1 branch
BranchTrueFalseTotal
if (!stored) { 1 2 3
153 1 STRLEN pl = 0;
154 2 ▶ const char *p = SvOK(password) ? SvPV_const(password, pl) : "";
Branch: 1 branch
BranchTrueFalseTotal
const char *p = SvOK(password) ? SvPV_const(password, pl) : ""; 1 0 1
155 1 pwd_dummy_verify(aTHX_ (const unsigned char *)p, pl, iterations);
156 1 RETVAL = 0;
157 }
158 else {
159 /* an undef password is the empty one, verified in full: the
160 * early return it used to take answered faster for a known
161 * email than for an unknown one */
162 2 STRLEN pl = 0, sl;
163 4 ▶ const char *p = SvOK(password) ? SvPV_const(password, pl) : "";
Branch: 1 branch
BranchTrueFalseTotal
const char *p = SvOK(password) ? SvPV_const(password, pl) : ""; 2 0 2
164 2 const char *s = SvPV_const(stored, sl);
165 2 RETVAL = pwd_verify(aTHX_ (const unsigned char *)p, pl, s, sl);
166 }
167 }
168 OUTPUT:
169 RETVAL
170  
171 # $c->issue_token($user_id, $kind, $ttl): a single-use token on the token
172 # model. Storage sees only the sha256 digest with an absolute expiry; a new
173 # token invalidates the user's older tokens of the same kind, so a re-sent
174 # mail leaves exactly one live link. Returns the plaintext, once.
175 SV *
176 issue_token(self, user_id, kind, ttl)
177 SV *self
178 SV *user_id
179 SV *kind
180 SV *ttl
181 CODE:
182 {
183 11 HV *cfg = pauth_cfg(aTHX_ self);
184 SV *m, *tok;
185 11 ▶ if (!cfg)
Branch: 1 branch
BranchTrueFalseTotal
if (!cfg) 1 10 11
186 1 croak("Punk: issue_token needs the auth keyword "
187 "(add `auth ...`)");
188 10 ▶ if (!SvOK(user_id) || !SvOK(kind) || !SvOK(ttl) || SvIV(ttl) <= 0)
Branch: 4 branches
BranchTrueFalseTotal
if (!SvOK(user_id) || !SvOK(kind) || !SvOK(ttl) || SvIV(ttl) <= 0) 10 0 10
if (!SvOK(user_id) || !SvOK(kind) || !SvOK(ttl) || SvIV(ttl) <= 0) 10 0 10
if (!SvOK(user_id) || !SvOK(kind) || !SvOK(ttl) || SvIV(ttl) <= 0) 10 0 10
if (!SvOK(user_id) || !SvOK(kind) || !SvOK(ttl) || SvIV(ttl) <= 0) 0 10 10
189 0 croak("Punk: issue_token needs a user id, a kind and a ttl");
190 10 m = pauth_model(aTHX_ self, cfg, "token_model", "issue_token");
191 { /* older same-kind tokens die first */
192 9 HV *filter = newHV();
193 SV *argv[1], *raw, *res;
194 AV *rows;
195 9 (void)hv_stores(filter, "user_id", newSVsv(user_id));
196 9 (void)hv_stores(filter, "kind", newSVsv(kind));
197 9 argv[0] = sv_2mortal(newRV_noinc((SV *)filter));
198 9 raw = pcx_call_meth(aTHX_ m, "search", argv, 1, 1);
199 9 ▶ res = pauth_await(aTHX_ self, raw ? raw : &PL_sv_undef);
Branch: 1 branch
BranchTrueFalseTotal
res = pauth_await(aTHX_ self, raw ? raw : &PL_sv_undef); 9 0 9
200 9 ▶ if (raw) SvREFCNT_dec(raw);
Branch: 1 branch
BranchTrueFalseTotal
if (raw) SvREFCNT_dec(raw); 9 0 9
201 9 rows = pauth_rows(aTHX_ res);
202 9 ▶ if (rows) {
Branch: 1 branch
BranchTrueFalseTotal
if (rows) { 9 0 9
203 9 SSize_t i, n = av_len(rows) + 1;
204 11 ▶ for (i = 0; i < n; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < n; i++) { 2 9 11
205 2 SV **rp = av_fetch(rows, i, 0);
206 SV **idp;
207 SV *dargv[2], *draw, *dres;
208 2 ▶ if (!(rp && *rp && SvROK(*rp))) continue;
Branch: 3 branches
BranchTrueFalseTotal
if (!(rp && *rp && SvROK(*rp))) continue; 2 0 2
if (!(rp && *rp && SvROK(*rp))) continue; 2 0 2
if (!(rp && *rp && SvROK(*rp))) continue; 0 2 2
209 2 idp = hv_fetchs((HV *)SvRV(*rp), "id", 0);
210 2 ▶ if (!(idp && *idp && SvOK(*idp))) continue;
Branch: 3 branches
BranchTrueFalseTotal
if (!(idp && *idp && SvOK(*idp))) continue; 2 0 2
if (!(idp && *idp && SvOK(*idp))) continue; 2 0 2
if (!(idp && *idp && SvOK(*idp))) continue; 0 2 2
211 2 dargv[0] = sv_2mortal(newSVpvs("id"));
212 2 dargv[1] = *idp;
213 2 draw = pcx_call_meth(aTHX_ m, "delete", dargv, 2, 1);
214 2 ▶ dres = pauth_await(aTHX_ self,
Branch: 1 branch
BranchTrueFalseTotal
dres = pauth_await(aTHX_ self, 2 0 2
215 draw ? draw : &PL_sv_undef);
216 2 ▶ if (draw) SvREFCNT_dec(draw);
Branch: 1 branch
BranchTrueFalseTotal
if (draw) SvREFCNT_dec(draw); 2 0 2
217 2 ▶ if (dres) SvREFCNT_dec(dres);
Branch: 1 branch
BranchTrueFalseTotal
if (dres) SvREFCNT_dec(dres); 2 0 2
218 }
219 }
220 9 ▶ if (res) SvREFCNT_dec(res);
Branch: 1 branch
BranchTrueFalseTotal
if (res) SvREFCNT_dec(res); 9 0 9
221 }
222 9 tok = pwd_token(aTHX);
223 {
224 9 HV *data = newHV();
225 SV *argv[1], *raw, *res;
226 STRLEN tl;
227 const unsigned char *tp =
228 9 (const unsigned char *)SvPV_const(tok, tl);
229 9 (void)hv_stores(data, "user_id", newSVsv(user_id));
230 9 (void)hv_stores(data, "kind", newSVsv(kind));
231 9 (void)hv_stores(data, "digest", pwd_token_digest(aTHX_ tp, tl));
232 9 (void)hv_stores(data, "expires",
233 newSViv((IV)time(NULL) + SvIV(ttl)));
234 9 argv[0] = sv_2mortal(newRV_noinc((SV *)data));
235 9 raw = pcx_call_meth(aTHX_ m, "create", argv, 1, 1);
236 9 ▶ res = pauth_await(aTHX_ self, raw ? raw : &PL_sv_undef);
Branch: 1 branch
BranchTrueFalseTotal
res = pauth_await(aTHX_ self, raw ? raw : &PL_sv_undef); 9 0 9
237 9 ▶ if (raw) SvREFCNT_dec(raw);
Branch: 1 branch
BranchTrueFalseTotal
if (raw) SvREFCNT_dec(raw); 9 0 9
238 9 ▶ if (res) SvREFCNT_dec(res);
Branch: 1 branch
BranchTrueFalseTotal
if (res) SvREFCNT_dec(res); 9 0 9
239 }
240 9 SvREFCNT_dec(m);
241 9 RETVAL = tok;
242 }
243 OUTPUT:
244 RETVAL
245  
246 # $c->take_token($token, @kinds): the row, or nothing. THE ORDER IS THE
247 # FEATURE: look up by digest, delete FIRST, then validate kind and expiry -
248 # a token is spent whether or not it turns out valid, so a wrong-kind probe
249 # burns it rather than leaving it live for its real endpoint.
250 SV *
251 take_token(self, token, ...)
252 SV *self
253 SV *token
254 CODE:
255 {
256 9 HV *cfg = pauth_cfg(aTHX_ self);
257 9 SV *m, *row_copy = NULL;
258 9 ▶ if (!cfg)
Branch: 1 branch
BranchTrueFalseTotal
if (!cfg) 1 8 9
259 1 croak("Punk: take_token needs the auth keyword "
260 "(add `auth ...`)");
261 8 ▶ if (!SvOK(token) || !SvCUR(token) || items < 3)
Branch: 3 branches
BranchTrueFalseTotal
if (!SvOK(token) || !SvCUR(token) || items < 3) 8 0 8
if (!SvOK(token) || !SvCUR(token) || items < 3) 8 0 8
if (!SvOK(token) || !SvCUR(token) || items < 3) 0 8 8
262 0 XSRETURN_UNDEF;
263 8 m = pauth_model(aTHX_ self, cfg, "token_model", "take_token");
264 {
265 8 HV *filter = newHV();
266 SV *argv[1], *raw, *res;
267 AV *rows;
268 8 SV **rp = NULL;
269 STRLEN tl;
270 const unsigned char *tp =
271 8 (const unsigned char *)SvPV_const(token, tl);
272 8 (void)hv_stores(filter, "digest", pwd_token_digest(aTHX_ tp, tl));
273 8 argv[0] = sv_2mortal(newRV_noinc((SV *)filter));
274 8 raw = pcx_call_meth(aTHX_ m, "search", argv, 1, 1);
275 8 ▶ res = pauth_await(aTHX_ self, raw ? raw : &PL_sv_undef);
Branch: 1 branch
BranchTrueFalseTotal
res = pauth_await(aTHX_ self, raw ? raw : &PL_sv_undef); 8 0 8
276 8 ▶ if (raw) SvREFCNT_dec(raw);
Branch: 1 branch
BranchTrueFalseTotal
if (raw) SvREFCNT_dec(raw); 8 0 8
277 8 rows = pauth_rows(aTHX_ res);
278 8 ▶ if (rows && av_len(rows) >= 0) rp = av_fetch(rows, 0, 0);
Branch: 2 branches
BranchTrueFalseTotal
if (rows && av_len(rows) >= 0) rp = av_fetch(rows, 0, 0); 8 0 8
if (rows && av_len(rows) >= 0) rp = av_fetch(rows, 0, 0); 5 3 8
279 8 ▶ if (rp && *rp && SvROK(*rp)
Branch: 3 branches
BranchTrueFalseTotal
if (rp && *rp && SvROK(*rp) 5 3 8
if (rp && *rp && SvROK(*rp) 5 0 5
if (rp && *rp && SvROK(*rp) 5 0 5
280 5 ▶ && SvTYPE(SvRV(*rp)) == SVt_PVHV) {
Branch: 1 branch
BranchTrueFalseTotal
&& SvTYPE(SvRV(*rp)) == SVt_PVHV) { 5 0 5
281 5 HV *row = (HV *)SvRV(*rp);
282 5 SV **idp = hv_fetchs(row, "id", 0);
283 5 SV **kp = hv_fetchs(row, "kind", 0);
284 5 SV **xp = hv_fetchs(row, "expires", 0);
285 5 int i, kind_ok = 0;
286 5 ▶ if (idp && *idp && SvOK(*idp)) {
Branch: 3 branches
BranchTrueFalseTotal
if (idp && *idp && SvOK(*idp)) { 5 0 5
if (idp && *idp && SvOK(*idp)) { 5 0 5
if (idp && *idp && SvOK(*idp)) { 5 0 5
287 SV *dargv[2], *draw, *dres;
288 5 dargv[0] = sv_2mortal(newSVpvs("id"));
289 5 dargv[1] = *idp;
290 5 draw = pcx_call_meth(aTHX_ m, "delete", dargv, 2, 1);
291 5 ▶ dres = pauth_await(aTHX_ self,
Branch: 1 branch
BranchTrueFalseTotal
dres = pauth_await(aTHX_ self, 5 0 5
292 draw ? draw : &PL_sv_undef);
293 5 ▶ if (draw) SvREFCNT_dec(draw);
Branch: 1 branch
BranchTrueFalseTotal
if (draw) SvREFCNT_dec(draw); 5 0 5
294 5 ▶ if (dres) SvREFCNT_dec(dres);
Branch: 1 branch
BranchTrueFalseTotal
if (dres) SvREFCNT_dec(dres); 5 0 5
295 }
296 5 ▶ if (kp && *kp && SvOK(*kp)) {
Branch: 3 branches
BranchTrueFalseTotal
if (kp && *kp && SvOK(*kp)) { 5 0 5
if (kp && *kp && SvOK(*kp)) { 5 0 5
if (kp && *kp && SvOK(*kp)) { 5 0 5
297 STRLEN kl2;
298 5 const char *k2 = SvPV_const(*kp, kl2);
299 11 ▶ for (i = 2; i < items && !kind_ok; i++) {
Branch: 2 branches
BranchTrueFalseTotal
for (i = 2; i < items && !kind_ok; i++) { 6 5 11
for (i = 2; i < items && !kind_ok; i++) { 6 0 6
300 STRLEN wl;
301 const char *w;
302 6 ▶ if (!SvOK(ST(i))) continue;
Branch: 1 branch
BranchTrueFalseTotal
if (!SvOK(ST(i))) continue; 0 6 6
303 6 w = SvPV_const(ST(i), wl);
304 6 ▶ if (wl == kl2 && memEQ(w, k2, kl2)) kind_ok = 1;
Branch: 2 branches
BranchTrueFalseTotal
if (wl == kl2 && memEQ(w, k2, kl2)) kind_ok = 1; 4 2 6
if (wl == kl2 && memEQ(w, k2, kl2)) kind_ok = 1; 4 0 4
305 }
306 }
307 5 ▶ if (kind_ok && xp && *xp && SvOK(*xp)
Branch: 4 branches
BranchTrueFalseTotal
if (kind_ok && xp && *xp && SvOK(*xp) 4 1 5
if (kind_ok && xp && *xp && SvOK(*xp) 4 0 4
if (kind_ok && xp && *xp && SvOK(*xp) 4 0 4
if (kind_ok && xp && *xp && SvOK(*xp) 4 0 4
308 4 ▶ && SvIV(*xp) >= (IV)time(NULL))
Branch: 1 branch
BranchTrueFalseTotal
&& SvIV(*xp) >= (IV)time(NULL)) 3 1 4
309 3 row_copy = newRV_noinc((SV *)newHVhv(row));
310 }
311 8 ▶ if (res) SvREFCNT_dec(res);
Branch: 1 branch
BranchTrueFalseTotal
if (res) SvREFCNT_dec(res); 8 0 8
312 }
313 8 SvREFCNT_dec(m);
314 8 ▶ if (!row_copy) XSRETURN_UNDEF;
Branch: 1 branch
BranchTrueFalseTotal
if (!row_copy) XSRETURN_UNDEF; 5 3 8
315 3 RETVAL = row_copy;
316 }
317 OUTPUT:
318 RETVAL
319  
320 MODULE = Punk PACKAGE = Punk::Auth
321  
322 PROTOTYPES: DISABLE
323  
324 # The await seam, exposed: Punk::Auth::_await($c, $value) unwraps a
325 # future-returning model backend's result (Punk::Future through $c->await,
326 # any other ->get-bearing object through its own get), and passes a plain
327 # value straight through - so glue code stays backend-agnostic.
328 SV *
329 _await(c, v)
330 SV *c
331 SV *v
332 CODE:
333 1 RETVAL = pauth_await(aTHX_ c, v);
334 OUTPUT:
335 RETVAL
« include/punk/punk_ratelimit.h ↑ Summary include/punk/punk_dbi.h »