Loading...
Searching...
No Matches
auth_plugin.h
Go to the documentation of this file.
/*
* This file is part of the Sofia-SIP package
*
* Copyright (C) 2005 Nokia Corporation.
*
* Contact: Pekka Pessi <pekka.pessi@nokia-email.address.hidden>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#ifndef AUTH_PLUGIN_H
#define AUTH_PLUGIN_H
#ifndef AUTH_MODULE_H
#include "sofia-sip/auth_module.h"
#endif
#ifndef AUTH_DIGEST_H
#include "sofia-sip/auth_digest.h"
#endif
#ifndef AUTH_COMMON_H
#include "sofia-sip/auth_common.h"
#endif
#ifndef MSG_DATE_H
#include <sofia-sip/msg_date.h>
#endif
#ifndef SU_MD5_H
#include <sofia-sip/su_md5.h>
#endif
#include <sofia-sip/htable.h>
SOFIA_BEGIN_DECLS
/* ====================================================================== */
/* Plugin interface for authentication */
struct auth_scheme
{
char const *asch_method;
usize_t asch_size;
int (*asch_init)(auth_mod_t *am,
auth_scheme_t *base,
su_root_t *root,
tag_type_t tag, tag_value_t value, ...);
void (*asch_check)(auth_mod_t *am,
auth_status_t *as,
msg_auth_t *auth,
auth_challenger_t const *ch);
void (*asch_challenge)(auth_mod_t *am,
auth_status_t *as,
auth_challenger_t const *ch);
void (*asch_cancel)(auth_mod_t *am,
auth_status_t *as);
void (*asch_destroy)(auth_mod_t *am);
};
typedef struct
{
unsigned apw_index;
void const *apw_type;
char const *apw_user;
char const *apw_realm;
char const *apw_pass;
char const *apw_hash;
char const *apw_ident;
auth_uplugin_t *apw_extended;
} auth_passwd_t;
HTABLE_DECLARE_WITH(auth_htable, aht, auth_passwd_t, usize_t, unsigned);
struct stat;
struct auth_mod_t
{
su_home_t am_home[1];
unsigned _am_refcount;
/* User database / cache */
char const *am_db;
struct stat *am_stat;
auth_htable_t am_users[1];
void *am_buffer;
auth_passwd_t *am_locals;
size_t am_local_count;
auth_passwd_t *am_anon_user;
/* Attributes */
url_t *am_remote;
char const *am_realm;
char const *am_opaque;
char const *am_gssapi_data;
char const *am_targetname;
auth_scheme_t *am_scheme;
char const **am_allow;
msg_param_t am_algorithm;
msg_param_t am_qop;
unsigned am_expires;
unsigned am_next_exp;
unsigned am_blacklist;
unsigned am_forbidden:1;
unsigned am_anonymous:1;
unsigned am_challenge:1;
unsigned am_nextnonce:1;
unsigned am_mutual:1;
unsigned am_fake:1;
unsigned :0;
unsigned am_count;
uint8_t am_master_key[16];
su_md5_t am_hmac_ipad;
su_md5_t am_hmac_opad;
unsigned am_max_ncount:1;
};
SOFIAPUBFUN
auth_passwd_t *auth_mod_getpass(auth_mod_t *am,
char const *user,
char const *realm);
SOFIAPUBFUN
auth_passwd_t *auth_mod_addpass(auth_mod_t *am,
char const *user,
char const *realm);
SOFIAPUBFUN int auth_readdb_if_needed(auth_mod_t *am);
SOFIAPUBFUN int auth_readdb(auth_mod_t *am);
SOFIAPUBFUN msg_auth_t *auth_mod_credentials(msg_auth_t *auth,
char const *scheme,
char const *realm);
SOFIAPUBFUN auth_mod_t *auth_mod_alloc(auth_scheme_t *scheme,
tag_type_t, tag_value_t, ...);
#define AUTH_PLUGIN(am) (auth_plugin_t *)((am) + 1)
SOFIAPUBFUN
int auth_init_default(auth_mod_t *am,
auth_scheme_t *base,
su_root_t *root,
tag_type_t tag, tag_value_t value, ...);
SOFIAPUBFUN void auth_cancel_default(auth_mod_t *am, auth_status_t *as);
SOFIAPUBFUN void auth_destroy_default(auth_mod_t *am);
SOFIAPUBFUN
void auth_method_basic(auth_mod_t *am,
auth_status_t *as,
msg_auth_t *auth,
auth_challenger_t const *ach);
SOFIAPUBFUN
void auth_challenge_basic(auth_mod_t *am,
auth_status_t *as,
auth_challenger_t const *ach);
SOFIAPUBFUN
msg_auth_t *auth_digest_credentials(msg_auth_t *auth,
char const *realm,
char const *opaque);
SOFIAPUBFUN
void auth_method_digest(auth_mod_t *am,
auth_status_t *as,
msg_auth_t *au,
auth_challenger_t const *ach);
SOFIAPUBFUN
void auth_info_digest(auth_mod_t *am,
auth_status_t *as,
auth_challenger_t const *ach);
SOFIAPUBFUN
void auth_check_digest(auth_mod_t *am,
auth_status_t *as,
auth_response_t *ar,
auth_challenger_t const *ach);
SOFIAPUBFUN
void auth_challenge_digest(auth_mod_t *am,
auth_status_t *as,
auth_challenger_t const *ach);
SOFIAPUBFUN
isize_t auth_generate_digest_nonce(auth_mod_t *am,
char buffer[],
size_t buffer_len,
int nextnonce,
msg_time_t now);
SOFIAPUBFUN
int auth_validate_digest_nonce(auth_mod_t *am,
auth_status_t *as,
auth_response_t *ar,
msg_time_t now);
SOFIAPUBFUN int auth_allow_check(auth_mod_t *am, auth_status_t *as);
SOFIAPUBFUN void auth_md5_hmac_init(auth_mod_t *am, su_md5_t *md5);
SOFIAPUBFUN void auth_md5_hmac_digest(auth_mod_t *am, su_md5_t *md5,
void *hmac, size_t size);
SOFIA_END_DECLS
#endif /* !defined AUTH_PLUGIN_H */
auth_common.h
Functions common for client/server.
auth_digest.h
Datatypes and functions for Digest authentication.
auth_module.h
Authentication verification interface.
auth_challenger_t
struct auth_challenger auth_challenger_t
Authentication challenge.
auth_uplugin_t
struct auth_uplugin_t auth_uplugin_t
Opaque authentication operation data used by plugin module.
Definition auth_module.h:73
auth_scheme_t
struct auth_scheme const auth_scheme_t
Virtual table for authentication plugin.
Definition auth_module.h:66
auth_method_digest
void auth_method_digest(auth_mod_t *am, auth_status_t *as, msg_auth_t *au, auth_challenger_t const *ach)
Authenticate a request with Digest authentication scheme.
Definition auth_module.c:634
auth_md5_hmac_init
void auth_md5_hmac_init(auth_mod_t *am, su_md5_t *md5)
Init md5 for MD5-based HMAC.
Definition auth_module.c:1488
auth_method_basic
void auth_method_basic(auth_mod_t *am, auth_status_t *as, msg_auth_t *auth, auth_challenger_t const *ach)
Basic scheme.
Definition auth_module.c:517
auth_allow_check
int auth_allow_check(auth_mod_t *am, auth_status_t *as)
Check if request method is on always-allowed list.
Definition auth_module.c:1224
auth_generate_digest_nonce
isize_t auth_generate_digest_nonce(auth_mod_t *am, char buffer[], size_t buffer_len, int nextnonce, msg_time_t now)
Generate nonce parameter.
Definition auth_module.c:1372
auth_digest_credentials
msg_auth_t * auth_digest_credentials(msg_auth_t *auth, char const *realm, char const *opaque)
Digest scheme.
Definition auth_module.c:1287
auth_challenge_basic
void auth_challenge_basic(auth_mod_t *am, auth_status_t *as, auth_challenger_t const *ach)
Construct a challenge header for Basic authentication scheme.
Definition auth_module.c:578
auth_destroy_default
void auth_destroy_default(auth_mod_t *am)
Default destroy method.
Definition auth_module.c:269
auth_mod_getpass
auth_passwd_t * auth_mod_getpass(auth_mod_t *am, char const *user, char const *realm)
Get an passwd entry for user.
Definition auth_module.c:841
auth_validate_digest_nonce
int auth_validate_digest_nonce(auth_mod_t *am, auth_status_t *as, auth_response_t *ar, msg_time_t now)
Validate nonce parameter.
Definition auth_module.c:1403
auth_readdb
int auth_readdb(auth_mod_t *am)
Read authentication database.
Definition auth_module.c:927
auth_info_digest
void auth_info_digest(auth_mod_t *am, auth_status_t *as, auth_challenger_t const *ach)
Construct a info header for Digest authentication scheme.
Definition auth_module.c:816
auth_readdb_if_needed
int auth_readdb_if_needed(auth_mod_t *am)
Read authentication database only when needed.
Definition auth_module.c:933
auth_mod_addpass
auth_passwd_t * auth_mod_addpass(auth_mod_t *am, char const *user, char const *realm)
Add a password entry.
Definition auth_module.c:869
auth_check_digest
void auth_check_digest(auth_mod_t *am, auth_status_t *as, auth_response_t *ar, auth_challenger_t const *ach)
Verify digest authentication.
Definition auth_module.c:667
auth_challenge_digest
void auth_challenge_digest(auth_mod_t *am, auth_status_t *as, auth_challenger_t const *ach)
Construct a challenge header for Digest authentication scheme.
Definition auth_module.c:773
auth_init_default
int auth_init_default(auth_mod_t *am, auth_scheme_t *base, su_root_t *root, tag_type_t tag, tag_value_t value,...)
Initialize an authentication module instance.
Definition auth_module.c:125
auth_cancel_default
void auth_cancel_default(auth_mod_t *am, auth_status_t *as)
Default cancel method.
Definition auth_module.c:475
auth_mod_credentials
msg_auth_t * auth_mod_credentials(msg_auth_t *auth, char const *scheme, char const *realm)
Find a credential header with matching scheme and realm.
Definition auth_module.c:1246
auth_mod_alloc
auth_mod_t * auth_mod_alloc(auth_scheme_t *scheme, tag_type_t, tag_value_t,...)
Allocate an authentication module instance.
Definition auth_module.c:92
htable.h
msg_date.h
msg_time_t
unsigned long msg_time_t
auth_mod_t
Common data for authentication module.
Definition auth_plugin.h:125
auth_mod_t::am_hmac_opad
su_md5_t am_hmac_opad
MD5 with outer pad.
Definition auth_plugin.h:166
auth_mod_t::am_hmac_ipad
su_md5_t am_hmac_ipad
MD5 with inner pad.
Definition auth_plugin.h:165
auth_mod_t::am_max_ncount
unsigned am_max_ncount
If nonzero, challenge with new nonce after ncount.
Definition auth_plugin.h:168
auth_mod_t::am_mutual
unsigned am_mutual
Mutual authentication.
Definition auth_plugin.h:157
auth_mod_t::am_challenge
unsigned am_challenge
Challenge even if successful.
Definition auth_plugin.h:155
auth_mod_t::am_anonymous
unsigned am_anonymous
Allow anonymous access.
Definition auth_plugin.h:154
auth_mod_t::am_fake
unsigned am_fake
Fake authentication.
Definition auth_plugin.h:158
auth_mod_t::am_forbidden
unsigned am_forbidden
Respond with 403 if bad credentials.
Definition auth_plugin.h:153
auth_mod_t::am_nextnonce
unsigned am_nextnonce
Send next nonce in responses.
Definition auth_plugin.h:156
auth_mod_t::am_users
auth_htable_t am_users[1]
Table of users.
Definition auth_plugin.h:132
auth_mod_t::am_algorithm
msg_param_t am_algorithm
Defauilt algorithm.
Definition auth_plugin.h:148
auth_mod_t::am_db
char const * am_db
User database file name.
Definition auth_plugin.h:130
auth_mod_t::am_targetname
char const * am_targetname
NTLM target name.
Definition auth_plugin.h:145
auth_mod_t::am_master_key
uint8_t am_master_key[16]
Private master key.
Definition auth_plugin.h:163
auth_mod_t::am_anon_user
auth_passwd_t * am_anon_user
Special entry for anonymous user.
Definition auth_plugin.h:138
auth_mod_t::_am_refcount
unsigned _am_refcount
Not used.
Definition auth_plugin.h:127
auth_mod_t::am_next_exp
unsigned am_next_exp
Next nonce lifetime.
Definition auth_plugin.h:151
auth_mod_t::am_opaque
char const * am_opaque
Opaque identification data.
Definition auth_plugin.h:143
auth_mod_t::am_stat
struct stat * am_stat
State of user file when read.
Definition auth_plugin.h:131
auth_mod_t::am_remote
url_t * am_remote
Remote authenticator.
Definition auth_plugin.h:141
auth_mod_t::am_buffer
void * am_buffer
Buffer for database.
Definition auth_plugin.h:134
auth_mod_t::am_allow
char const ** am_allow
Methods to allow without authentication.
Definition auth_plugin.h:147
auth_mod_t::am_locals
auth_passwd_t * am_locals
Entries from local user file.
Definition auth_plugin.h:135
auth_mod_t::am_scheme
auth_scheme_t * am_scheme
Authentication scheme (Digest, Basic).
Definition auth_plugin.h:146
auth_mod_t::am_realm
char const * am_realm
Our realm.
Definition auth_plugin.h:142
auth_mod_t::am_local_count
size_t am_local_count
Number of entries from local user file.
Definition auth_plugin.h:136
auth_mod_t::am_expires
unsigned am_expires
Nonce lifetime.
Definition auth_plugin.h:150
auth_mod_t::am_blacklist
unsigned am_blacklist
Extra delay if bad credentials.
Definition auth_plugin.h:152
auth_mod_t::am_count
unsigned am_count
Nonce counter.
Definition auth_plugin.h:161
auth_mod_t::am_gssapi_data
char const * am_gssapi_data
NTLM data.
Definition auth_plugin.h:144
auth_mod_t::am_qop
msg_param_t am_qop
Default qop (quality-of-protection).
Definition auth_plugin.h:149
auth_passwd_t
User data structure.
Definition auth_plugin.h:106
auth_passwd_t::apw_type
void const * apw_type
Magic identifier.
Definition auth_plugin.h:108
auth_passwd_t::apw_realm
char const * apw_realm
Realm.
Definition auth_plugin.h:111
auth_passwd_t::apw_index
unsigned apw_index
Key to hash table.
Definition auth_plugin.h:107
auth_passwd_t::apw_extended
auth_uplugin_t * apw_extended
Method-specific extension.
Definition auth_plugin.h:115
auth_passwd_t::apw_hash
char const * apw_hash
MD5 of the username, realm and pass.
Definition auth_plugin.h:113
auth_passwd_t::apw_ident
char const * apw_ident
Identity information.
Definition auth_plugin.h:114
auth_passwd_t::apw_user
char const * apw_user
Username.
Definition auth_plugin.h:110
auth_passwd_t::apw_pass
char const * apw_pass
Password.
Definition auth_plugin.h:112
auth_response_t
Digest parameters for digest-response in Authorize.
Definition auth_digest.h:117
auth_scheme
Authentication scheme.
Definition auth_plugin.h:66
auth_scheme::asch_destroy
void(* asch_destroy)(auth_mod_t *am)
Reclaim resources an authentication module.
Definition auth_plugin.h:100
auth_scheme::asch_challenge
void(* asch_challenge)(auth_mod_t *am, auth_status_t *as, auth_challenger_t const *ch)
Create a challenge.
Definition auth_plugin.h:86
auth_scheme::asch_cancel
void(* asch_cancel)(auth_mod_t *am, auth_status_t *as)
Cancel an asynchronous authentication request.
Definition auth_plugin.h:93
auth_scheme::asch_method
char const * asch_method
Name.
Definition auth_plugin.h:68
auth_scheme::asch_init
int(* asch_init)(auth_mod_t *am, auth_scheme_t *base, su_root_t *root, tag_type_t tag, tag_value_t value,...)
Initialize module.
Definition auth_plugin.h:74
auth_scheme::asch_check
void(* asch_check)(auth_mod_t *am, auth_status_t *as, msg_auth_t *auth, auth_challenger_t const *ch)
Check authentication.
Definition auth_plugin.h:80
auth_scheme::asch_size
usize_t asch_size
Size of module object.
Definition auth_plugin.h:71
auth_status_t
Authentication operation result.
Definition auth_module.h:97
su_md5_t
url_t
su_home_t
SU_HOME_T su_home_t
SOFIAPUBFUN
#define SOFIAPUBFUN
su_md5.h
tag_value_t
intptr_t tag_value_t
tag_type_t
struct tag_type_s const * tag_type_t
uint8_t
SU_U8_T uint8_t
su_root_t
struct su_root_t su_root_t

Sofia-SIP 1.12.11devel - Copyright (C) 2006 Nokia Corporation. All rights reserved. Licensed under the terms of the GNU Lesser General Public License.