1# Debugging Access Token Issuer
2
3This sample demonstrates a Firebase Cloud Function that issues debugging access
4tokens to authenticated and authorized users.
5
6The directory structure looks like this:
7
8```shell
9server/
10 |
11 +- firebase.json  # Describes properties of the project
12 |
13 +- genkey.sh      # Optional script to generate token signing
14                   # key and certificates with a self-signed CA
15 |
16 + package.json    # npm package file
17 |
18 +- functions/     # Directory containing the function code
19      |
20      +- api_config.SAMPLE.json # A sample configuration
21      |
22      +- .eslintrc.json  # Rules for JavaScript linting
23      |
24      +- package.json  # npm package file
25      |
26      +- index.js      # main source file
27      |
28      +- node_modules/ # directory where the dependencies (declared in
29                       # package.json) are installed
30```
31
32## Running the Samples
33
34*   Setup Firebase Cloud Functions. See Step 1-3 of the guide at
35    [https://firebase.google.com/docs/functions/get-started](https://firebase.google.com/docs/functions/get-started).
36*   Prepare the token signing key and certificate. The key MUST be a RSA key
37    with at least 2048 bits. The certificate MUST contain at least one Subject
38    Alternative Name
39    ([SAN](https://en.wikipedia.org/wiki/Subject_Alternative_Name)). Use
40    `genkey.sh` if signing the certificate with a self-signed CA.
41*   Configure the token issuer in a config file. See `api_config.SAMPLE.json`
42    for an example. The config file contains secret information; do NOT commit
43    it in git.
44*   Deploy the config file by running `firebase functions:config:set
45    api_config="$(cat YOUR_CONFIG.json)"`.
46*   Deploy the Cloud Function. See the instructions at
47    [https://firebase.google.com/docs/functions/manage-functions](hhttps://firebase.google.com/docs/functions/manage-functions).
48
49## License
50
51Copyright 2021 Google LLC
52
53Licensed to the Apache Software Foundation (ASF) under one or more contributor
54license agreements. See the NOTICE file distributed with this work for
55additional information regarding copyright ownership. The ASF licenses this file
56to you under the Apache License, Version 2.0 (the "License"); you may not use
57this file except in compliance with the License. You may obtain a copy of the
58License at
59
60http://www.apache.org/licenses/LICENSE-2.0
61
62Unless required by applicable law or agreed to in writing, software distributed
63under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
64CONDITIONS OF ANY KIND, either express or implied. See the License for the
65specific language governing permissions and limitations under the License.
66