Skip to content

Commit

Permalink
feat(definitions): add CredentialsScheme interface
Browse files Browse the repository at this point in the history
  • Loading branch information
JKRhb committed Mar 10, 2022
1 parent 47a2718 commit 43f2457
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 6 deletions.
1 change: 1 addition & 0 deletions lib/definitions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ export 'src/definitions/credentials/credentials.dart';
export 'src/definitions/credentials/digest_credentials.dart';
export 'src/definitions/credentials/oauth2_credentials.dart';
export 'src/definitions/credentials/psk_credentials.dart';
export 'src/definitions/security/credentials_scheme.dart';
export 'src/definitions/thing_description.dart';
export 'src/definitions/thing_model.dart';
3 changes: 2 additions & 1 deletion lib/src/definitions/security/apikey_security_scheme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
// SPDX-License-Identifier: BSD-3-Clause

import '../credentials/apikey_credentials.dart';
import 'credentials_scheme.dart';
import 'helper_functions.dart';
import 'security_scheme.dart';

/// API key authentication security configuration identified by the Vocabulary
/// Term `apikey`.
class ApiKeySecurityScheme extends SecurityScheme {
class ApiKeySecurityScheme extends SecurityScheme implements CredentialsScheme {
@override
String get scheme => "apikey";

Expand Down
3 changes: 2 additions & 1 deletion lib/src/definitions/security/basic_security_scheme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
// SPDX-License-Identifier: BSD-3-Clause

import '../credentials/basic_credentials.dart';
import 'credentials_scheme.dart';
import 'helper_functions.dart';
import 'security_scheme.dart';

/// Basic Authentication security configuration identified by the Vocabulary
/// Term `basic`.
class BasicSecurityScheme extends SecurityScheme {
class BasicSecurityScheme extends SecurityScheme implements CredentialsScheme {
@override
String get scheme => "basic";

Expand Down
3 changes: 2 additions & 1 deletion lib/src/definitions/security/bearer_security_scheme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
// SPDX-License-Identifier: BSD-3-Clause

import '../credentials/bearer_credentials.dart';
import 'credentials_scheme.dart';
import 'helper_functions.dart';
import 'security_scheme.dart';

/// Bearer Token security configuration identified by the Vocabulary Term
/// `bearer`.
class BearerSecurityScheme extends SecurityScheme {
class BearerSecurityScheme extends SecurityScheme implements CredentialsScheme {
@override
String get scheme => "bearer";

Expand Down
13 changes: 13 additions & 0 deletions lib/src/definitions/security/credentials_scheme.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// 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/credentials.dart';

/// Interface to ensure that a given `SecurityScheme` has a [credentials] field.
abstract class CredentialsScheme {
/// The credentials assigned to this [CredentialsScheme].
Credentials? get credentials;
}
3 changes: 2 additions & 1 deletion lib/src/definitions/security/digest_security_scheme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
// SPDX-License-Identifier: BSD-3-Clause

import '../credentials/digest_credentials.dart';
import 'credentials_scheme.dart';
import 'helper_functions.dart';
import 'security_scheme.dart';

/// Digest Access Authentication security configuration identified by the
/// Vocabulary Term `digest`.
class DigestSecurityScheme extends SecurityScheme {
class DigestSecurityScheme extends SecurityScheme implements CredentialsScheme {
@override
String get scheme => "digest";

Expand Down
3 changes: 2 additions & 1 deletion lib/src/definitions/security/oauth2_security_scheme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
// SPDX-License-Identifier: BSD-3-Clause

import '../credentials/oauth2_credentials.dart';
import 'credentials_scheme.dart';
import 'helper_functions.dart';
import 'security_scheme.dart';

/// OAuth 2.0 authentication security configuration for systems conformant with
/// RFC 6749, RFC 8252 and (for the device flow) RFC 8628, identified by the
/// Vocabulary Term `oauth2`.
class OAuth2SecurityScheme extends SecurityScheme {
class OAuth2SecurityScheme extends SecurityScheme implements CredentialsScheme {
@override
String get scheme => "oauth2";

Expand Down
3 changes: 2 additions & 1 deletion lib/src/definitions/security/psk_security_scheme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
// SPDX-License-Identifier: BSD-3-Clause

import '../credentials/psk_credentials.dart';
import 'credentials_scheme.dart';
import 'helper_functions.dart';
import 'security_scheme.dart';

/// Pre-shared key authentication security configuration identified by the
/// Vocabulary Term `psk`.
class PskSecurityScheme extends SecurityScheme {
class PskSecurityScheme extends SecurityScheme implements CredentialsScheme {
@override
String get scheme => "psk";

Expand Down

0 comments on commit 43f2457

Please sign in to comment.