-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(authorization): add bearer token authorization
- Loading branch information
1 parent
864a507
commit b3760be
Showing
3 changed files
with
42 additions
and
2 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
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
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,30 @@ | ||
import { debug } from 'debug' | ||
|
||
import { | ||
CamundaEnvironmentConfigurator, | ||
CamundaPlatform8Configuration, | ||
DeepPartial, | ||
} from '../../lib' | ||
import { IOAuthProvider } from '../index' | ||
|
||
import { TokenGrantAudienceType } from './IOAuthProvider' | ||
|
||
export class BearerAuthProvider implements IOAuthProvider { | ||
private bearerToken: string | ||
|
||
constructor(options?: { | ||
config?: DeepPartial<CamundaPlatform8Configuration> | ||
}) { | ||
const config = CamundaEnvironmentConfigurator.mergeConfigWithEnvironment( | ||
options?.config ?? {} | ||
) | ||
|
||
this.bearerToken = config.BEARER_TOKEN || '' | ||
} | ||
|
||
public async getToken(audienceType: TokenGrantAudienceType): Promise<string> { | ||
debug(`Token request for ${audienceType}`) | ||
|
||
return Promise.resolve(this.bearerToken) | ||
} | ||
} |