master
1#ifndef HEADER_CURL_SASL_H
2#define HEADER_CURL_SASL_H
3/***************************************************************************
4 * _ _ ____ _
5 * Project ___| | | | _ \| |
6 * / __| | | | |_) | |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
9 *
10 * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
11 *
12 * This software is licensed as described in the file COPYING, which
13 * you should have received as part of this distribution. The terms
14 * are also available at https://curl.se/docs/copyright.html.
15 *
16 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 * copies of the Software, and permit persons to whom the Software is
18 * furnished to do so, under the terms of the COPYING file.
19 *
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
22 *
23 * SPDX-License-Identifier: curl
24 *
25 ***************************************************************************/
26#include "bufref.h"
28struct Curl_easy;
29struct connectdata;
31/* Authentication mechanism flags */
32#define SASL_MECH_LOGIN (1 << 0)
33#define SASL_MECH_PLAIN (1 << 1)
34#define SASL_MECH_CRAM_MD5 (1 << 2)
35#define SASL_MECH_DIGEST_MD5 (1 << 3)
36#define SASL_MECH_GSSAPI (1 << 4)
37#define SASL_MECH_EXTERNAL (1 << 5)
38#define SASL_MECH_NTLM (1 << 6)
39#define SASL_MECH_XOAUTH2 (1 << 7)
40#define SASL_MECH_OAUTHBEARER (1 << 8)
41#define SASL_MECH_SCRAM_SHA_1 (1 << 9)
42#define SASL_MECH_SCRAM_SHA_256 (1 << 10)
44/* Authentication mechanism values */
45#define SASL_AUTH_NONE 0
46#define SASL_AUTH_ANY 0xffff
47#define SASL_AUTH_DEFAULT (SASL_AUTH_ANY & ~SASL_MECH_EXTERNAL)
49/* Authentication mechanism strings */
50#define SASL_MECH_STRING_LOGIN "LOGIN"
51#define SASL_MECH_STRING_PLAIN "PLAIN"
52#define SASL_MECH_STRING_CRAM_MD5 "CRAM-MD5"
53#define SASL_MECH_STRING_DIGEST_MD5 "DIGEST-MD5"
54#define SASL_MECH_STRING_GSSAPI "GSSAPI"
55#define SASL_MECH_STRING_EXTERNAL "EXTERNAL"
56#define SASL_MECH_STRING_XOAUTH2 "XOAUTH2"
57#define SASL_MECH_STRING_OAUTHBEARER "OAUTHBEARER"
58#define SASL_MECH_STRING_SCRAM_SHA_1 "SCRAM-SHA-1"
59#define SASL_MECH_STRING_SCRAM_SHA_256 "SCRAM-SHA-256"
61/* SASL flags */
62#define SASL_FLAG_BASE64 0x0001 /* Messages are base64-encoded */
64/* SASL machine states */
65typedef enum {
66 SASL_STOP,
67 SASL_PLAIN,
68 SASL_LOGIN,
69 SASL_LOGIN_PASSWD,
70 SASL_EXTERNAL,
71 SASL_CRAMMD5,
72 SASL_DIGESTMD5,
73 SASL_DIGESTMD5_RESP,
74 SASL_GSSAPI,
75 SASL_GSSAPI_TOKEN,
76 SASL_GSSAPI_NO_DATA,
77 SASL_OAUTH2,
78 SASL_OAUTH2_RESP,
79 SASL_GSASL,
80 SASL_CANCEL,
81 SASL_FINAL
82} saslstate;
84/* Progress indicator */
85typedef enum {
86 SASL_IDLE,
87 SASL_INPROGRESS,
88 SASL_DONE
89} saslprogress;
91/* Protocol dependent SASL parameters */
92struct SASLproto {
93 const char *service; /* The service name */
94 CURLcode (*sendauth)(struct Curl_easy *data, const char *mech,
95 const struct bufref *ir);
96 /* Send authentication command */
97 CURLcode (*contauth)(struct Curl_easy *data, const char *mech,
98 const struct bufref *contauth);
99 /* Send authentication continuation */
100 CURLcode (*cancelauth)(struct Curl_easy *data, const char *mech);
101 /* Cancel authentication. */
102 CURLcode (*getmessage)(struct Curl_easy *data, struct bufref *out);
103 /* Get SASL response message */
104 size_t maxirlen; /* Maximum initial response + mechanism length,
105 or zero if no max. This is normally the max
106 command length - other characters count.
107 This has to be zero for non-base64 protocols. */
108 int contcode; /* Code to receive when continuation is expected */
109 int finalcode; /* Code to receive upon authentication success */
110 unsigned short defmechs; /* Mechanisms enabled by default */
111 unsigned short flags; /* Configuration flags. */
112};
114/* Per-connection parameters */
115struct SASL {
116 const struct SASLproto *params; /* Protocol dependent parameters */
117 saslstate state; /* Current machine state */
118 const char *curmech; /* Current mechanism id. */
119 unsigned short authmechs; /* Accepted authentication mechanisms */
120 unsigned short prefmech; /* Preferred authentication mechanism */
121 unsigned short authused; /* Auth mechanism used for the connection */
122 BIT(resetprefs); /* For URL auth option parsing. */
123 BIT(mutual_auth); /* Mutual authentication enabled (GSSAPI only) */
124 BIT(force_ir); /* Protocol always supports initial response */
125};
127/* This is used to test whether the line starts with the given mechanism */
128#define sasl_mech_equal(line, wordlen, mech) \
129 ((wordlen) == (sizeof(mech) - 1) / sizeof(char) && \
130 !memcmp(line, mech, wordlen))
132/* Convert a mechanism name to a token */
133unsigned short Curl_sasl_decode_mech(const char *ptr,
134 size_t maxlen, size_t *len);
136/* Parse the URL login options */
137CURLcode Curl_sasl_parse_url_auth_option(struct SASL *sasl,
138 const char *value, size_t len);
140/* Initializes an SASL structure */
141void Curl_sasl_init(struct SASL *sasl, struct Curl_easy *data,
142 const struct SASLproto *params);
144/* Check if we have enough auth data and capabilities to authenticate */
145bool Curl_sasl_can_authenticate(struct SASL *sasl, struct Curl_easy *data);
147/* Calculate the required login details for SASL authentication */
148CURLcode Curl_sasl_start(struct SASL *sasl, struct Curl_easy *data,
149 bool force_ir, saslprogress *progress);
151/* Continue an SASL authentication */
152CURLcode Curl_sasl_continue(struct SASL *sasl, struct Curl_easy *data,
153 int code, saslprogress *progress);
155CURLcode Curl_sasl_is_blocked(struct SASL *sasl, struct Curl_easy *data);
157#endif /* HEADER_CURL_SASL_H */
Diagnostics4 git calls · 24 ms
CallStatusSizeTime024 ms
discover200152 B2 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=2 git.response.bytes=152 git.server.agent=gitty/1.0 git.server.object_format=sha1 git.server.caps=agent ls-refs fetch object-format git.server.fetch=shallow filter sideband-all git.protocol.version=2 git.pkt.frames=8 git.pkt.data=6 git.pkt.flush=2 git.pkt.delim=0 git.pkt.bytes=152 git.pkt.payload.max=34
ls-refs200149 B · hit2 ms
git.upload-pack ls-refs http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=2 git.response.bytes=149 git.response.cache=HIT git.response.duration_ms=2 git.protocol.version=2 git.pkt.frames=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=149 git.pkt.payload.max=78 git.ls_refs.count=2 git.ls_refs.head=refs/heads/master
fetchblob:none · deepen 10200287 KiB · hit2 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=20 git.response.bytes=293470 git.response.cache=HIT git.response.duration_ms=2 git.fetch.filter=blob:none git.fetch.filter.requested=tree:0 git.fetch.filter.fallback=blob:none git.fetch.filter.learned=false git.fetch.wants=31c911efe5652725e930f4d2e60c9060e5f6646d git.fetch.haves.count=0 git.fetch.deepen=10 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=10 git.pkt.data=8 git.pkt.flush=1 git.pkt.delim=1 git.pkt.bytes=293470 git.pkt.payload.max=65516 git.sideband.band1.bytes=293354 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=87 git.pack.bytes=293354 git.pack.ofs_delta=0 git.pack.ref_delta=1 git.pack.chain.max=1 git.pack.trailer=6a646bcda6740bab42e321b51998b52ea15146c0 git.pack.full=86Open pack map
fetch2002.1 KiB · hit20 ms
git.upload-pack fetch http.response.status_code=200 git.response.bytes=2186 git.response.cache=HIT git.response.duration_ms=20 git.fetch.wants=cbd2834c59a987c74011c48a7585f8a8a633c79c git.fetch.haves.count=0 git.fetch.deepen=0 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=2186 git.pkt.payload.max=2165 git.sideband.band1.bytes=2164 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0
Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.
- Remote
- https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/curl.git
- Ref
- refs/heads/master
- Commit
- 31c911efe5652725e930f4d2e60c9060e5f6646d
- cf-ray
- a5e335342aa7f485
- Request
- 81573b00…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format