|
Packit |
3adb1e |
/* ====================================================================
|
|
Packit |
3adb1e |
* Licensed to the Apache Software Foundation (ASF) under one
|
|
Packit |
3adb1e |
* or more contributor license agreements. See the NOTICE file
|
|
Packit |
3adb1e |
* distributed with this work for additional information
|
|
Packit |
3adb1e |
* regarding copyright ownership. The ASF licenses this file
|
|
Packit |
3adb1e |
* to you under the Apache License, Version 2.0 (the
|
|
Packit |
3adb1e |
* "License"); you may not use this file except in compliance
|
|
Packit |
3adb1e |
* with the License. You may obtain a copy of the License at
|
|
Packit |
3adb1e |
*
|
|
Packit |
3adb1e |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
Packit |
3adb1e |
*
|
|
Packit |
3adb1e |
* Unless required by applicable law or agreed to in writing,
|
|
Packit |
3adb1e |
* software distributed under the License is distributed on an
|
|
Packit |
3adb1e |
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
Packit |
3adb1e |
* KIND, either express or implied. See the License for the
|
|
Packit |
3adb1e |
* specific language governing permissions and limitations
|
|
Packit |
3adb1e |
* under the License.
|
|
Packit |
3adb1e |
* ====================================================================
|
|
Packit |
3adb1e |
*/
|
|
Packit |
3adb1e |
|
|
Packit |
3adb1e |
#ifndef AUTH_SPNEGO_H
|
|
Packit |
3adb1e |
#define AUTH_SPNEGO_H
|
|
Packit |
3adb1e |
|
|
Packit |
3adb1e |
#include <apr.h>
|
|
Packit |
3adb1e |
#include <apr_pools.h>
|
|
Packit |
3adb1e |
#include "serf.h"
|
|
Packit |
3adb1e |
#include "serf_private.h"
|
|
Packit |
3adb1e |
|
|
Packit |
3adb1e |
#if defined(SERF_HAVE_SSPI)
|
|
Packit |
3adb1e |
#define SERF_HAVE_SPNEGO
|
|
Packit |
3adb1e |
#define SERF_USE_SSPI
|
|
Packit |
3adb1e |
#elif defined(SERF_HAVE_GSSAPI)
|
|
Packit |
3adb1e |
#define SERF_HAVE_SPNEGO
|
|
Packit |
3adb1e |
#define SERF_USE_GSSAPI
|
|
Packit |
3adb1e |
#endif
|
|
Packit |
3adb1e |
|
|
Packit |
3adb1e |
#ifdef SERF_HAVE_SPNEGO
|
|
Packit |
3adb1e |
|
|
Packit |
3adb1e |
#ifdef __cplusplus
|
|
Packit |
3adb1e |
extern "C" {
|
|
Packit |
3adb1e |
#endif
|
|
Packit |
3adb1e |
|
|
Packit |
3adb1e |
typedef struct serf__spnego_context_t serf__spnego_context_t;
|
|
Packit |
3adb1e |
|
|
Packit |
3adb1e |
typedef struct serf__spnego_buffer_t {
|
|
Packit |
3adb1e |
apr_size_t length;
|
|
Packit |
3adb1e |
void *value;
|
|
Packit |
3adb1e |
} serf__spnego_buffer_t;
|
|
Packit |
3adb1e |
|
|
Packit |
3adb1e |
/* Create outbound security context.
|
|
Packit |
3adb1e |
*
|
|
Packit |
3adb1e |
* All temporary allocations will be performed in SCRATCH_POOL, while security
|
|
Packit |
3adb1e |
* context will be allocated in result_pool and will be destroyed automatically
|
|
Packit |
3adb1e |
* on RESULT_POOL cleanup.
|
|
Packit |
3adb1e |
*
|
|
Packit |
3adb1e |
*/
|
|
Packit |
3adb1e |
apr_status_t
|
|
Packit |
3adb1e |
serf__spnego_create_sec_context(serf__spnego_context_t **ctx_p,
|
|
Packit |
3adb1e |
const serf__authn_scheme_t *scheme,
|
|
Packit |
3adb1e |
apr_pool_t *result_pool,
|
|
Packit |
3adb1e |
apr_pool_t *scratch_pool);
|
|
Packit |
3adb1e |
|
|
Packit |
3adb1e |
/* Initialize outbound security context.
|
|
Packit |
3adb1e |
*
|
|
Packit |
3adb1e |
* The function is used to build a security context between the client
|
|
Packit |
3adb1e |
* application and a remote peer.
|
|
Packit |
3adb1e |
*
|
|
Packit |
3adb1e |
* CTX is pointer to existing context created using
|
|
Packit |
3adb1e |
* serf__spnego_create_sec_context() function.
|
|
Packit |
3adb1e |
*
|
|
Packit |
3adb1e |
* SERVICE is name of Kerberos service name. Usually 'HTTP'. HOSTNAME is
|
|
Packit |
3adb1e |
* canonical name of destination server. Caller should resolve server's alias
|
|
Packit |
3adb1e |
* to canonical name.
|
|
Packit |
3adb1e |
*
|
|
Packit |
3adb1e |
* INPUT_BUF is pointer structure describing input token if any. Should be
|
|
Packit |
3adb1e |
* zero length on first call.
|
|
Packit |
3adb1e |
*
|
|
Packit |
3adb1e |
* OUTPUT_BUF will be populated with pointer to output data that should send
|
|
Packit |
3adb1e |
* to destination server. This buffer will be automatically freed on
|
|
Packit |
3adb1e |
* RESULT_POOL cleanup.
|
|
Packit |
3adb1e |
*
|
|
Packit |
3adb1e |
* All temporary allocations will be performed in SCRATCH_POOL.
|
|
Packit |
3adb1e |
*
|
|
Packit |
3adb1e |
* Return value:
|
|
Packit |
3adb1e |
* - APR_EAGAIN The client must send the output token to the server and wait
|
|
Packit |
3adb1e |
* for a return token.
|
|
Packit |
3adb1e |
*
|
|
Packit |
3adb1e |
* - APR_SUCCESS The security context was successfully initialized. There is no
|
|
Packit |
3adb1e |
* need for another serf__spnego_init_sec_context call. If the function returns
|
|
Packit |
3adb1e |
* an output token, that is, if the OUTPUT_BUF is of nonzero length, that
|
|
Packit |
3adb1e |
* token must be sent to the server.
|
|
Packit |
3adb1e |
*
|
|
Packit |
3adb1e |
* Other returns values indicates error.
|
|
Packit |
3adb1e |
*/
|
|
Packit |
3adb1e |
apr_status_t
|
|
Packit |
3adb1e |
serf__spnego_init_sec_context(serf_connection_t *conn,
|
|
Packit |
3adb1e |
serf__spnego_context_t *ctx,
|
|
Packit |
3adb1e |
const char *service,
|
|
Packit |
3adb1e |
const char *hostname,
|
|
Packit |
3adb1e |
serf__spnego_buffer_t *input_buf,
|
|
Packit |
3adb1e |
serf__spnego_buffer_t *output_buf,
|
|
Packit |
3adb1e |
apr_pool_t *result_pool,
|
|
Packit |
3adb1e |
apr_pool_t *scratch_pool
|
|
Packit |
3adb1e |
);
|
|
Packit |
3adb1e |
|
|
Packit |
3adb1e |
/*
|
|
Packit |
3adb1e |
* Reset a previously created security context so we can start with a new one.
|
|
Packit |
3adb1e |
*
|
|
Packit |
3adb1e |
* This is triggered when the server requires per-request authentication,
|
|
Packit |
3adb1e |
* where each request requires a new security context.
|
|
Packit |
3adb1e |
*/
|
|
Packit |
3adb1e |
apr_status_t
|
|
Packit |
3adb1e |
serf__spnego_reset_sec_context(serf__spnego_context_t *ctx);
|
|
Packit |
3adb1e |
|
|
Packit |
3adb1e |
#ifdef __cplusplus
|
|
Packit |
3adb1e |
}
|
|
Packit |
3adb1e |
#endif
|
|
Packit |
3adb1e |
|
|
Packit |
3adb1e |
#endif /* SERF_HAVE_SPNEGO */
|
|
Packit |
3adb1e |
|
|
Packit |
3adb1e |
#endif /* !AUTH_SPNEGO_H */
|