metal/mtce-common/src/common/tokenUtil.h
Alex Kozyrev 506ef3fd7f MTCE: reading BMC passwords from Barbican secret storage.
Use Openstack Barbican API to retrieve BMC passwords stored by SysInv.
See SysInv commit for details on how to write password to Barbican.
MTCE is going to find corresponding secret by host uuid and retrieve
secret payload associated with it. mtcSecretApi_get is used to find
secret reference, based on a hostname. mtcSecretApi_read is used to
read a password using the reference found on a prevoius step.
Also, did a little cleanup and removed old unused token handling code.

Depends-On: I7102a9662f3757c062ab310737f4ba08379d0100
Change-Id: I66011dc95bb69ff536bd5888c08e3987bd666082
Story: 2003108
Task: 27700
Signed-off-by: Alex Kozyrev <alex.kozyrev@windriver.com>
2019-02-14 09:04:46 -05:00

64 lines
2.2 KiB
C++

#ifndef __INCLUDE_TOKENUTIL_H__
#define __INCLUDE_TOKENUTIL_H__
/*
* Copyright (c) 2013, 2017 Wind River Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*
*/
/*
* This module contains a single static __token__ object,
* an interface that updates/refreshes it with a valid token
* an interface that queries keystone service list uuids
* an interface tht queries the specified service admin
* endpoint using its service uuid.
*
*
* tokenUtil_get_svc_uuid - returns the service uuid for the
* specified service.
* tokenUtil_get_endpoint - returns the admin endpoint for the
* specified service uuid.
*/
#include <iostream>
#include <string>
using namespace std;
#include "logMacros.h"
#include "httpUtil.h" /* for ... libEvent */
#define MTC_POST_KEY_LABEL "/v3/auth/tokens"
/* The invalidation window is 5 minutes according
* to the testing of token expiration time */
#define STALE_TOKEN_DURATION 300 //5 minutes
/* returns the static token object for this module */
keyToken_type * tokenUtil_get_ptr ( void );
keyToken_type tokenUtil_get_token ( void );
int tokenUtil_handler ( libEvent & event );
int tokenUtil_new_token ( libEvent & event, string hostname, bool blocking=true );
void tokenUtil_get_first ( libEvent & event, string & hostname );
int tokenUtil_token_refresh( libEvent & event, string hostname );
int tokenUtil_get_endpoints( libEvent & event, string service_uuid );
string tokenUtil_get_svc_uuid ( libEvent & event, string service_name );
void tokenUtil_fail_token ( void );
void tokenUtil_log_refresh ( void );
int keystone_config_handler ( void * user,
const char * section,
const char * name,
const char * value);
void tokenUtil_manage_token ( libEvent & event,
string & hostname,
int & refresh_rate,
struct mtc_timer & token_refresh_timer,
void (*handler)(int, siginfo_t*, void*));
#endif /* __INCLUDE_TOKENUTIL_H__ */