-
Notifications
You must be signed in to change notification settings - Fork 547
add basic authentication features #855
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
Merged
Merged
Changes from 43 commits
Commits
Show all changes
71 commits
Select commit
Hold shift + click to select a range
171a118
feat: add authentication support with APIAuthType and APIAuthModel
Udhay-Adithya 4177065
feat: improve authentication model with BearerToken, APIKey, and JWTB…
Udhay-Adithya 51fe211
feat: implement authentication handling in HTTP requests
Udhay-Adithya 6a2d1fd
feat: implement new authentication models
Udhay-Adithya 449e325
feat: refactor authentication handling to use new ApiAuthModel and up…
Udhay-Adithya efaebd0
fix: input text field error
Udhay-Adithya 1540d84
fix:prevent text field rebuild on watch
Udhay-Adithya 52a1feb
feat: enhance JWT authentication handling with new fields and JWT gen…
Udhay-Adithya a48d059
fix: state persistance upon api type switch
Udhay-Adithya 88017a9
chore: generate lock files
Udhay-Adithya 0d7f1a9
fix: update authorization label and reorder request pane
Udhay-Adithya fd92206
refactor: reorganize import statements
Udhay-Adithya d046d50
refactor: rename ApiAuthModel to AuthModel and authData to authModel
Udhay-Adithya 74c0959
refactor: rename authData to authModel and update related tests
Udhay-Adithya bb10ad6
feat: split authentication related fields into seperate files
Udhay-Adithya ff23413
feat: change text field design
Udhay-Adithya 0ec2120
feat: replace DropdownButtonFormField with ADPopupMenu for improved U…
Udhay-Adithya 5be9ffd
feat: update AuthModel serialization to use explicitToJson for nested…
Udhay-Adithya 99e5fa7
feat: enhance AuthModel serialization with anyMap support and add def…
Udhay-Adithya 987d9ca
feat: enhance EditAuthType to support read-only in history view
Udhay-Adithya 620c275
fix: change JWT generation failure handling to throw an exception ins…
Udhay-Adithya 5a6e2b1
feat: add authentication tab for graphql requests
Udhay-Adithya e06cb2e
feat: add read-only authentication tab to graphql history request pane
Udhay-Adithya bf170e1
feat: remove AuthModel from HttpRequestModel and integrate into Histo…
Udhay-Adithya 8d8940d
feat: add read-only support to authentication fields
Udhay-Adithya a17d6fd
chore: remove logging in EditAuthType
Udhay-Adithya 3903277
chore: resolve merge conflicts
Udhay-Adithya a11c833
refactor: move auth models to better_networking package
Udhay-Adithya 4284f47
fix: add missing crypto dependency to better_networking package
Udhay-Adithya 6c5862c
refactor: move authModel to HttpRequestModel
Udhay-Adithya 92af4fb
feat: add digest authentication
Udhay-Adithya d5ca13b
feat: enhance JWT support with private key handling and additional al…
Udhay-Adithya 13bf054
refactor: remove unused digest authentication model import and clean …
Udhay-Adithya c39b8fb
refactor: remove unused import and logging from JWT generation
Udhay-Adithya 32855fd
refactor: update authentication handling to check authData instead of…
Udhay-Adithya 8d4eedc
tests: add authentication unit tests
Udhay-Adithya a13d3d5
tests: add auth fields widget tests(coverage 98.4%)
Udhay-Adithya dcccc2b
tests: add api auth model tests(coverage 100%)
Udhay-Adithya 739afca
tests: improve auth utils tests(coverage 90%)
Udhay-Adithya e838654
feat: enhance authentication fields with additional info
Udhay-Adithya 38d8e8e
fix: update tooltip icon color and size
Udhay-Adithya 127b2c1
fix: disable onChanged for read-only auth fields
Udhay-Adithya 38eb527
feat: update APIAuthType enum to include display types for authentica…
Udhay-Adithya 65f375c
Merge branch 'foss42:main' into basic-auth
Udhay-Adithya db93e82
fix: make authModel optional in HistoryRequestModel
Udhay-Adithya 20c7107
fix: update qop label in DigestAuthFields test
Udhay-Adithya 3ca5255
fix: pass null for authData in sendHttpRequest for digest authenticat…
Udhay-Adithya 51c44a3
fix: update label for private key field in JWT auth fields test
Udhay-Adithya db2f5af
refactor: move auth_textfield to widgets folder
Udhay-Adithya 69e7f7b
docs: add authentication testing links
Udhay-Adithya 9850b7a
Update auth widgets export
animator 99c38c4
refactor API Key auth
animator 5afce74
Update consts.dart
animator 759e906
Update basic_auth_fields.dart
animator 7925a38
Update bearer_auth_fields.dart
animator 5d89dfd
Update consts.dart
animator 568927b
rename AuthTextField
animator 13a4000
refactor imports
animator 4f11185
Update imports in tests
animator 33acbc8
Update pubspec.yaml
animator 447cbd4
refactor for digest
animator 1e10606
Remove comments from JWT
animator 32dcbda
JWT refactor
animator b8d0d03
reinstate highlight
animator 3948351
turns fields optional
animator 972d8be
Add AuthPage
animator 862319b
Update hisotry rwquest pane auth
animator 245a7b7
Fix EditGraphQLRequestPane provider
animator 351131f
Update pubspec.yaml
animator 744b8c0
Fix dropdown labels
animator 1dea1b4
Fix test
animator File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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
107 changes: 107 additions & 0 deletions
107
lib/screens/common_widgets/auth/api_key_auth_fields.dart
This file contains hidden or 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,107 @@ | ||
import 'package:apidash/screens/common_widgets/auth_textfield.dart'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Constants should be in consts.dart not hardcoded in this file |
||
import 'package:apidash_core/apidash_core.dart'; | ||
import 'package:apidash_design_system/apidash_design_system.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
class ApiKeyAuthFields extends StatefulWidget { | ||
final AuthModel? authData; | ||
final bool readOnly; | ||
final Function(AuthModel?) updateAuth; | ||
|
||
const ApiKeyAuthFields( | ||
{super.key, | ||
required this.authData, | ||
required this.updateAuth, | ||
this.readOnly = false}); | ||
|
||
@override | ||
State<ApiKeyAuthFields> createState() => _ApiKeyAuthFieldsState(); | ||
} | ||
|
||
class _ApiKeyAuthFieldsState extends State<ApiKeyAuthFields> { | ||
late TextEditingController _keyController; | ||
late TextEditingController _nameController; | ||
late String _addKeyTo; | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
final apiAuth = widget.authData?.apikey; | ||
_keyController = TextEditingController(text: apiAuth?.key ?? ''); | ||
_nameController = TextEditingController(text: apiAuth?.name ?? 'x-api-key'); | ||
_addKeyTo = apiAuth?.location ?? 'header'; | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
Text( | ||
"Add to", | ||
style: TextStyle( | ||
fontWeight: FontWeight.normal, | ||
fontSize: 14, | ||
), | ||
), | ||
SizedBox( | ||
height: 4, | ||
), | ||
ADPopupMenu<String>( | ||
value: _addKeyTo == 'header' ? 'Header' : 'Query Params', | ||
values: const [ | ||
('header', 'Header'), | ||
('query', 'Query Params'), | ||
], | ||
tooltip: "Select where to add API key", | ||
isOutlined: true, | ||
onChanged: widget.readOnly | ||
? null | ||
: (String? newLocation) { | ||
if (newLocation != null) { | ||
setState(() { | ||
_addKeyTo = newLocation; | ||
}); | ||
_updateApiKeyAuth(); | ||
} | ||
}, | ||
), | ||
const SizedBox(height: 16), | ||
AuthTextField( | ||
readOnly: widget.readOnly, | ||
controller: _nameController, | ||
hintText: "Header/Query Param Name", | ||
onChanged: (value) => _updateApiKeyAuth(), | ||
), | ||
const SizedBox(height: 16), | ||
AuthTextField( | ||
readOnly: widget.readOnly, | ||
controller: _keyController, | ||
title: "API Key", | ||
hintText: "Key", | ||
isObscureText: true, | ||
onChanged: (value) => _updateApiKeyAuth(), | ||
), | ||
], | ||
); | ||
} | ||
|
||
void _updateApiKeyAuth() { | ||
widget.updateAuth(widget.authData?.copyWith( | ||
type: APIAuthType.apiKey, | ||
apikey: AuthApiKeyModel( | ||
key: _keyController.text.trim(), | ||
name: _nameController.text.trim(), | ||
location: _addKeyTo, | ||
), | ||
) ?? | ||
AuthModel( | ||
type: APIAuthType.apiKey, | ||
apikey: AuthApiKeyModel( | ||
key: _keyController.text.trim(), | ||
name: _nameController.text.trim(), | ||
location: _addKeyTo, | ||
), | ||
)); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This field should be optional not required