3 Commits

Author SHA1 Message Date
2248b1e6d7 changing to azure storage connection string 2024-10-11 13:10:08 -05:00
e192dcdb05 Feature/8 add optional auth guard (#9)
* adding optional auth to guard

* adding optional auth to guard
2024-09-24 08:58:43 -05:00
fcffd65d33 Feature/3 add az table module (#7)
* adding azure table client module

* adding azure table client module

* adding azure table client module

* adding azure table client module

* adding azure table client module
2024-08-11 19:51:23 -05:00
6 changed files with 10 additions and 8 deletions

View File

@@ -15,8 +15,11 @@ export class AuthGuard extends PassportAuthGuard('azure-ad') implements CanActiv
'isPublic',
context.getHandler()
);
const req = context.switchToHttp().getRequest();
const authHeader = req.headers.authorization;
const token = authHeader && authHeader.split(' ')[1];
if (isPublic) {
if (isPublic && !token) {
return true;
}

View File

@@ -1,4 +1,3 @@
export interface TableOptions {
accountName: string;
accountKey: string;
connectionString;
}

View File

@@ -13,7 +13,7 @@ export class TableModule {
provide: TABLE_OPTIONS,
useValue: options
},
TableModule
TableService
],
exports: [TableService]
}

View File

@@ -1,7 +1,7 @@
import { Inject, Injectable } from '@nestjs/common';
import { TableOptions } from './az-table.interface';
import { TABLE_OPTIONS } from './az-table.constants';
import { TableClient, AzureNamedKeyCredential } from '@azure/data-tables';
import { TableClient } from '@azure/data-tables';
@Injectable()
export class TableService {
@@ -11,8 +11,7 @@ export class TableService {
) {}
async getTableClient(tableName: string): Promise<TableClient> {
const credential: AzureNamedKeyCredential = new AzureNamedKeyCredential(this.tablesOptions.accountName, this.tablesOptions.accountKey);
const tableClient: TableClient = new TableClient(`https://${this.tablesOptions.accountName}.table.core.windows.net`, tableName, credential);
const tableClient: TableClient = new TableClient(this.tablesOptions.connectionString, tableName);
return tableClient;
}

View File

@@ -7,6 +7,7 @@ export * from './azAppConfig/az-app-config.service';
export * from './azTable/az-table.module';
export * from './azTable/az-table.service';
export { TableClient } from '@azure/data-tables';
// Auth

View File

@@ -1,6 +1,6 @@
{
"name": "@noahspan/noahspan-modules",
"version": "0.3.8",
"version": "0.4.0",
"description": "",
"author": "",
"license": "UNLICENSED",