Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Admin Ability to Create API Keys for Integration with External Systems #3007

Closed
mastercactapus opened this issue May 11, 2023 · 7 comments · Fixed by #3797
Closed

Admin Ability to Create API Keys for Integration with External Systems #3007

mastercactapus opened this issue May 11, 2023 · 7 comments · Fixed by #3797
Assignees
Labels
enhancement New feature or request

Comments

@mastercactapus
Copy link
Member

What problem would you like to solve? Please describe:
External systems and teams often want to build tools that integrate with GoAlert directly but currently lack the ability to authenticate and securely access GoAlert's API.

Describe the solution you'd like:
Allow administrators to create and manage API keys for external system integration. Offer direct tokens with optional expiration time and support for tokens generated by an OAuth server. Limit the ability to generate keys to users with admin access, but the keys themselves may not have admin-level access. For now, keep the ability to limit keys to specific resources out of scope, as the current auth model doesn't support it.

Describe alternatives you've considered:
User-generated API keys can be considered, but starting with user access limited to admins can help with adoption and maintain security.

Additional context:
Some use cases for API keys include:

  • External systems subscribing to alert events for improved communication and reporting
  • Building a Terraform plugin for GoAlert
  • Integrating with external scheduling systems
  • Synchronizing multiple GoAlert instances
@mastercactapus mastercactapus added the enhancement New feature or request label May 11, 2023
@mastercactapus
Copy link
Member Author

untitled-Map 1

1ddo pushed a commit to 1ddo/goalert that referenced this issue Jul 26, 2023
@mastercactapus
Copy link
Member Author

UI Design Notes:

New page Admin > API Keys as a list page displaying keys:

  • no search
  • no pagination
  • Name, Expiration, # of fields, is read-only (no Mutation.*), time last used
  • CREATE API KEY button (top on wide, FAB on mobile)
  • Can edit keys (name and description only)
  • Clicking on a key opens a details pane (like the Admin > Message Logs page) to allow edit & delete
    • Show allowed fields
    • Show creation time
    • Show created by user
    • Show last user agent string

New API Key form/dialog:

  • input: Name
  • input: Description
  • input: Expiration time
  • input: Allowed fields (multi-select)
    • Optional query input (paste/enter gql query, update selected fields)
  • Upon creation show non-click-away dialog state with copy button (only way to get the token)

API Reqs:

  • apiKeys query to list all API keys
  • createAPIKey mutation to generate a new key
  • queryFields query to list the fields of a provided query
  • allowedFields query to list all available schema fields

@mastercactapus
Copy link
Member Author

mastercactapus commented Oct 19, 2023

Remaining items:

  • Create key dialog enter query field (query -> allowed fields)
  • Denote expired keys
  • Add "duplicate" key option that's also available for expired keys
  • Add playwright integration test
  • remove experimental flag

@mastercactapus
Copy link
Member Author

mastercactapus commented Oct 19, 2023

  • duplicate should open the create dialog with all the values pre-populated
  • expired keys should probably have a warning icon
  • integration test can wait until the query field is done (so it can be a full test)

@Forfold
Copy link
Contributor

Forfold commented Feb 5, 2024

@mastercactapus How do we use this interface with input variables and how are input variables intended to be sent as a request to this API?

i.e. a Service query requires an ID as an input

Screenshot 2024-02-05 at 9 51 46 AM

@mastercactapus
Copy link
Member Author

Query doc would look something like this:
image

The actual request payload would be like this:

{
  "variables": {
    "id": "11111111-1111-1111-1111-111111111111"
  },
  "operationName": "Service"
}

Note that the query field can be omitted with API keys, otherwise it would look like this:

{
  "query": "query Service($id: ID!) {\n\tservice(id: $id) {\n    name\n  }\n}",
  "variables": {
    "id": "11111111-1111-1111-1111-111111111111"
  },
  "operationName": "Service"
}

@mastercactapus
Copy link
Member Author

More info on variables here:
https://graphql.org/learn/queries/#variables

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants