Skip to content

Commit

Permalink
Merge pull request #89 from depot/fix/ceph-auth-namespace
Browse files Browse the repository at this point in the history
fix: use namespace for ceph authorization
  • Loading branch information
goller authored May 20, 2024
2 parents cdad3d5 + d09284a commit 7e178fc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/handlers/volumes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,12 @@ async function authorizeClient({
clientName: plainClientName,
imageSpec,
}: AuthorizeClientAction): Promise<PlainMessage<ReportVolumeUpdatesRequest>> {
const osdProfile = newOsdProfile(volumeName)
let namespace = volumeName
if (imageSpec && imageSpec.includes('/')) {
namespace = imageSpec.split('/')[1]
}

const osdProfile = newOsdProfile(namespace)
const clientName = newClientName(plainClientName)
await authCaps(osdProfile, clientName)

Expand Down
4 changes: 2 additions & 2 deletions src/utils/ceph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ export function newClientName(name: string): ClientName {
return name as ClientName
}

export function newOsdProfile(volumeName: string): OsdProfile {
export function newOsdProfile(namespace: string): OsdProfile {
// Gives a user read-write access to the Ceph Block Devices in namespace.
return `profile rbd pool=${POOL} namespace=${volumeName}` as OsdProfile
return `profile rbd pool=${POOL} namespace=${namespace}` as OsdProfile
}

export function newSnapshotSpec(snapshotName: string): SnapshotSpec {
Expand Down

0 comments on commit 7e178fc

Please sign in to comment.