-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* API Management Backend: Add title and description to api_keys Model changes - Add title and description fields to api_keys model. - Add a user_id field which automatically takes the current user's id. - Add a team_id field GraphQL Changes Add mutations to create and delete api keys. User has to be an admin in the current workspace in order to be able to administer api keys. * Add GraphQL query to fetch team api keys Add ability to list all api keys in a team, and the ability to fetch one api key given its id. * Add mutation and test to delete team api keys * Add UserType to ApiKeyType * Create bot user when creating api keys via GraphQL When the CreateApiKey mutation is called, we will automatically create a new BotUser linked to the team. This bot user will host and own the api key. * Polish api-key creation permissions * Add reviewer feedback * Generate relay/graphql schema * Add team and user to api keys (in original migration) * Add reviewer feedback - Clean up ApiKeyMutations - Change team and user columns in api_keys table to references - Add maximum number of api_keys in a team - Increase default expiry limit of api_keys * Fix failing tests * Fix deletion of api keys, and bot_user name * Set default role for TeamUser when creating api_key When creating api_key, set the role for the created TeamUser to 'editor' * Don't create bot_user when creating api keys without team Don't create bot_user when creating api keys without team * Create bot user only when needed * Get API key expiry from application configuration * Log all graphql activity Log all calls to the graphql endpoint * ApiKey title should not be mandatory * Fix failing tests * Order team api keys by creation date * Revert unintended changes to schema.rb * Log graphql activity only when a user is available --------- Co-authored-by: Alexandre Amorim <[email protected]>
- Loading branch information
1 parent
1cbb141
commit 2c531f4
Showing
20 changed files
with
1,120 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module ApiKeyMutations | ||
MUTATION_TARGET = 'api_key'.freeze | ||
PARENTS = ['team'].freeze | ||
|
||
class Create < Mutations::CreateMutation | ||
argument :title, GraphQL::Types::String, required: false | ||
argument :description, GraphQL::Types::String, required: false | ||
end | ||
|
||
class Destroy < Mutations::DestroyMutation; end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
class ApiKeyType < DefaultObject | ||
description "ApiKey type" | ||
|
||
implements GraphQL::Types::Relay::Node | ||
|
||
field :dbid, GraphQL::Types::Int, null: true | ||
field :team_id, GraphQL::Types::Int, null: true | ||
field :user_id, GraphQL::Types::Int, null: true | ||
field :title, GraphQL::Types::String, null: true | ||
field :access_token, GraphQL::Types::String, null: true | ||
field :description, GraphQL::Types::String, null: true | ||
field :application, GraphQL::Types::String, null: true | ||
field :expire_at, GraphQL::Types::String, null: true | ||
|
||
field :team, TeamType, null: true | ||
field :user, UserType, null: true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class AddTitleDescToApiKeys < ActiveRecord::Migration[6.1] | ||
def change | ||
add_column(:api_keys, :title, :string) unless column_exists?(:api_keys, :title) | ||
add_column :api_keys, :description, :string | ||
add_reference(:api_keys, :team, foreign_key: true, null: true) unless column_exists?(:api_keys, :team_id) | ||
add_reference(:api_keys, :user, foreign_key: true, null: true) unless column_exists?(:api_keys, :user_id) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.