Coverage Report

Created: 2026-09-03 06:52

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/mod_auth_openidc/src/handle/revoke.c
Line
Count
Source
1
/*
2
 * Licensed to the Apache Software Foundation (ASF) under one
3
 * or more contributor license agreements.  See the NOTICE file
4
 * distributed with this work for additional information
5
 * regarding copyright ownership.  The ASF licenses this file
6
 * to you under the Apache License, Version 2.0 (the
7
 * "License"); you may not use this file except in compliance
8
 * with the License.  You may obtain a copy of the License at
9
 *
10
 *   http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing,
13
 * software distributed under the License is distributed on an
14
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
 * KIND, either express or implied.  See the License for the
16
 * specific language governing permissions and limitations
17
 * under the License.
18
 */
19
20
/***************************************************************************
21
 * Copyright (C) 2017-2026 ZmartZone Holding BV
22
 * All rights reserved.
23
 *
24
 * DISCLAIMER OF WARRANTIES:
25
 *
26
 * THE SOFTWARE PROVIDED HEREUNDER IS PROVIDED ON AN "AS IS" BASIS, WITHOUT
27
 * ANY WARRANTIES OR REPRESENTATIONS EXPRESS, IMPLIED OR STATUTORY; INCLUDING,
28
 * WITHOUT LIMITATION, WARRANTIES OF QUALITY, PERFORMANCE, NONINFRINGEMENT,
29
 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  NOR ARE THERE ANY
30
 * WARRANTIES CREATED BY A COURSE OR DEALING, COURSE OF PERFORMANCE OR TRADE
31
 * USAGE.  FURTHERMORE, THERE ARE NO WARRANTIES THAT THE SOFTWARE WILL MEET
32
 * YOUR NEEDS OR BE FREE FROM ERRORS, OR THAT THE OPERATION OF THE SOFTWARE
33
 * WILL BE UNINTERRUPTED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
34
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
35
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES HOWEVER CAUSED AND ON ANY THEORY OF
36
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
37
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
38
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39
 *
40
 * @Author: Hans Zandbelt - hans.zandbelt@openidc.com
41
 */
42
43
#include "handle/handle.h"
44
#include "mod_auth_openidc.h"
45
46
12
int oidc_revoke_session(request_rec *r, const oidc_cfg_t *c) {
47
12
  apr_byte_t rc = FALSE;
48
12
  char *session_id = NULL;
49
50
12
  oidc_util_url_parameter_get(r, OIDC_REDIRECT_URI_REQUEST_REVOKE_SESSION, &session_id);
51
12
  if (session_id == NULL)
52
0
    return HTTP_BAD_REQUEST;
53
54
12
  if (oidc_cfg_session_type_get(c) == OIDC_SESSION_TYPE_SERVER_CACHE)
55
12
    rc = oidc_cache_set_session(r, session_id, NULL, 0);
56
0
  else
57
12
    oidc_warn(r, "cannot revoke session because server side caching is not in use");
58
59
12
  r->user = "";
60
61
12
  return (rc == TRUE) ? OK : HTTP_INTERNAL_SERVER_ERROR;
62
12
}
63
64
/*
65
 * handle a request to invalidate a cached access token introspection result
66
 */
67
2
int oidc_revoke_at_cache_remove(request_rec *r, oidc_cfg_t *c) {
68
2
  char *access_token = NULL;
69
2
  oidc_util_url_parameter_get(r, OIDC_REDIRECT_URI_REQUEST_REMOVE_AT_CACHE, &access_token);
70
2
  if (access_token == NULL)
71
0
    return HTTP_BAD_REQUEST;
72
73
2
  char *cache_entry = NULL;
74
2
  oidc_cache_get_access_token(r, access_token, &cache_entry);
75
2
  if (cache_entry == NULL) {
76
2
    oidc_error(r, "no cached access token found for value: %s", access_token);
77
2
    return HTTP_NOT_FOUND;
78
2
  }
79
80
0
  oidc_cache_set_access_token(r, access_token, NULL, 0);
81
82
0
  return OK;
83
2
}