Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QUESTION] Apply token-based authentication in Django 5.0.6 #414

Open
ianrussel opened this issue Oct 14, 2024 · 0 comments
Open

[QUESTION] Apply token-based authentication in Django 5.0.6 #414

ianrussel opened this issue Oct 14, 2024 · 0 comments
Labels
question Further information is requested

Comments

@ianrussel
Copy link

Question
Hi, I would like to ask what is the correct configuration in DJANGO when using msal authentication

`DATABASES = {
'default': {
'ENGINE': 'mssql',
'NAME': os.getenv('DB_NAME'),
'USER': os.getenv('DB_USER', None) if DB_HOST == 'localhost' else '',
'PASSWORD': os.getenv('DB_PASSWORD', None) if DB_HOST == 'localhost' else '',
'HOST': os.getenv('DB_HOST'), # Either 'localhost' or IP or domain name of the SQL Server
'PORT': os.getenv('DB_PORT'), # Default SQL Server port is 1433
'OPTIONS': {
'driver': 'ODBC Driver 17 for SQL Server', # Name of the ODBC driver you installed
'ConnectionPooling': 'False',
},
}
}

Apply token-based authentication only if not localhost

if DB_HOST != 'localhost':
DATABASES['default']['OPTIONS'].update({
'authentication': 'ActiveDirectoryAccessToken', # Authentication method
})
DATABASES['default']['TOKEN'] = get_sql_access_token() # Your MSAL token function
DATABASES['default']['extra_params'] = "Authentication=ActiveDirectoryAccessToken"`

Relevant Issues and Pull Requests

I always got error

(pyodbc.OperationalError) ('08001', "[08001] [Microsoft][ODBC Driver 17 for SQL Server]Invalid value specified for connection string attribute 'Authentication' (0) (SQLDriverConnect)")

regards,

Ian

@ianrussel ianrussel added the question Further information is requested label Oct 14, 2024
@ianrussel ianrussel changed the title [QUESTION] [QUESTION] Apply token-based authentication in Django 5.0.6 Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant