Skip to content

Commit 7f27269

Browse files
committed
docs: Fix runas command and add NTLM auth configuration to check_sql_auth
1 parent 6465961 commit 7f27269

File tree

2 files changed

+61
-3
lines changed

2 files changed

+61
-3
lines changed

docs/pages/product/auth/methods/ntlm.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ In the following example, Power BI Desktop is launched under the `cube` user:
3333

3434
```bash
3535
# Run Power BI Desktop as the `cube` user
36-
runas /user:cube "C:\Program Files\Microsoft Power BI Desktop\bin\PBIDesktop.exe"
36+
runas /netonly /user:cube "C:\Program Files\Microsoft Power BI Desktop\bin\PBIDesktop.exe"
3737

3838
# Run a specific report in Power BI Desktop as the `cube` user
39-
runas /user:cube "C:\Program Files\Microsoft Power BI Desktop\bin\PBIDesktop.exe \"C:\Users\Administrator\Desktop\Dashboard.pbix\""
39+
runas /netonly /user:cube "C:\Program Files\Microsoft Power BI Desktop\bin\PBIDesktop.exe \"C:\Users\Administrator\Desktop\Dashboard.pbix\""
4040
```
4141

4242
__This flow should only be used for testing purposes.__ Note that, when Power BI Desktop

docs/pages/product/configuration/reference/config.mdx

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1256,6 +1256,61 @@ module.exports = {
12561256
Check [this recipe](/product/auth/recipes/sql-api-ldap) for an example of
12571257
using `check_sql_auth` to authenticate requests to the SQL API with LDAP.
12581258

1259+
You can also check for the protocol and the authentication method as follows. This can
1260+
be useful for handling the [NTLM][ref-ntlm] authentication in the [DAX API][ref-dax-api]
1261+
and the [MDX API][ref-mdx-api]:
1262+
1263+
<CodeTabs>
1264+
1265+
```python
1266+
from cube import config
1267+
import os
1268+
1269+
@config('check_sql_auth')
1270+
def check_sql_auth(req: dict, user_name: str, password: str) -> dict:
1271+
# Handle NTLM authentication:
1272+
# - for Power BI `runas` command
1273+
# - for Power BI gateway
1274+
if req['protocol'] == 'xmla' and req['method'] == 'ntlm':
1275+
if (user_name == os.environ.get('CUBEJS_SQL_USER')):
1276+
return {
1277+
'password': os.environ.get('CUBEJS_SQL_PASSWORD'),
1278+
'securityContext': {}
1279+
}
1280+
1281+
return {
1282+
'password': os.environ.get('CUBEJS_SQL_PASSWORD'),
1283+
'securityContext': {}
1284+
}
1285+
1286+
raise Exception('Access denied')
1287+
```
1288+
1289+
```javascript
1290+
module.exports = {
1291+
checkSqlAuth: (req, user_name, password) => {
1292+
// handle ntlm auth scenarios (PBI "runas" command + PBI gateway auth)
1293+
if (req.protocol === 'xmla' && req.method === 'ntlm') {
1294+
if (user_name === process.env.CUBEJS_SQL_USER) {
1295+
return {
1296+
password: process.env.CUBEJS_SQL_PASSWORD,
1297+
securityContext: {}
1298+
}
1299+
}
1300+
1301+
return {
1302+
password: process.env.CUBEJS_SQL_PASSWORD,
1303+
securityContext: {}
1304+
}
1305+
}
1306+
1307+
throw new Error('Access denied')
1308+
}
1309+
}
1310+
```
1311+
1312+
</CodeTabs>
1313+
12591314
### `can_switch_sql_user`
12601315

12611316
Used in the [SQL API][ref-sql-api]. Default implementation depends on
@@ -1484,4 +1539,7 @@ If not defined, Cube will lookup for environment variable
14841539
[ref-dap-roles]: /product/auth/data-access-policies#data-access-roles
14851540
[ref-auth-integration]: /product/auth#authentication-integration
14861541
[ref-ldap-roles-mapping]: /product/workspace/sso#user-roles-mapping
1487-
[ref-ldap-integration]: /product/workspace/sso#ldap-integration
1542+
[ref-ldap-integration]: /product/workspace/sso#ldap-integration
1543+
[ref-dax-api]: /product/apis-integrations/dax-api
1544+
[ref-mdx-api]: /product/apis-integrations/mdx-api
1545+
[ref-ntlm]: /product/auth/methods/ntlm

0 commit comments

Comments
 (0)