Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Global rule:
* @Bandwidth-Samples/dx
* @Bandwidth-Samples/band-swi @Bandwidth-Samples/band-devx
11 changes: 0 additions & 11 deletions .github/actions/maven-test/Dockerfile

This file was deleted.

6 changes: 0 additions & 6 deletions .github/actions/maven-test/action.yml

This file was deleted.

3 changes: 0 additions & 3 deletions .github/actions/maven-test/entrypoint.sh

This file was deleted.

19 changes: 19 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: 2

updates:
- package-ecosystem: maven
directory: /
schedule:
interval: monthly
open-pull-requests-limit: 5
ignore:
- dependency-name: "com.bandwidth.sdk:bandwidth-sdk"
update-types:
- version-update:semver-minor
- version-update:semver-patch
groups:
dependencies:
patterns:
- "*"
exclude-patterns:
- "com.bandwidth.sdk:bandwidth-sdk"
16 changes: 0 additions & 16 deletions .github/workflows/on-pull-request.yaml

This file was deleted.

16 changes: 16 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Test

on:
pull_request:
branches:
- main
schedule:
- cron: "0 9 * * 1"

jobs:
contract-test:
name: Contract Test
uses: Bandwidth-Samples/sample-app-tooling/.github/workflows/java.yml@main
with:
sample: mfa-cli
start-command: mvn -B -q exec:java
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 Bandwidth Samples
Copyright (c) 2026 Bandwidth Samples

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
28 changes: 16 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,41 @@

# Description

This app creates a simple CLI tool used to create and verify multi-factor auth codes using Bandwidth's Multi-Factor Auth API. The app will prompt the user for their phone number, followed by their preferred method of code delivery; either messaging or voice. The app will then text or call the phone number provided with a 6 digit MFA code that the user can enter back into the CLI to verify.
This sample app is a command line tool that sends and verifies multi-factor auth codes using Bandwidth's Multi-Factor Auth API.

The app asks for a phone number in E.164 format and whether to send the code by `messaging` or `voice` (`messaging` if left blank). It then texts or calls that number with a 6 digit code, asks you to enter the code, and checks it. The app exits with status `0` if the code is verified and `1` otherwise.

# Pre-Requisites

In order to use the Bandwidth API users need to set up the appropriate application at the [Bandwidth Dashboard](https://dashboard.bandwidth.com/) and create API tokens.
In order to use the Bandwidth API users need to set up the appropriate applications at the [Bandwidth Dashboard](https://dashboard.bandwidth.com/) and create API tokens.

To create an application log into the [Bandwidth Dashboard](https://dashboard.bandwidth.com/) and navigate to the `Applications` tab. Fill out the **New Application** form selecting the service (Messaging or Voice) that the application will be used for. All Bandwidth services require publicly accessible Callback URLs, for more information on how to set one up see [Callback URLs](#callback-urls).
This app needs two applications, one for each delivery method. To create an application log into the [Bandwidth Dashboard](https://dashboard.bandwidth.com/) and navigate to the `Applications` tab. Fill out the **New Application** form once selecting Messaging, and once selecting Voice. This app doesn't receive any callbacks, so the callback URLs can be left as placeholders.

For more information about API credentials see our [Account Credentials](https://dev.bandwidth.com/docs/account/credentials) page.

# Running the Application

To install the required packages for this app, run the command:
To install the required packages and build the app, run the command:

```sh
mvn clean install
mvn package
```

Use the following command to run the application:

```sh
mvn exec:java
mvn -q exec:java
```

# Environmental Variables

The sample app uses the below environmental variables.

```sh
BW_ACCOUNT_ID # Your Bandwidth Account Id
BW_USERNAME # Your Bandwidth API Token
BW_PASSWORD # Your Bandwidth API Secret
BW_NUMBER # Your The Bandwidth Phone Number
BW_VOICE_APPLICATION_ID # Your Voice Application Id created in the dashboard
BW_MESSAGING_APPLICATION_ID # Your Messaging Application Id created in the dashboard
BW_ACCOUNT_ID # Your Bandwidth Account Id
BW_CLIENT_ID # Your Bandwidth API OAuth Client Id
BW_CLIENT_SECRET # Your Bandwidth API OAuth Client Secret
BW_NUMBER # The Bandwidth phone number the code is sent from
BW_VOICE_APPLICATION_ID # Your Voice Application Id created in the dashboard
BW_MESSAGING_APPLICATION_ID # Your Messaging Application Id created in the dashboard
```
21 changes: 7 additions & 14 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,15 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>11</java.version>
<spring.version>2.2.6.RELEASE</spring.version>
<java.version>21</java.version>
</properties>

<dependencies>
<!-- https://mvnrepository.com/artifact/com.bandwidth.sdk/bandwidth-sdk -->
<dependency>
<groupId>com.bandwidth.sdk</groupId>
<artifactId>bandwidth-sdk</artifactId>
<version>9.1.2</version>
</dependency>

<dependency>
<groupId>javax.activation</groupId>
<artifactId>javax.activation-api</artifactId>
<version>1.2.0</version>
<version>18.3.1</version>
</dependency>
</dependencies>

Expand All @@ -35,16 +28,16 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<version>3.16.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.1.1</version>
<version>3.6.4</version>
<configuration>
<mainClass>com.bandwidth.Main</mainClass>
</configuration>
Expand Down
Loading
Loading