Go to the source code of this file.
Macros | |
#define | JWT_ALG "alg" |
#define | JWT_TYP "typ" |
#define | JWT_TYP_VALUE "jwt" |
#define | JWT_ALG_VALUE_HMAC "HS512" |
#define | JWT_ALG_VALUE_RSA "RS256" |
#define | SERVER_ADDRESS "http://localhost:7776" |
Enumerations | |
enum | OIDC_VerificationOptions { OIDC_VERIFICATION_DEFAULT = 0 , OIDC_VERIFICATION_NO_CODE_VERIFIER = 1 } |
Functions | |
char * | OIDC_generate_id_token_rsa (const char *rp_uri, const struct GNUNET_CRYPTO_PublicKey *sub_key, const struct GNUNET_RECLAIM_AttributeList *attrs, const struct GNUNET_RECLAIM_PresentationList *presentations, const struct GNUNET_TIME_Relative *expiration_time, const char *nonce, const json_t *secret_rsa_key) |
Create a JWT using RSA256 algorithm from attributes. More... | |
char * | OIDC_generate_id_token_hmac (const char *rp_uri, const struct GNUNET_CRYPTO_PublicKey *sub_key, const struct GNUNET_RECLAIM_AttributeList *attrs, const struct GNUNET_RECLAIM_PresentationList *presentations, const struct GNUNET_TIME_Relative *expiration_time, const char *nonce, const char *secret_key) |
Create a JWT using HMAC (HS256) from attributes. More... | |
char * | OIDC_build_authz_code (const struct GNUNET_CRYPTO_PrivateKey *issuer, const struct GNUNET_RECLAIM_Ticket *ticket, const struct GNUNET_RECLAIM_AttributeList *attrs, const struct GNUNET_RECLAIM_PresentationList *presentations, const char *nonce, const char *code_challenge) |
Builds an OIDC authorization code including a reclaim ticket and nonce. More... | |
int | OIDC_parse_authz_code (const char *rp_uri, const struct GNUNET_CRYPTO_PublicKey *cid, const char *code, const char *code_verifier, struct GNUNET_RECLAIM_Ticket *ticket, struct GNUNET_RECLAIM_AttributeList **attrs, struct GNUNET_RECLAIM_PresentationList **presentations, char **nonce, enum OIDC_VerificationOptions opts, char **emsg) |
Parse reclaim ticket and nonce from authorization code. More... | |
void | OIDC_build_token_response (const char *access_token, const char *id_token, const struct GNUNET_TIME_Relative *expiration_time, char **token_response) |
Build a token response for a token request TODO: Maybe we should add the scope here? More... | |
char * | OIDC_access_token_new (const struct GNUNET_RECLAIM_Ticket *ticket, const char *rp_uri) |
Generate a new access token. More... | |
int | OIDC_access_token_parse (const char *token, struct GNUNET_RECLAIM_Ticket **ticket, char **rp_uri) |
Parse an access token. More... | |
enum GNUNET_GenericReturnValue | OIDC_check_scopes_for_claim_request (const char *scopes, const char *attr) |
Checks if a claim is implicitly requested through standard scope(s) More... | |
char * | OIDC_generate_userinfo (const struct GNUNET_CRYPTO_PublicKey *sub_key, const struct GNUNET_RECLAIM_AttributeList *attrs, const struct GNUNET_RECLAIM_PresentationList *presentations) |
Generate userinfo JSON as string. More... | |
#define JWT_ALG "alg" |
Definition at line 32 of file oidc_helper.h.
#define JWT_TYP "typ" |
Definition at line 33 of file oidc_helper.h.
#define JWT_TYP_VALUE "jwt" |
Definition at line 34 of file oidc_helper.h.
#define JWT_ALG_VALUE_HMAC "HS512" |
Definition at line 36 of file oidc_helper.h.
#define JWT_ALG_VALUE_RSA "RS256" |
Definition at line 37 of file oidc_helper.h.
#define SERVER_ADDRESS "http://localhost:7776" |
Definition at line 39 of file oidc_helper.h.
Enumerator | |
---|---|
OIDC_VERIFICATION_DEFAULT | Strict verification. |
OIDC_VERIFICATION_NO_CODE_VERIFIER | Do not check code verifier even if expected. |
Definition at line 41 of file oidc_helper.h.
char * OIDC_generate_id_token_rsa | ( | const char * | rp_uri, |
const struct GNUNET_CRYPTO_PublicKey * | sub_key, | ||
const struct GNUNET_RECLAIM_AttributeList * | attrs, | ||
const struct GNUNET_RECLAIM_PresentationList * | presentations, | ||
const struct GNUNET_TIME_Relative * | expiration_time, | ||
const char * | nonce, | ||
const json_t * | secret_rsa_key | ||
) |
Create a JWT using RSA256 algorithm from attributes.
rp_uri | the RP URI |
sub_key | the public key of the subject |
attrs | the attribute list |
presentations | credential presentation list (may be empty) |
expiration_time | the validity of the token |
secret_rsa_key | the key used to sign the JWT |
Definition at line 423 of file oidc_helper.c.
References generate_id_token_body(), GNUNET_asprintf(), GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, and result.
Referenced by token_endpoint().
char * OIDC_generate_id_token_hmac | ( | const char * | rp_uri, |
const struct GNUNET_CRYPTO_PublicKey * | sub_key, | ||
const struct GNUNET_RECLAIM_AttributeList * | attrs, | ||
const struct GNUNET_RECLAIM_PresentationList * | presentations, | ||
const struct GNUNET_TIME_Relative * | expiration_time, | ||
const char * | nonce, | ||
const char * | secret_key | ||
) |
Create a JWT using HMAC (HS256) from attributes.
rp_uri | the RP URI |
sub_key | the public key of the subject |
attrs | the attribute list |
presentations | credential presentation list (may be empty) |
expiration_time | the validity of the token |
secret_key | the key used to sign the JWT |
Creating the JWT signature. This might not be standards compliant, check.
Definition at line 475 of file oidc_helper.c.
References create_jwt_hmac_header(), fix_base64(), generate_id_token_body(), GNUNET_asprintf(), GNUNET_CRYPTO_hmac_raw(), GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_STRINGS_base64url_encode(), and result.
Referenced by token_endpoint().
char * OIDC_build_authz_code | ( | const struct GNUNET_CRYPTO_PrivateKey * | issuer, |
const struct GNUNET_RECLAIM_Ticket * | ticket, | ||
const struct GNUNET_RECLAIM_AttributeList * | attrs, | ||
const struct GNUNET_RECLAIM_PresentationList * | presentations, | ||
const char * | nonce_str, | ||
const char * | code_challenge | ||
) |
Builds an OIDC authorization code including a reclaim ticket and nonce.
issuer | the issuer |
ticket | the ticket to include in the code |
attrs | list of attributes to share |
presentations | credential presentation list |
nonce | the nonce to include in the code |
code_challenge | PKCE code challenge |
opts | verification options |
issuer | the issuer of the ticket, used to sign the ticket and nonce |
ticket | the ticket to include in the code |
attrs | list of attributes which are shared |
presentations | credential presentation list (may be empty) |
nonce | the nonce to include in the code |
code_challenge | PKCE code challenge |
PLAINTEXT
END
Definition at line 567 of file oidc_helper.c.
References OIDC_Parameters::attr_list_len, OIDC_Parameters::code_challenge_len, GNUNET_RECLAIM_Ticket::gns_name, GNUNET_assert, GNUNET_break, GNUNET_CRYPTO_sign_(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_malloc, GNUNET_RECLAIM_attribute_list_serialize(), GNUNET_RECLAIM_attribute_list_serialize_get_size(), GNUNET_RECLAIM_presentation_list_serialize(), GNUNET_RECLAIM_presentation_list_serialize_get_size(), GNUNET_SIGNATURE_PURPOSE_RECLAIM_CODE_SIGN, GNUNET_STRINGS_base64url_encode(), GNUNET_SYSERR, OIDC_Parameters::nonce_len, payload, OIDC_Parameters::pres_list_len, GNUNET_CRYPTO_EccSignaturePurpose::purpose, ticket, and OIDC_Parameters::ticket.
Referenced by oidc_ticket_issue_cb().
int OIDC_parse_authz_code | ( | const char * | rp_uri, |
const struct GNUNET_CRYPTO_PublicKey * | cid, | ||
const char * | code, | ||
const char * | code_verifier, | ||
struct GNUNET_RECLAIM_Ticket * | ticket, | ||
struct GNUNET_RECLAIM_AttributeList ** | attrs, | ||
struct GNUNET_RECLAIM_PresentationList ** | presentations, | ||
char ** | nonce_str, | ||
enum OIDC_VerificationOptions | opts, | ||
char ** | emsg | ||
) |
Parse reclaim ticket and nonce from authorization code.
This also verifies the signature in the code.
rp_uri | the RP URI |
code | the string representation of the code |
code_verfier | PKCE code verifier |
ticket | where to store the ticket |
attrs | the attributes found in the code |
presentations | credential presentation list |
nonce | where to store the nonce |
This also verifies the signature in the code.
audience | the expected audience of the code |
code | the string representation of the code |
code_verfier | PKCE code verifier. Optional, must be provided if used in request. |
ticket | where to store the ticket |
attrs | the attributes in the code |
presentations | credential presentation list |
nonce_str | where to store the nonce (if contained) |
Definition at line 754 of file oidc_helper.c.
References OIDC_Parameters::attr_list_len, check_code_challenge(), OIDC_Parameters::code_challenge_len, GNUNET_RECLAIM_Ticket::gns_name, GNUNET_asprintf(), GNUNET_CRYPTO_signature_verify_(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_GNS_parse_ztld(), GNUNET_log, GNUNET_OK, GNUNET_RECLAIM_attribute_list_deserialize(), GNUNET_RECLAIM_presentation_list_deserialize(), GNUNET_SIGNATURE_PURPOSE_RECLAIM_CODE_SIGN, GNUNET_strdup, GNUNET_STRINGS_base64url_decode(), GNUNET_strndup, GNUNET_SYSERR, OIDC_Parameters::nonce_len, OIDC_VERIFICATION_NO_CODE_VERIFIER, gnunet-chk::opts, OIDC_Parameters::pres_list_len, GNUNET_CRYPTO_EccSignaturePurpose::purpose, ticket, and OIDC_Parameters::ticket.
Referenced by consume_fail(), and token_endpoint().
void OIDC_build_token_response | ( | const char * | access_token, |
const char * | id_token, | ||
const struct GNUNET_TIME_Relative * | expiration_time, | ||
char ** | token_response | ||
) |
Build a token response for a token request TODO: Maybe we should add the scope here?
access_token | the access token to include |
id_token | the id_token to include |
expiration_time | the expiration time of the token(s) |
token_response | where to store the response |
Definition at line 873 of file oidc_helper.c.
References GNUNET_assert, and GNUNET_TIME_Relative::rel_value_us.
Referenced by token_endpoint().
char * OIDC_access_token_new | ( | const struct GNUNET_RECLAIM_Ticket * | ticket, |
const char * | rp_uri | ||
) |
Generate a new access token.
Definition at line 901 of file oidc_helper.c.
References GNUNET_asprintf(), GNUNET_free, GNUNET_STRINGS_base64_encode(), and ticket.
Referenced by token_endpoint().
int OIDC_access_token_parse | ( | const char * | token, |
struct GNUNET_RECLAIM_Ticket ** | ticket, | ||
char ** | rp_uri | ||
) |
Parse an access token.
Definition at line 920 of file oidc_helper.c.
References GNUNET_assert, GNUNET_free, GNUNET_OK, GNUNET_strdup, GNUNET_STRINGS_base64_decode(), GNUNET_SYSERR, and ticket.
Referenced by userinfo_endpoint().
enum GNUNET_GenericReturnValue OIDC_check_scopes_for_claim_request | ( | const char * | scopes, |
const char * | attr | ||
) |
Checks if a claim is implicitly requested through standard scope(s)
scopes | the scopes which have been requested |
attr | the attribute name to check |
Checks if a claim is implicitly requested through standard scope(s)
scopes | the scopes which have been requested |
attr | the attribute name to check |
attribute matches requested scope
Definition at line 959 of file oidc_helper.c.
References GNUNET_free, GNUNET_NO, GNUNET_strdup, GNUNET_YES, OIDC_address_claims, OIDC_email_claims, OIDC_phone_claims, and OIDC_profile_claims.
Referenced by attr_in_claims_request().
char * OIDC_generate_userinfo | ( | const struct GNUNET_CRYPTO_PublicKey * | sub_key, |
const struct GNUNET_RECLAIM_AttributeList * | attrs, | ||
const struct GNUNET_RECLAIM_PresentationList * | presentations | ||
) |
Generate userinfo JSON as string.
sub_key | the subject (user) |
attrs | user attribute list |
presentations | credential presentation list |
sub_key | the subject (user) |
attrs | user attribute list |
presentations | credential presentation list (may be empty) |
Definition at line 348 of file oidc_helper.c.
References generate_userinfo_json().
Referenced by consume_fail(), and consume_ticket().