Skip to content

Commit

Permalink
feat: add basic credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
JKRhb committed Feb 3, 2022
1 parent 8a21c16 commit 76333eb
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/definitions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
///
/// [spec link]: https://www.w3.org/TR/wot-thing-description11/
export 'src/definitions/credentials/basic_credentials.dart';
export 'src/definitions/credentials/credentials.dart';
export 'src/definitions/thing_description.dart';
export 'src/definitions/thing_model.dart';
6 changes: 6 additions & 0 deletions lib/src/core/consumed_thing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@

import '../../scripting_api.dart' as scripting_api;
import '../../scripting_api.dart' hide ConsumedThing, InteractionOutput;
import '../definitions/credentials/basic_credentials.dart';
import '../definitions/credentials/credentials.dart';
import '../definitions/data_schema.dart';
import '../definitions/form.dart';
import '../definitions/interaction_affordances/interaction_affordance.dart';
import '../definitions/security/basic_security_scheme.dart';
import '../definitions/security/security_scheme.dart';
import '../definitions/thing_description.dart';
import 'interaction_output.dart';
Expand Down Expand Up @@ -64,6 +66,10 @@ class ConsumedThing implements scripting_api.ConsumedThing {
for (final entry in securityDefinitions.entries) {
final credentials = credentialStore?[entry.key];
final securityDefinition = entry.value;
if (securityDefinition is BasicSecurityScheme &&
credentials is BasicCredentials) {
securityDefinition.credentials = credentials;
}
}
}

Expand Down
21 changes: 21 additions & 0 deletions lib/src/definitions/credentials/basic_credentials.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright 2022 The NAMIB Project Developers. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//
// SPDX-License-Identifier: BSD-3-Clause

import 'credentials.dart';

/// [Credentials] used for the `BasicSecurityScheme`.
///
/// Provides an unencrypted [username] and [password] combination.
class BasicCredentials extends Credentials {
/// The [username] associated with these [BasicCredentials].
String username;

/// The [password] associated with these [BasicCredentials].
String password;

/// Constructor.
BasicCredentials(this.username, this.password) : super("basic");
}

0 comments on commit 76333eb

Please sign in to comment.