Checking if a SQL Server login already exists

Here’s a way to do this in SQL Server 2005 and later without using the deprecated syslogins view: IF NOT EXISTS (SELECT name FROM master.sys.server_principals WHERE name=”LoginName”) BEGIN CREATE LOGIN [LoginName] WITH PASSWORD = N’password’ END The server_principals view is used instead of sql_logins because the latter doesn’t list Windows logins. If you need to … Read more

SQL Server 2008 can’t login with newly created user

SQL Server was not configured to allow mixed authentication. Here are steps to fix: Right-click on SQL Server instance at root of Object Explorer, click on Properties Select Security from the left pane. Select the SQL Server and Windows Authentication mode radio button, and click OK. Right-click on the SQL Server instance, select Restart (alternatively, … Read more

JWT vs cookies for token-based authentication

The biggest difference between bearer tokens and cookies is that the browser will automatically send cookies, where bearer tokens need to be added explicitly to the HTTP request. This feature makes cookies a good way to secure websites, where a user logs in and navigates between pages using links. The browser automatically sending cookies also … Read more

What is the purpose of a “Refresh Token”?

Basically, refresh tokens are used to get new access token. To clearly differentiate these two tokens and avoid getting mixed up, here are their functions given in The OAuth 2.0 Authorization Framework: Access tokens are issued to third-party clients by an authorization server with the approval of the resource owner. The client uses the access … Read more

How to create user for a db in postgresql? [closed]

From CLI: $ su – postgres $ psql template1 template1=# CREATE USER tester WITH PASSWORD ‘test_password’; template1=# GRANT ALL PRIVILEGES ON DATABASE “test_database” to tester; template1=# \q PHP (as tested on localhost, it works as expected): $connString = ‘port=5432 dbname=test_database user=tester password=test_password’; $connHandler = pg_connect($connString); echo ‘Connected to ‘.pg_dbname($connHandler);

Security of REST authentication schemes

A previous answer only mentioned SSL in the context of data transfer and didn’t actually cover authentication. You’re really asking about securely authenticating REST API clients. Unless you’re using TLS client authentication, SSL alone is NOT a viable authentication mechanism for a REST API. SSL without client authc only authenticates the server, which is irrelevant … Read more

What is the difference between Digest and Basic Authentication?

Digest Authentication communicates credentials in an encrypted form by applying a hash function to: the username, the password, a server supplied nonce value, the HTTP method and the requested URI. Whereas Basic Authentication uses non-encrypted base64 encoding. Therefore, Basic Authentication should generally only be used where transport layer security is provided such as https. See … Read more

Configuration System Failed to Initialize

Make sure that your config file (web.config if web, or app.config if windows) in your project starts as: <?xml version=”1.0″?> <configuration> <configSections> <sectionGroup name=”applicationSettings” type=”System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089″ > <section name=”YourProjectName.Properties.Settings” type=”System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089″ requirePermission=”false” /> </sectionGroup> </configSections> </configuration> Note that inside the configuration element, the first child must be the configSections … Read more