From cf508035ebaabd15df7d200d3648f839d3ae8d46 Mon Sep 17 00:00:00 2001 From: zachmann Date: Tue, 12 Sep 2017 11:53:07 +0200 Subject: [PATCH 1/2] changes naming scheme of clientconfig file #27 closed --- src/ipc.c | 2 +- src/oidc-gen.c | 29 ++++++++++++++++++----------- src/oidc_utilities.c | 15 +++++++++++++++ src/oidc_utilities.h | 2 ++ src/version.h | 2 +- 5 files changed, 37 insertions(+), 13 deletions(-) diff --git a/src/ipc.c b/src/ipc.c index 50aeefd4..4d638ae9 100644 --- a/src/ipc.c +++ b/src/ipc.c @@ -286,7 +286,7 @@ oidc_error_t ipc_write(int _sock, char* fmt, ...) { vsprintf(msg, fmt, original); syslog(LOG_AUTHPRIV|LOG_DEBUG, "ipc writing to socket %d\n",_sock); syslog(LOG_AUTHPRIV|LOG_DEBUG, "ipc write %s\n",msg); - if(write(_sock, msg, strlen(msg)+1) < 0) { + if(write(_sock, msg, strlen(msg)) < 0) { syslog(LOG_AUTHPRIV|LOG_ALERT, "writing on stream socket: %m"); clearFreeString(msg); oidc_errno = OIDC_EWRITE; diff --git a/src/oidc-gen.c b/src/oidc-gen.c index d2a86a43..36d2c540 100644 --- a/src/oidc-gen.c +++ b/src/oidc-gen.c @@ -525,25 +525,32 @@ void registerClient(int sock, char* short_name, struct arguments arguments) { printf("Writing client config to file '%s'\n", arguments.output); encryptAndWriteConfig(client_config, NULL, arguments.output, NULL); } else { - char* name = getJSONValue(client_config, "client_name"); - name = realloc(name, strlen(name)+strlen(".clientconfig")+1); - strcat(name, ".clientconfig"); - if(oidcFileDoesExist(name)) { + char* path_fmt = "%s_%s_%s.clientconfig"; + char* iss = provider_getIssuer(*provider)+8; + char* today = getDateString(); + char* client_id = getJSONValue(client_config, "client_id"); + char* path = calloc(sizeof(char), snprintf(NULL, 0, path_fmt, iss, today, client_id)+1); + sprintf(path, path_fmt, iss, today, client_id); + clearFreeString(client_id); + clearFreeString(today); + + + if(oidcFileDoesExist(path)) { syslog(LOG_AUTHPRIV|LOG_DEBUG, "The clientconfig file already exists. Changing path."); int i = 0; char* newName = NULL; do { clearFreeString(newName); - newName = calloc(sizeof(char), snprintf(NULL, 0, "%s%d", name, i)); - sprintf(newName, "%s%d", name, i); + newName = calloc(sizeof(char), snprintf(NULL, 0, "%s%d", path, i)); + sprintf(newName, "%s%d", path, i); i++; } while(oidcFileDoesExist(newName)); - clearFreeString(name); - name = newName; + clearFreeString(path); + path = newName; } - printf("Writing client config to file '%s%s'\n", getOidcDir(), name); - encryptAndWriteConfig(client_config, NULL, NULL, name); - clearFreeString(name); + printf("Writing client config to file '%s%s'\n", getOidcDir(), path); + encryptAndWriteConfig(client_config, NULL, NULL, path); + clearFreeString(path); } } diff --git a/src/oidc_utilities.c b/src/oidc_utilities.c index 99cda33d..1fbc2711 100644 --- a/src/oidc_utilities.c +++ b/src/oidc_utilities.c @@ -1,5 +1,6 @@ #include #include +#include #include "oidc_utilities.h" @@ -47,3 +48,17 @@ void clearFreeString(char* s) { } clearFree(s, strlen(s)); } + +/** @fn char* getDateString() + * @brief returns the current date in YYYY-mm-dd format + * @returns a pointer to the formated date. Has to be freed after usage + */ +char* getDateString() { + char* s = calloc(sizeof(char), 10+1); + time_t now = time(NULL); + struct tm *t = localtime(&now); + + + strftime(s, 10+1, "%F", t); + return s; +} diff --git a/src/oidc_utilities.h b/src/oidc_utilities.h index b3b10b99..e5401449 100644 --- a/src/oidc_utilities.h +++ b/src/oidc_utilities.h @@ -8,4 +8,6 @@ int isValid(const char* c) ; void clearFree(void* p, size_t len); void clearFreeString(char* s); +char* getDateString() ; + #endif //OIDC_UTILITIES_H diff --git a/src/version.h b/src/version.h index 241d5cee..b6a2abcf 100644 --- a/src/version.h +++ b/src/version.h @@ -1,7 +1,7 @@ #ifndef OIDC_VERSION_H #define OIDC_VERSION_H -#define VERSION "1.0.7" +#define VERSION "1.0.8" #define BUG_ADDRESS "" #define AGENT_VERSION "oidc-agent " VERSION #define GEN_VERSION "oidc-gen " VERSION From 59bd4ca7adc56dacd599ba728ae489d720a1d2d2 Mon Sep 17 00:00:00 2001 From: zachmann Date: Tue, 12 Sep 2017 12:32:53 +0200 Subject: [PATCH 2/2] renames provider configs to account configs, including api --- README.MD | 38 +++++++++++++++++++------------------- src/api.c | 28 ++++++++++++++-------------- src/api.h | 4 ++-- src/ipc.h | 2 +- src/oidc-add.c | 10 +++++----- src/oidc-agent.c | 16 ++++++++-------- src/oidc-gen.c | 31 +++++++++++++++++-------------- src/oidc-token.c | 24 ++++++++++++------------ src/version.h | 2 +- 9 files changed, 79 insertions(+), 76 deletions(-) diff --git a/README.MD b/README.MD index 805e29b0..0dbe379c 100644 --- a/README.MD +++ b/README.MD @@ -10,8 +10,8 @@ an X-session or a login session, and all other windows or programs are started a clients to the oidc-agent program. Through use of environment variables the agent can be located and automatically used to handle oidc tokens. -The agent initially does not have any providers loaded. You can load a -provider configuration by using oidc-add. Multiple provider configurations may +The agent initially does not have any configurations loaded. You can load a +account configuration by using oidc-add. Multiple accounts configurations may be loaded in oidc-agent concurrently. oidc-add is also used to remove a loaded configuration from oidc-agent. @@ -47,15 +47,15 @@ eval `oidc-agent` ``` ### oidc-gen -You can use oidc-gen to generate a new oidc provider config. +You can use oidc-gen to generate a new oidc account config. Most likely you do not have already a client registered and don't want to do it through a web interface. If the provider supports dynamic registration (iam does), you can let the agent register a new client for you. This is the default option. You can run ```oidc-gen``` to start this flow. Using iam password grant type is not supported using dynamic registration. The client is registered and you have to contact the provider to update the client config manually. After that is done, you can specify the saved client config file to oidc-gen using ```oidc-gen -f ``` -and finish the provider configuration. Afterwards the config is added to oidc-agent -and can be used by oidc-add normally to add and remove the provider from the agent. +and finish the account configuration. Afterwards the config is added to oidc-agent +and can be used by oidc-add normally to add and remove the account configuration from the agent. If you have already a registered client (e.g. because the provider does not support dynamic registration) you can run ```oidc-gen -m``` for manual configuration. oidc-gen will prompt you for the relevant @@ -71,7 +71,7 @@ configuration oidc-add is your friend. ### oidc-add oidc-add will add an existing configuration to the oidc-agent, making it useable. You -have to provide the short name of the provider configuration via command line +have to provide the short name of the account configuration via command line argument. ``` oidc-add @@ -81,30 +81,30 @@ oidc-add clients can use the provided api to communicate with oidc-agent. An example client is oidc-token. -The api provides functions for getting a list of currently loaded providers and access token. They can be easily used. Alternative a client can directly communicate with the oidc-agent through UNIX domain sockets. The socket address can be get from the environment variable which is set by the agent. The request has to be sent json encoded. We use a UNIX domain socket of type ```SOCK_SEQPACKET```. +The api provides functions for getting a list of currently loaded account configs and access token. They can be easily used. Alternative a client can directly communicate with the oidc-agent through UNIX domain sockets. The socket address can be get from the environment variable which is set by the agent. The request has to be sent json encoded. We use a UNIX domain socket of type ```SOCK_SEQPACKET```. The following fields and values have to be present for the different calls: -#### List of Providers: +#### List of Accounts: ##### Request | field | value | |---------|---------------| -| request | provider_list | +| request | account_list | example: ``` -{"request":"provider_list"} +{"request":"account_list"} ``` ##### Response | field | value | |---------------|-----------------------| | status | success | -| provider_list | JSON Array of strings | +| account_list | JSON Array of strings | example: ``` -{"status":"success", "provider_list":["iam", "test"]} +{"status":"success", "account_list":["iam", "test"]} ``` ##### Error Response @@ -123,12 +123,12 @@ example: | field | value | |------------------|------------------------| | request | access_token | -| provider | | +| account | | | min_valid_period | [s] | example: ``` -{"request":"access_token", "provider":"iam", "min_valid_period":60} +{"request":"access_token", "account":"iam", "min_valid_period":60} ``` ##### Response @@ -150,20 +150,20 @@ example: example: ``` -{"status":"failure", "error":"Provider not loaded"} +{"status":"failure", "error":"Account not loaded"} ``` #### oidc-token oidc-token is n example client using the provided C-api and can be used to easily get an oidc access token from the command line. -oidc-token can list the currently loaded providers and get an access token. +oidc-token can list the currently loaded accounts and get an access token. -For displaying a list of loaded providers run +For displaying a list of loaded accounts run ``` oidc-token -l ``` -To get an access token for one provider you have to specify the short name and +To get an access token for one account config you have to specify the short name and how long the access token should be valid at least. The time is given in seconds. If no minimum period of validity is specified, the default value 0 will be used. This means that the access token might not be valid anymore even when @@ -172,7 +172,7 @@ access token is issued and returned. We guarantee that the token will be valid the specific time, if it is below the server's maximum, otherwise it will be the provider's maximum. -The following call will get an access token for the provider with the short name +The following call will get an access token for the account with the short name 'iam'. The access token will be valid at least for 60 seconds. ``` oidc-token iam -t 60 diff --git a/src/api.c b/src/api.c index 8f9fe522..6b155cf1 100644 --- a/src/api.c +++ b/src/api.c @@ -9,13 +9,13 @@ #include "oidc_error.h" -char* getProviderRequest() { - char* fmt = "{\"request\":\"provider_list\"}"; +char* getAccountRequest() { + char* fmt = "{\"request\":\"account_list\"}"; return fmt; } char* getAccessTokenRequest(const char* providername, unsigned long min_valid_period) { - char* fmt = "{\"request\":\"access_token\", \"provider\":\"%s\", \"min_valid_period\":%lu}"; + char* fmt = "{\"request\":\"access_token\", \"account\":\"%s\", \"min_valid_period\":%lu}"; char* request = calloc(sizeof(char), snprintf(NULL, 0, fmt, providername, min_valid_period)+1); sprintf(request, fmt, providername, min_valid_period); return request; @@ -39,17 +39,17 @@ char* communicate(char* json_request) { return response; } -/** @fn char* getAccessToken(const char* providername, unsigned long min_valid_period) - * @brief gets an valid access token for a provider - * @param providername the short name of the provider for whom an access token +/** @fn char* getAccessToken(const char* accountname, unsigned long min_valid_period) + * @brief gets an valid access token for a account config + * @param accountname the short name of the account config for which an access token * should be returned * @param min_valid_period the minium period of time the access token has to be valid * in seconds * @return a pointer to the access token. Has to be freed after usage. On * failure NULL is returned and oidc_errno is set. */ -char* getAccessToken(const char* providername, unsigned long min_valid_period) { - char* request = getAccessTokenRequest(providername, min_valid_period); +char* getAccessToken(const char* accountname, unsigned long min_valid_period) { + char* request = getAccessTokenRequest(accountname, min_valid_period); char* response = communicate(request); if(response==NULL) { return NULL; @@ -79,14 +79,14 @@ char* getAccessToken(const char* providername, unsigned long min_valid_period) { } } -/** @fn char* getLoadedProvider() - * @brief gets a a list of currently loaded providers +/** @fn char* getLoadedAccount() + * @brief gets a a list of currently loaded accounts * @return a pointer to the JSON Array String containing all the short names - * of the currently loaded providers. Has to be freed after usage. + * of the currently loaded accounts. Has to be freed after usage. * On failure NULL is returned and oidc_errno is set. */ -char* getLoadedProvider() { - char* request = getProviderRequest(); +char* getLoadedAccounts() { + char* request = getAccountRequest(); char* response = communicate(request); if(response==NULL) { return NULL; @@ -94,7 +94,7 @@ char* getLoadedProvider() { struct key_value pairs[3]; pairs[0].key = "status"; pairs[1].key = "error"; - pairs[2].key = "provider_list"; + pairs[2].key = "account_list"; if(getJSONValues(response, pairs, sizeof(pairs)/sizeof(*pairs))<0) { fprintf(stderr, "Read malformed data. Please hand in bug report.\n"); clearFreeString(response); diff --git a/src/api.h b/src/api.h index b9a3861d..6dc599d9 100644 --- a/src/api.h +++ b/src/api.h @@ -5,7 +5,7 @@ #define OIDC_SOCK_ENV_NAME "OIDC_SOCK" -char* getAccessToken(const char* providername, unsigned long min_valid_period) ; -char* getLoadedProvider() ; +char* getAccessToken(const char* accountname, unsigned long min_valid_period) ; +char* getLoadedAccounts() ; extern char* oidc_perror(); #endif // OIDC_API_H diff --git a/src/ipc.h b/src/ipc.h index bbe384d6..d4ba6952 100644 --- a/src/ipc.h +++ b/src/ipc.h @@ -16,7 +16,7 @@ #define RESPONSE_ERROR_ENDPOINT "{\"status\":\"failure\", \"error\":\"%s\", \"token_endpoint\":\"%s\", \"authorization_endpoint\":\"%s\", \"registration_endpoint\":\"%s\", \"revocation_endpoint\":\"%s\"}" #define RESPONSE_STATUS_ENDPOINT_REFRESH "{\"status\":\"%s\", \"token_endpoint\":\"%s\", \"authorization_endpoint\":\"%s\", \"registration_endpoint\":\"%s\", \"revocation_endpoint\":\"%s\", \"refresh_token\":\"%s\"}" #define RESPONSE_STATUS_ACCESS "{\"status\":\"%s\", \"access_token\":\"%s\"}" -#define RESPONSE_STATUS_PROVIDER "{\"status\":\"%s\", \"provider_list\":%s}" +#define RESPONSE_STATUS_ACCOUNT "{\"status\":\"%s\", \"account_list\":%s}" #define RESPONSE_STATUS_REGISTER "{\"status\":\"%s\", \"response\":%s}" #define RESPONSE_ERROR "{\"status\":\"failure\", \"error\":\"%s\"}" diff --git a/src/oidc-add.c b/src/oidc-add.c index 1e506bcc..5729efac 100644 --- a/src/oidc-add.c +++ b/src/oidc-add.c @@ -31,7 +31,7 @@ struct arguments { Order of fields: {NAME, KEY, ARG, FLAGS, DOC}. */ static struct argp_option options[] = { - {"remove", 'r', 0, 0, "the provider is removed, not added", 0}, + {"remove", 'r', 0, 0, "the account config is removed, not added", 0}, {"debug", 'g', 0, 0, "sets the log level to DEBUG", 0}, {"verbose", 'v', 0, 0, "enables verbose mode. The send data will be printed.", 0}, {0} @@ -77,13 +77,13 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state) { A description of the non-option command-line arguments that we accept. */ -static char args_doc[] = "PROVIDER_SHORTNAME"; +static char args_doc[] = "ACCOUNT_SHORTNAME"; /* DOC. Field 4 in ARGP. Program documentation. */ -static char doc[] = "oidc-add -- A client for adding and removing providers to the oidc-agent"; +static char doc[] = "oidc-add -- A client for adding and removing accounts to the oidc-agent"; /* The ARGP structure itself. @@ -114,12 +114,12 @@ int main(int argc, char** argv) { char* provider = arguments.args[0]; if(!providerConfigExists(provider)) { - printf("No provider configured with that short name\n"); + printf("No account configured with that short name\n"); exit(EXIT_FAILURE); } struct oidc_provider* p = NULL; while(NULL==p) { - char* password = promptPassword("Enter encrpytion password for provider %s: ", provider); + char* password = promptPassword("Enter encrpytion password for account config %s: ", provider); p = decryptProvider(provider, password); clearFreeString(password); } diff --git a/src/oidc-agent.c b/src/oidc-agent.c index 71baf2ff..d592b5e2 100644 --- a/src/oidc-agent.c +++ b/src/oidc-agent.c @@ -168,7 +168,7 @@ void handleAdd(int sock, struct oidc_provider** loaded_p, size_t* loaded_p_count } if(NULL!=findProvider(*loaded_p, *loaded_p_count, *provider)) { freeProvider(provider); - ipc_write(sock, RESPONSE_ERROR, "provider already loaded"); + ipc_write(sock, RESPONSE_ERROR, "account already loaded"); return; } if(retrieveAccessTokenRefreshFlowOnly(provider, FORCE_NEW_TOKEN)!=OIDC_SUCCESS) { @@ -205,7 +205,7 @@ void handleRm(int sock, struct oidc_provider** loaded_p, size_t* loaded_p_count, } if(NULL==findProvider(*loaded_p, *loaded_p_count, *provider)) { freeProvider(provider); - ipc_write(sock, RESPONSE_ERROR, revoke ? "Could not revoke token: provider not loaded" : "provider not loaded"); + ipc_write(sock, RESPONSE_ERROR, revoke ? "Could not revoke token: account not loaded" : "account not loaded"); return; } if(revoke && revokeToken(provider)!=OIDC_SUCCESS) { @@ -221,14 +221,14 @@ void handleRm(int sock, struct oidc_provider** loaded_p, size_t* loaded_p_count, void handleToken(int sock, struct oidc_provider* loaded_p, size_t loaded_p_count, char* short_name, char* min_valid_period_str) { syslog(LOG_AUTHPRIV|LOG_DEBUG, "Handle Token request"); if(short_name==NULL || min_valid_period_str== NULL) { - ipc_write(sock, RESPONSE_ERROR, "Bad request. Need provider name and min_valid_period for getting access token."); + ipc_write(sock, RESPONSE_ERROR, "Bad request. Need account name and min_valid_period for getting access token."); return; } struct oidc_provider key = {0, short_name, 0}; time_t min_valid_period = atoi(min_valid_period_str); struct oidc_provider* provider = findProvider(loaded_p, loaded_p_count, key); if(provider==NULL) { - ipc_write(sock, RESPONSE_ERROR, "Provider not loaded."); + ipc_write(sock, RESPONSE_ERROR, "Account not loaded."); return; } if(retrieveAccessTokenRefreshFlowOnly(provider, min_valid_period)!=0) { @@ -241,7 +241,7 @@ void handleToken(int sock, struct oidc_provider* loaded_p, size_t loaded_p_count void handleList(int sock, struct oidc_provider* loaded_p, size_t loaded_p_count) { syslog(LOG_AUTHPRIV|LOG_DEBUG, "Handle list request"); char* providerList = getProviderNameList(loaded_p, loaded_p_count); - ipc_write(sock, RESPONSE_STATUS_PROVIDER, "success", oidc_errno==OIDC_EARGNULL ? "[]" : providerList); + ipc_write(sock, RESPONSE_STATUS_ACCOUNT, "success", oidc_errno==OIDC_EARGNULL ? "[]" : providerList); clearFreeString(providerList); } @@ -254,7 +254,7 @@ void handleRegister(int sock, struct oidc_provider* loaded_p, size_t loaded_p_co } if(NULL!=findProvider(loaded_p, loaded_p_count, *provider)) { freeProvider(provider); - ipc_write(sock, RESPONSE_ERROR, "A provider with this shortname is already loaded. I will not register a new one."); + ipc_write(sock, RESPONSE_ERROR, "A account with this shortname is already loaded. I will not register a new one."); return; } if(getEndpoints(provider)!=OIDC_SUCCESS) { @@ -369,7 +369,7 @@ int main(int argc, char** argv) { if(NULL!=q) { struct key_value pairs[4]; pairs[0].key = "request"; pairs[0].value = NULL; - pairs[1].key = "provider"; pairs[1].value = NULL; + pairs[1].key = "account"; pairs[1].value = NULL; pairs[2].key = "min_valid_period"; pairs[2].value = NULL; pairs[3].key = "config"; pairs[3].value = NULL; if(getJSONValues(q, pairs, sizeof(pairs)/sizeof(*pairs))<0) { @@ -386,7 +386,7 @@ int main(int argc, char** argv) { handleRm(*(con->msgsock), loaded_p_addr, &loaded_p_count, pairs[3].value, 1); } else if(strcmp(pairs[0].value, "access_token")==0) { handleToken(*(con->msgsock), *loaded_p_addr, loaded_p_count, pairs[1].value, pairs[2].value); - } else if(strcmp(pairs[0].value, "provider_list")==0) { + } else if(strcmp(pairs[0].value, "account_list")==0) { handleList(*(con->msgsock), *loaded_p_addr, loaded_p_count); } else if(strcmp(pairs[0].value, "register")==0) { handleRegister(*(con->msgsock), *loaded_p_addr, loaded_p_count, pairs[3].value); diff --git a/src/oidc-gen.c b/src/oidc-gen.c index 36d2c540..a739723a 100644 --- a/src/oidc-gen.c +++ b/src/oidc-gen.c @@ -57,7 +57,7 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state) { static char args_doc[] = "[SHORT_NAME] | SHORT_NAME -d"; -static char doc[] = "oidc-gen -- A tool for generating oidc provider configuration which can be used by oidc-add"; +static char doc[] = "oidc-gen -- A tool for generating oidc account configurations which can be used by oidc-add"; static struct argp argp = {options, parse_opt, args_doc, doc}; @@ -184,7 +184,7 @@ int main(int argc, char** argv) { } printf("%s\n", pairs[0].value); if(strcmp(pairs[0].value, "success")==0) { - printf("The generated provider was successfully added to oidc-agent. You don't have to run oidc-add.\n"); + printf("The generated account config was successfully added to oidc-agent. You don't have to run oidc-add.\n"); } clearFreeString(pairs[0].value); @@ -366,16 +366,16 @@ struct oidc_provider* genNewProvider(const char* short_name) { provider = loaded_p; goto prompting; } else { - printf("No provider exists with this short name. Creating new configuration ...\n"); + printf("No account exists with this short name. Creating new configuration ...\n"); goto prompting; } } - provider_setName(provider, prompt("Enter short name for the provider to configure: ")); + provider_setName(provider, prompt("Enter short name for the account to configure: ")); if(!isValid(provider_getName(*provider))) { continue; } if(oidcFileDoesExist(provider_getName(*provider))) { - if(getUserConfirmation("A provider with this short name is already configured. Do you want to edit the configuration?")) { + if(getUserConfirmation("A account with this short name is already configured. Do you want to edit the configuration?")) { struct oidc_provider* loaded_p = NULL; while(NULL==loaded_p) { encryptionPassword = promptPassword("Enter encryption Password: "); @@ -471,13 +471,13 @@ void registerClient(int sock, char* short_name, struct arguments arguments) { provider_setName(provider, name); } while(!isValid(provider_getName(*provider))) { - provider_setName(provider, prompt("Enter short name for the provider to configure: ")); + provider_setName(provider, prompt("Enter short name for the account to configure: ")); if(!isValid(provider_getName(*provider))) { continue; } } if(oidcFileDoesExist(provider_getName(*provider))) { - fprintf(stderr, "A provider with that shortname already configured\n"); + fprintf(stderr, "A account with that shortname already configured\n"); exit(EXIT_FAILURE); } @@ -526,7 +526,10 @@ void registerClient(int sock, char* short_name, struct arguments arguments) { encryptAndWriteConfig(client_config, NULL, arguments.output, NULL); } else { char* path_fmt = "%s_%s_%s.clientconfig"; - char* iss = provider_getIssuer(*provider)+8; + char* iss = calloc(sizeof(char), strlen(provider_getIssuer(*provider)+8)+1); + strcpy(iss, provider_getIssuer(*provider)+8); + char* iss_new_end = strchr(iss, '/'); + *iss_new_end = 0; char* today = getDateString(); char* client_id = getJSONValue(client_config, "client_id"); char* path = calloc(sizeof(char), snprintf(NULL, 0, path_fmt, iss, today, client_id)+1); @@ -562,7 +565,7 @@ void registerClient(int sock, char* short_name, struct arguments arguments) { void handleDelete(char* short_name) { if(!oidcFileDoesExist(short_name)) { - fprintf(stderr, "No provider with that shortname configured\n"); + fprintf(stderr, "No account with that shortname configured\n"); exit(EXIT_FAILURE); } struct oidc_provider* loaded_p = NULL; @@ -605,11 +608,11 @@ void deleteClient(char* short_name, char* provider_json, int revoke) { exit(EXIT_FAILURE); } clearFreeString(res); - if(strcmp(pairs[0].value, "success")==0 || strcmp(pairs[1].value, "provider not loaded")==0) { - printf("The generated provider was successfully removed from oidc-agent. You don't have to run oidc-add.\n"); + if(strcmp(pairs[0].value, "success")==0 || strcmp(pairs[1].value, "account not loaded")==0) { + printf("The generated account was successfully removed from oidc-agent. You don't have to run oidc-add.\n"); clearFreeString(pairs[0].value); if(removeOidcFile(short_name)==0) { - printf("Successfully deleted provider configuration.\n"); + printf("Successfully deleted account configuration.\n"); } else { printf("error removing configuration file: %s", oidc_perror()); } @@ -622,10 +625,10 @@ void deleteClient(char* short_name, char* provider_json, int revoke) { if(getUserConfirmation("Do you want to unload and delete anyway. You then have to revoke the refresh token manually.")) { deleteClient(short_name, provider_json, 0); } else { - printf("The provider was not removed from oidc-agent due to the above listed error. You can fix the error and try it again.\n"); + printf("The account was not removed from oidc-agent due to the above listed error. You can fix the error and try it again.\n"); } } else { - printf("The provider was not removed from oidc-agent due to the above listed error. You can fix the error and try it again.\n"); + printf("The account was not removed from oidc-agent due to the above listed error. You can fix the error and try it again.\n"); } clearFreeString(pairs[1].value); clearFreeString(pairs[0].value); exit(EXIT_FAILURE); diff --git a/src/oidc-token.c b/src/oidc-token.c index 6227c7b2..9b7b2f50 100644 --- a/src/oidc-token.c +++ b/src/oidc-token.c @@ -18,8 +18,8 @@ const char *argp_program_bug_address = BUG_ADDRESS; /* This structure is used by main to communicate with parse_opt. */ struct arguments { - char* args[1]; /* provider */ - int list_provider; + char* args[1]; /* account shortname */ + int list_accounts; unsigned long min_valid_period; /* Arguments for -t */ }; @@ -28,7 +28,7 @@ struct arguments { Order of fields: {NAME, KEY, ARG, FLAGS, DOC}. */ static struct argp_option options[] = { - {"listprovider", 'l', 0, 0, "Lists the currently loaded providers", 0}, + {"listaccounts", 'l', 0, 0, "Lists the currently loaded accounts", 0}, {"time", 't', "min_valid_period", 0, "period of how long the access token should be at least valid in seconds", 0}, {0} }; @@ -43,7 +43,7 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state) { switch (key) { case 'l': - arguments->list_provider = 1; + arguments->list_accounts = 1; break; case 't': if(!isdigit(*arg)) { @@ -58,7 +58,7 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state) { arguments->args[state->arg_num] = arg; break; case ARGP_KEY_END: - if(arguments->list_provider) { + if(arguments->list_accounts) { break; } if (state->arg_num < 1) { @@ -76,7 +76,7 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state) { A description of the non-option command-line arguments that we accept. */ -static char args_doc[] = "PROVIDER_SHORTNAME | -l"; +static char args_doc[] = "ACCOUNT_SHORTNAME | -l"; /* DOC. Field 4 in ARGP. @@ -96,19 +96,19 @@ int main (int argc, char **argv) { /* Set argument defaults */ arguments.min_valid_period = 0; - arguments.list_provider = 0; + arguments.list_accounts = 0; arguments.args[0]=NULL; /* parse arguments */ argp_parse (&argp, argc, argv, 0, 0, &arguments); - if(arguments.list_provider) { - char* providerList = getLoadedProvider(); // for a list of loaded providers, simply call the api - if(providerList==NULL) { + if(arguments.list_accounts) { + char* accountList = getLoadedAccounts(); // for a list of loaded accounts, simply call the api + if(accountList==NULL) { fprintf(stderr, "Error: %s\n", oidc_perror()); } else { - printf("The following providers are configured: %s\n", providerList); - clearFreeString(providerList); + printf("The following accounts are loaded: %s\n", accountList); + clearFreeString(accountList); } } if(arguments.args[0]) { diff --git a/src/version.h b/src/version.h index b6a2abcf..31bb510f 100644 --- a/src/version.h +++ b/src/version.h @@ -1,7 +1,7 @@ #ifndef OIDC_VERSION_H #define OIDC_VERSION_H -#define VERSION "1.0.8" +#define VERSION "1.1.0" #define BUG_ADDRESS "" #define AGENT_VERSION "oidc-agent " VERSION #define GEN_VERSION "oidc-gen " VERSION