-
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.
Merge pull request #428 from atsign-foundation/at_auth_new
feat: at_auth package
- Loading branch information
Showing
24 changed files
with
1,005 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# https://dart.dev/guides/libraries/private-files | ||
# Created by `dart pub` | ||
.dart_tool/ | ||
.packages | ||
|
||
# Avoid committing pubspec.lock for library packages; see | ||
# https://dart.dev/guides/libraries/private-files#pubspeclock. | ||
pubspec.lock | ||
|
||
at_auth.iml |
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,2 @@ | ||
## 1.0.0 | ||
- Implemented onboard and authenticate methods. |
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,33 @@ | ||
Package for onboarding and authentication to an atsign's secondary server | ||
|
||
## Features | ||
|
||
- onboard logic - cram authentication,pkam/encryption/apkam key pair generation, initial pkam authentication | ||
- authentication - read keys from .atKeys file, pkam authentication | ||
|
||
## Getting started | ||
|
||
- Developers should have a free/paid atsign from https://atsign.com/ | ||
|
||
## Usage | ||
|
||
Onboard an atsign | ||
```dart | ||
final atAuth = AtAuthImpl(); | ||
final atOnboardingRequest = AtOnboardingRequest('@alice') | ||
..rootDomain = 'vip.ve.atsign.zone' | ||
..enableEnrollment = true | ||
..appName = 'wavi' | ||
..deviceName = 'iphone'; | ||
final atOnboardingResponse = await atAuth.onboard(atOnboardingRequest, <cram_secret>); | ||
``` | ||
|
||
Authenticate an atsign | ||
```dart | ||
final atAuth = AtAuthImpl(); | ||
final atAuthRequest = AtAuthRequest('@alice') | ||
..rootDomain = 'vip.ve.atsign.zone' | ||
..atKeysFilePath = args[1]; | ||
final atAuthResponse = await atAuth.authenticate(atAuthRequest); | ||
``` | ||
|
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,34 @@ | ||
# This file configures the static analysis results for your project (errors, | ||
# warnings, and lints). | ||
# | ||
# This enables the 'recommended' set of lints from `package:lints`. | ||
# This set helps identify many issues that may lead to problems when running | ||
# or consuming Dart code, and enforces writing Dart using a single, idiomatic | ||
# style and format. | ||
# | ||
# If you want a smaller set of lints you can change this to specify | ||
# 'package:lints/core.yaml'. These are just the most critical lints | ||
# (the recommended set includes the core lints). | ||
# The core lints are also what is used by pub.dev for scoring packages. | ||
|
||
include: package:lints/recommended.yaml | ||
|
||
# Uncomment the following section to specify additional rules. | ||
|
||
linter: | ||
rules: | ||
camel_case_types : true | ||
unnecessary_string_interpolations : true | ||
await_only_futures : true | ||
unawaited_futures: true | ||
depend_on_referenced_packages : false | ||
|
||
# analyzer: | ||
# exclude: | ||
# - path/to/excluded/files/** | ||
|
||
# For more information about the core and recommended set of lints, see | ||
# https://dart.dev/go/core-lints | ||
|
||
# For additional information about configuring this file, see | ||
# https://dart.dev/guides/language/analysis-options |
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,12 @@ | ||
import 'package:at_auth/at_auth.dart'; | ||
|
||
/// dart authenticate.dart <atsign> <path_to_atkeys_file> | ||
void main(List<String> args) async { | ||
final atAuth = AtAuthImpl(); | ||
final atSign = args[0]; | ||
final atAuthRequest = AtAuthRequest(atSign) | ||
..rootDomain = 'vip.ve.atsign.zone' | ||
..atKeysFilePath = args[1]; | ||
final atAuthResponse = await atAuth.authenticate(atAuthRequest); | ||
print('atAuthResponse: $atAuthResponse'); | ||
} |
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,15 @@ | ||
import 'package:at_auth/at_auth.dart'; | ||
|
||
/// dart onboard_apkam.dart <atsign> <cram_secret> | ||
void main(List<String> args) async { | ||
final atAuth = AtAuthImpl(); | ||
final atSign = args[0]; | ||
final atOnboardingRequest = AtOnboardingRequest(atSign) | ||
..rootDomain = 'vip.ve.atsign.zone' | ||
..enableEnrollment = true | ||
..appName = 'wavi' | ||
..deviceName = 'iphone'; | ||
final atOnboardingResponse = | ||
await atAuth.onboard(atOnboardingRequest, args[1]); | ||
print('atOnboardingResponse: $atOnboardingResponse'); | ||
} |
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,12 @@ | ||
import 'package:at_auth/at_auth.dart'; | ||
|
||
/// dart onboard_legacy.dart <atsign> <cram_secret> | ||
void main(List<String> args) async { | ||
final atAuth = AtAuthImpl(); | ||
final atSign = args[0]; | ||
final atOnboardingRequest = AtOnboardingRequest(atSign) | ||
..rootDomain = 'vip.ve.atsign.zone'; | ||
final atOnboardingResponse = | ||
await atAuth.onboard(atOnboardingRequest, args[1]); | ||
print('atOnboardingResponse: $atOnboardingResponse'); | ||
} |
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,10 @@ | ||
library at_auth; | ||
|
||
export 'src/at_auth_base.dart'; | ||
export 'src/at_auth_impl.dart'; | ||
export 'src/onboard/at_onboarding_request.dart'; | ||
export 'src/onboard/at_onboarding_response.dart'; | ||
export 'src/auth/at_auth_request.dart'; | ||
export 'src/auth/at_auth_response.dart'; | ||
export 'src/keys/at_auth_keys.dart'; | ||
export 'src/exception/at_auth_exceptions.dart'; |
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,25 @@ | ||
import 'package:at_auth/src/onboard/at_onboarding_request.dart'; | ||
import 'package:at_auth/src/onboard/at_onboarding_response.dart'; | ||
import 'package:at_auth/src/auth/at_auth_request.dart'; | ||
import 'package:at_auth/src/auth/at_auth_response.dart'; | ||
import 'package:at_chops/at_chops.dart'; | ||
|
||
/// Interface for onboarding and authentication to a secondary server of an atsign | ||
abstract class AtAuth { | ||
AtChops? atChops; | ||
|
||
/// Authenticate method is invoked when an atsign wants to authenticate to secondary server with an .atKeys file | ||
/// Step 1. Read the keys from [atAuthRequest.atAuthKeys] or [atAuthRequest.atKeysFilePath] | ||
/// Step 2 Perform pkam authentication | ||
Future<AtAuthResponse> authenticate(AtAuthRequest atAuthRequest); | ||
|
||
/// Onboard method is invoked when an atsign is activated for the first time from a client app. | ||
/// Step 1. Perform cram auth | ||
/// Step 2. Generate pkam, encryption keypairs and apkam symmetric key | ||
/// Step 3. Update pkam public key to secondary | ||
/// Step 4. Perform pkam auth | ||
/// Step 5. Update encryption public key to server and delete cram secret from server | ||
/// Set [atOnboardingRequest.publicKeyId] if pkam auth mode is [PkamAuthMode.sim] | ||
Future<AtOnboardingResponse> onboard( | ||
AtOnboardingRequest atOnboardingRequest, String cramSecret); | ||
} |
Oops, something went wrong.