1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-06-27 20:47:11 +02:00
Files
bin
cmake
module
Base
Core
Entity
Library
Misc
Vendor
AES256
ASIO
B64
CPR
CURL
CMake
include
lib
vauth
cleartext.c
cram.c
digest.c
digest.h
digest_sspi.c
krb5_gssapi.c
krb5_sspi.c
ntlm.c
ntlm.h
ntlm_sspi.c
oauth2.c
spnego_gssapi.c
spnego_sspi.c
vauth.c
vauth.h
vquic
vssh
vtls
CMakeLists.txt
Makefile.am
Makefile.inc
Makefile.m32
Makefile.netware
Makefile.vxworks
altsvc.c
altsvc.h
amigaos.c
amigaos.h
arpa_telnet.h
asyn-ares.c
asyn-thread.c
asyn.h
base64.c
c-hyper.c
c-hyper.h
checksrc.pl
config-amigaos.h
config-dos.h
config-mac.h
config-os400.h
config-plan9.h
config-riscos.h
config-tpf.h
config-vxworks.h
config-win32.h
config-win32ce.h
conncache.c
conncache.h
connect.c
connect.h
content_encoding.c
content_encoding.h
cookie.c
cookie.h
curl_addrinfo.c
curl_addrinfo.h
curl_base64.h
curl_config.h.cmake
curl_ctype.c
curl_ctype.h
curl_des.c
curl_des.h
curl_endian.c
curl_endian.h
curl_fnmatch.c
curl_fnmatch.h
curl_get_line.c
curl_get_line.h
curl_gethostname.c
curl_gethostname.h
curl_gssapi.c
curl_gssapi.h
curl_hmac.h
curl_krb5.h
curl_ldap.h
curl_md4.h
curl_md5.h
curl_memory.h
curl_memrchr.c
curl_memrchr.h
curl_multibyte.c
curl_multibyte.h
curl_ntlm_core.c
curl_ntlm_core.h
curl_ntlm_wb.c
curl_ntlm_wb.h
curl_path.c
curl_path.h
curl_printf.h
curl_range.c
curl_range.h
curl_rtmp.c
curl_rtmp.h
curl_sasl.c
curl_sasl.h
curl_setup.h
curl_setup_once.h
curl_sha256.h
curl_sspi.c
curl_sspi.h
curl_threads.c
curl_threads.h
curlx.h
dict.c
dict.h
doh.c
doh.h
dotdot.c
dotdot.h
dynbuf.c
dynbuf.h
easy.c
easygetopt.c
easyif.h
easyoptions.c
easyoptions.h
escape.c
escape.h
file.c
file.h
fileinfo.c
fileinfo.h
firefox-db2pem.sh
formdata.c
formdata.h
ftp.c
ftp.h
ftplistparser.c
ftplistparser.h
getenv.c
getinfo.c
getinfo.h
gopher.c
gopher.h
hash.c
hash.h
hmac.c
hostasyn.c
hostcheck.c
hostcheck.h
hostip.c
hostip.h
hostip4.c
hostip6.c
hostsyn.c
hsts.c
hsts.h
http.c
http.h
http2.c
http2.h
http_aws_sigv4.c
http_aws_sigv4.h
http_chunks.c
http_chunks.h
http_digest.c
http_digest.h
http_negotiate.c
http_negotiate.h
http_ntlm.c
http_ntlm.h
http_proxy.c
http_proxy.h
idn_win32.c
if2ip.c
if2ip.h
imap.c
imap.h
inet_ntop.c
inet_ntop.h
inet_pton.c
inet_pton.h
krb5.c
ldap.c
libcurl.plist
libcurl.rc
libcurl.vers.in
llist.c
llist.h
makefile.amiga
makefile.dj
md4.c
md5.c
memdebug.c
memdebug.h
mime.c
mime.h
mk-ca-bundle.pl
mk-ca-bundle.vbs
mprintf.c
mqtt.c
mqtt.h
multi.c
multihandle.h
multiif.h
netrc.c
netrc.h
non-ascii.c
non-ascii.h
nonblock.c
nonblock.h
nwlib.c
nwos.c
openldap.c
optiontable.pl
parsedate.c
parsedate.h
pingpong.c
pingpong.h
pop3.c
pop3.h
progress.c
progress.h
psl.c
psl.h
quic.h
rand.c
rand.h
rename.c
rename.h
rtsp.c
rtsp.h
select.c
select.h
sendf.c
sendf.h
setopt.c
setopt.h
setup-os400.h
setup-vms.h
setup-win32.h
sha256.c
share.c
share.h
sigpipe.h
slist.c
slist.h
smb.c
smb.h
smtp.c
smtp.h
sockaddr.h
socketpair.c
socketpair.h
socks.c
socks.h
socks_gssapi.c
socks_sspi.c
speedcheck.c
speedcheck.h
splay.c
splay.h
strcase.c
strcase.h
strdup.c
strdup.h
strerror.c
strerror.h
strtok.c
strtok.h
strtoofft.c
strtoofft.h
system_win32.c
system_win32.h
telnet.c
telnet.h
tftp.c
tftp.h
timeval.c
timeval.h
transfer.c
transfer.h
url.c
url.h
urlapi-int.h
urlapi.c
urldata.h
version.c
version_win32.c
version_win32.h
warnless.c
warnless.h
wildcard.c
wildcard.h
x509asn1.c
x509asn1.h
m4
packages
plan9
scripts
src
winbuild
CHANGES
CMakeLists.txt
COPYING
GIT-INFO
MacOSX-Framework
Makefile.am
Makefile.dist
README
README.md
RELEASE-NOTES
SECURITY.md
acinclude.m4
appveyor.yml
buildconf
buildconf.bat
configure.ac
curl-config.in
libcurl.pc.in
maketgz
CivetWeb
ConcurrentQueue
Fmt
Hash
MDBC
MaxmindDB
PUGIXML
SQLite
SimpleIni
SimpleSocket
SleepyDiscord
TinyDir
WebSocketPP
Whirlpool
ZLib
CMakeLists.txt
CMakeLists.txt
Core.cpp
Core.hpp
Logger.cpp
Logger.hpp
Main.cpp
Register.cpp
SqBase.hpp
sdk
.gitignore
.gitmodules
CMakeLists.txt
LICENSE
README.md
SqMod/module/Vendor/CURL/lib/vauth/oauth2.c
2021-01-27 07:27:48 +02:00

127 lines
4.1 KiB
C

/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
* RFC6749 OAuth 2.0 Authorization Framework
*
***************************************************************************/
#include "curl_setup.h"
#if !defined(CURL_DISABLE_IMAP) || !defined(CURL_DISABLE_SMTP) || \
!defined(CURL_DISABLE_POP3)
#include <curl/curl.h>
#include "urldata.h"
#include "vauth/vauth.h"
#include "curl_base64.h"
#include "warnless.h"
#include "curl_printf.h"
/* The last #include files should be: */
#include "curl_memory.h"
#include "memdebug.h"
/*
* Curl_auth_create_oauth_bearer_message()
*
* This is used to generate an already encoded OAuth 2.0 message ready for
* sending to the recipient.
*
* Parameters:
*
* data[in] - The session handle.
* user[in] - The user name.
* host[in] - The host name.
* port[in] - The port(when not Port 80).
* bearer[in] - The bearer token.
* outptr[in / out] - The address where a pointer to newly allocated memory
* holding the result will be stored upon completion.
* outlen[out] - The length of the output message.
*
* Returns CURLE_OK on success.
*/
CURLcode Curl_auth_create_oauth_bearer_message(struct Curl_easy *data,
const char *user,
const char *host,
const long port,
const char *bearer,
char **outptr, size_t *outlen)
{
CURLcode result = CURLE_OK;
char *oauth = NULL;
/* Generate the message */
if(port == 0 || port == 80)
oauth = aprintf("n,a=%s,\1host=%s\1auth=Bearer %s\1\1", user, host,
bearer);
else
oauth = aprintf("n,a=%s,\1host=%s\1port=%ld\1auth=Bearer %s\1\1", user,
host, port, bearer);
if(!oauth)
return CURLE_OUT_OF_MEMORY;
/* Base64 encode the reply */
result = Curl_base64_encode(data, oauth, strlen(oauth), outptr, outlen);
free(oauth);
return result;
}
/*
* Curl_auth_create_xoauth_bearer_message()
*
* This is used to generate an already encoded XOAuth 2.0 message ready for
* sending to the recipient.
*
* Parameters:
*
* data[in] - The session handle.
* user[in] - The user name.
* bearer[in] - The bearer token.
* outptr[in / out] - The address where a pointer to newly allocated memory
* holding the result will be stored upon completion.
* outlen[out] - The length of the output message.
*
* Returns CURLE_OK on success.
*/
CURLcode Curl_auth_create_xoauth_bearer_message(struct Curl_easy *data,
const char *user,
const char *bearer,
char **outptr, size_t *outlen)
{
CURLcode result = CURLE_OK;
/* Generate the message */
char *xoauth = aprintf("user=%s\1auth=Bearer %s\1\1", user, bearer);
if(!xoauth)
return CURLE_OUT_OF_MEMORY;
/* Base64 encode the reply */
result = Curl_base64_encode(data, xoauth, strlen(xoauth), outptr, outlen);
free(xoauth);
return result;
}
#endif /* disabled, no users */