Basic Authentication
Basic authentication uses the database "api_user" table to collect a valid username and password. Be aware that the password is stored in plain text.
Setup
-
Internet Information Services (IIS)
- In your IIS installation, locate and select the Safran Web API Site.
- Select the "Authentication" option.
- Set "Anonymous Authentication = "Enabled"
- All other to "Disabled"
- Select the "Authentication" option.
- In your IIS installation, locate and select the Safran Web API Site.
-
Within the appsettings.json file found in your file folder.
-
Ensure the "authentication type" setting is set to "Basic".
-
See Authentification type below.
-
-
Within the Safran Database
- Insert user and password into the "api_user" table of your Safran database, which the API is accessing.
- Notice that the API is no longer using the previous table named "user" since 25 June 2020.
Authentification Type
"AppSettings": {
"SafranWebApiAuthenticationType": "Basic",
...
}
Create database table, MS SQL
SQL command
USE [Safran]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[api_user](
[id] numeric(8,0) NOT NULL,
[username] nvarchar(50) NOT NULL,
[password] nvarchar(50) NOT NULL,
CONSTRAINT [pk_api_user] PRIMARY KEY CLUSTERED ([id] ASC)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
GRANT ALL ON api_user TO powerplan
GO
Add user to table, MS SQL
SQL command
use [Safran]
go
insert into dbo.[api_user] (id, username, password) values (1, 'safranwebapi', 'safran')
go
Create database table, Oracle
SQL command
create table API_USER (
ID number(8,0) not null,
USERNAME varchar2(50) not null,
PASSWORD varchar2(50) not null,
constraint PK_API_USER primary key (id)
)
tablespace safran_data;
grant all on API_USER to safran;
create public synonym API_USER for safransa.API_USER;
Add user to table, Oracle
SQL command
INSERT INTO API_USER (id, username, password) VALUES (1, 'safranwebapi', 'safran');