Friendly OAuth2 Server
Sign Up Sign In
Index Documentation Download Check license
Friendly oAuth2 server documentation
Friendly oAuth2 server documentation
Setup and running
Setup and running test version
Setup and running production version
Setup https protocol
Setup other database
Working with OAuth2 and OpenId Methods
OAuth2
OAuth2 code flow
OAuth2 implicit flow
OAuth2 user password flow
OAuth2 client credential flow
OAuth2 refresh token flow
OpenId
OpenId code flow
OpenId implicit flow
Client secret authentication
Client secret basic
Client secret post
Client secret jwt
Client key jwt
None
Extra
OAuth2 dynamic registration
OAuth2 revoke
OAuth2 introspect
OAuth2 jwks.json
OAuth2 .well-known
OAuth2 backchannel_logout
OAuth2 userinfo
Extra settings
Control panel
User section
User sessions 1
User sessions 2
User info
Change password
Delete account
Client section
List of registered clients
Number of authorizations per day
New client registration
Admin section
Client authorizations
Auth settings
Users
Clients
Administrators
Roles
Limits
Create user
Setting up and launching the enterprise version
1) If you have an enterprise edition distribution you will also need java 17 version or later. Therefore, follow step 1 from section 1.1. 2) You will also need to install PostgreSQL as a DBMS. For simplicity, you can use the docker containerization system and select image postgres:14.1-alpine. The contents of the docker-compose.yaml file should be something like:
version: '2.1' services: postgresql: image: postgres:14.1-alpine restart: always environment: - POSTGRES_USER=postgres - POSTGRES_PASSWORD=admin ports: - '5432:5432' expose: - '5432:5432' volumes: - ./postgresql/conf.sql:/docker-entrypoint-initdb.d/conf.sql - ./postgresql/data:/var/lib/postgresql/data
Next, create a postgresql folder and put the conf.sql, file in this folder, the contents of the file:
SELECT ' CREATE DATABASE oauth2server WITH OWNER = postgres ENCODING = "UTF8" LC_COLLATE = "en_US.utf8" LC_CTYPE = "en_US.utf8" TABLESPACE = pg_default CONNECTION LIMIT = -1; ' WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'oauth2server')\gexec \c oauth2server CREATE SCHEMA IF NOT EXISTS config AUTHORIZATION postgres; CREATE SCHEMA IF NOT EXISTS description AUTHORIZATION postgres; CREATE SCHEMA IF NOT EXISTS security AUTHORIZATION postgres; CREATE SCHEMA IF NOT EXISTS public AUTHORIZATION postgres; -- ####### config ####### CREATE TABLE IF NOT EXISTS config.limit_config ( client_maximum_number_of_valid_tokens integer, id boolean NOT NULL, user_maximum_number_of_clients integer, user_maximum_number_of_valid_codes integer, user_maximum_number_of_valid_tokens integer, client_access_token_validity_time bigint, client_open_id_token_validity_time bigint, client_refresh_token_validity_time bigint, CONSTRAINT limit_config_pkey PRIMARY KEY (id) ); CREATE TABLE IF NOT EXISTS config.metadata_config ( id boolean NOT NULL, logoico character varying(1000000) COLLATE pg_catalog."default", logopng180 character varying(1000000) COLLATE pg_catalog."default", logopng192 character varying(1000000) COLLATE pg_catalog."default", logopng512 character varying(1000000) COLLATE pg_catalog."default", logosvg character varying(1000000) COLLATE pg_catalog."default", server_name character varying(255) COLLATE pg_catalog."default", CONSTRAINT metadata_config_pkey PRIMARY KEY (id) ); CREATE TABLE IF NOT EXISTS config.server_config ( client_secret_basic boolean NOT NULL, client_secret_jwt boolean NOT NULL, client_secret_post boolean NOT NULL, deleting_user_account boolean NOT NULL, dynamic_registration boolean NOT NULL, enable_client_credentials_flow boolean NOT NULL, enable_code_flow boolean NOT NULL, enable_implicit_flow boolean NOT NULL, enable_open_id_implicit_flow boolean NOT NULL, enable_open_id_token boolean NOT NULL, enable_owner_password_flow boolean NOT NULL, enable_refresh_token boolean NOT NULL, enable_registration boolean NOT NULL, forgot_password boolean NOT NULL, id boolean NOT NULL, "none" boolean NOT NULL, private_key_jwt boolean NOT NULL, smtp_num_digits integer NOT NULL, verification_mail_code boolean NOT NULL, zone_offset character varying(6) COLLATE pg_catalog."default", private_key bytea, public_key bytea, public_key_exponent bytea, public_key_modulus bytea, algorithm_for_key character varying(255) COLLATE pg_catalog."default", issuer character varying(255) COLLATE pg_catalog."default", smtp_host character varying(255) COLLATE pg_catalog."default", smtp_password character varying(255) COLLATE pg_catalog."default", smtp_port character varying(255) COLLATE pg_catalog."default", smtp_username character varying(255) COLLATE pg_catalog."default", CONSTRAINT server_config_pkey PRIMARY KEY (id) ); -- ####### description ####### CREATE TABLE IF NOT EXISTS description.user_info ( id integer NOT NULL, user_entity_id integer, picture character varying(1000000) COLLATE pg_catalog."default", email character varying(255) COLLATE pg_catalog."default", family_name character varying(255) COLLATE pg_catalog."default", given_name character varying(255) COLLATE pg_catalog."default", name character varying(255) COLLATE pg_catalog."default", preferred_nsername character varying(255) COLLATE pg_catalog."default", CONSTRAINT user_info_pkey PRIMARY KEY (id), CONSTRAINT user_info_user_entity_id_key UNIQUE (user_entity_id) ); -- ####### security ####### CREATE TABLE IF NOT EXISTS security.admin_panel_forgot_password ( user_entity_id integer, expired timestamp(6) with time zone, id bigint NOT NULL, link character varying(255) COLLATE pg_catalog."default", CONSTRAINT admin_panel_forgot_password_pkey PRIMARY KEY (id), CONSTRAINT admin_panel_forgot_password_user_entity_id_key UNIQUE (user_entity_id) ); CREATE TABLE IF NOT EXISTS security.admin_panel_token ( user_entity_id integer, expires_in timestamp(6) with time zone, id bigint NOT NULL, one_per_request_code character varying(255) COLLATE pg_catalog."default", token character varying(255) COLLATE pg_catalog."default", CONSTRAINT admin_panel_token_pkey PRIMARY KEY (id), CONSTRAINT admin_panel_token_user_entity_id_key UNIQUE (user_entity_id) ); CREATE TABLE IF NOT EXISTS security.authorization_bearer_token ( client_entity_id_for_authorization_bearer_token integer, user_entity_id_for_authorization_bearer_token integer, token_type character varying(7) COLLATE pg_catalog."default", expires_in timestamp(6) with time zone, id bigint NOT NULL, open_id_token_expires_in timestamp(6) with time zone, refresh_token_expires_in timestamp(6) with time zone, session_creation_time timestamp(6) with time zone, open_id_token character varying(1000) COLLATE pg_catalog."default", access_token character varying(255) COLLATE pg_catalog."default", ip_address character varying(255) COLLATE pg_catalog."default", refresh_token character varying(255) COLLATE pg_catalog."default", user_agent character varying(255) COLLATE pg_catalog."default", CONSTRAINT authorization_bearer_token_pkey PRIMARY KEY (id), CONSTRAINT authorization_bearer_token_access_token_key UNIQUE (access_token), CONSTRAINT authorization_bearer_token_refresh_token_key UNIQUE (refresh_token) ); CREATE TABLE IF NOT EXISTS security.authorization_code ( authorization_code_token_id integer, client_entity_id integer, id integer NOT NULL, user_entity_id integer, expires timestamp(6) with time zone, code character varying(255) COLLATE pg_catalog."default", CONSTRAINT authorization_code_pkey PRIMARY KEY (id) ); CREATE TABLE IF NOT EXISTS security.client ( blocked boolean NOT NULL, client_for_user_id integer, id integer NOT NULL, client_id character varying(255) COLLATE pg_catalog."default", client_secret character varying(255) COLLATE pg_catalog."default", home_page character varying(255) COLLATE pg_catalog."default", img character varying(255) COLLATE pg_catalog."default", name character varying(255) COLLATE pg_catalog."default", redirect_urls character varying(255)[] COLLATE pg_catalog."default", CONSTRAINT client_pkey PRIMARY KEY (id) ); CREATE TABLE IF NOT EXISTS security.client_authentication_expired_token_id ( client_entity_id integer, id integer NOT NULL, jti character varying(255) COLLATE pg_catalog."default", CONSTRAINT client_authentication_expired_token_id_pkey PRIMARY KEY (id) ); CREATE TABLE IF NOT EXISTS security.client_keys ( client_keys_id integer, id bigint NOT NULL, client_key_jwt character varying(1024) COLLATE pg_catalog."default", client_own_private_key_jwt character varying(1024) COLLATE pg_catalog."default", client_private_key_jwt character varying(1024) COLLATE pg_catalog."default", private_key bytea, public_key bytea, CONSTRAINT client_keys_pkey PRIMARY KEY (id), CONSTRAINT client_keys_client_keys_id_key UNIQUE (client_keys_id) ); CREATE TABLE IF NOT EXISTS security.client_num_auth ( client_entity_id integer, count integer, date date, version integer, id bigint NOT NULL, CONSTRAINT client_num_auth_pkey PRIMARY KEY (id) ); CREATE TABLE IF NOT EXISTS security.scope ( id integer NOT NULL, description character varying(255) COLLATE pg_catalog."default", name character varying(255) COLLATE pg_catalog."default", CONSTRAINT scope_pkey PRIMARY KEY (id) ); CREATE TABLE IF NOT EXISTS security.token_for_login_form ( client_entity_id integer, current_redirect_url character varying(255) COLLATE pg_catalog."default", response_type character varying(255) COLLATE pg_catalog."default", scope character varying(255) COLLATE pg_catalog."default", state character varying(255) COLLATE pg_catalog."default", token_for_login_form character varying(255) COLLATE pg_catalog."default" NOT NULL, CONSTRAINT token_for_login_form_pkey PRIMARY KEY (token_for_login_form) ); CREATE TABLE IF NOT EXISTS security."user" ( blocked boolean NOT NULL, id integer NOT NULL, user_info_id integer, password character varying(255) COLLATE pg_catalog."default", username character varying(255) COLLATE pg_catalog."default", CONSTRAINT user_pkey PRIMARY KEY (id), CONSTRAINT user_user_info_id_key UNIQUE (user_info_id) ); CREATE TABLE IF NOT EXISTS security.user_auth_code ( user_entity_id integer, expires_in timestamp(6) with time zone, id bigint NOT NULL, anonim_email character varying(255) COLLATE pg_catalog."default", code character varying(255) COLLATE pg_catalog."default", CONSTRAINT user_auth_code_pkey PRIMARY KEY (id) ); -- ####### security ####### CREATE TABLE IF NOT EXISTS public.client_client_authentication_expired_token_id_entities ( client_authentication_expired_token_id_entities_id integer NOT NULL, client_entity_id integer NOT NULL, CONSTRAINT client_client_authentication_expired_token_id_entities_pkey PRIMARY KEY (client_authentication_expired_token_id_entities_id, client_entity_id), CONSTRAINT client_client_authentication__client_authentication_expired_key UNIQUE (client_authentication_expired_token_id_entities_id) ); CREATE TABLE IF NOT EXISTS public.client_token_for_login_form_entities ( client_entity_id integer NOT NULL, token_for_login_form_entities_token_for_login_form character varying(255) COLLATE pg_catalog."default" NOT NULL, CONSTRAINT client_token_for_login_form_entities_pkey PRIMARY KEY (client_entity_id, token_for_login_form_entities_token_for_login_form), CONSTRAINT client_token_for_login_form_e_token_for_login_form_entities_key UNIQUE (token_for_login_form_entities_token_for_login_form) ); CREATE TABLE IF NOT EXISTS public.scope_user_entities ( scope_entity_id integer NOT NULL, user_entities_id integer NOT NULL, CONSTRAINT scope_user_entities_pkey PRIMARY KEY (scope_entity_id, user_entities_id) ); CREATE TABLE IF NOT EXISTS public.user_scopes_set ( scopes_set_id integer NOT NULL, user_entity_id integer NOT NULL, CONSTRAINT user_scopes_set_pkey PRIMARY KEY (scopes_set_id, user_entity_id) ); ALTER TABLE description.user_info ADD CONSTRAINT fk5k3pb35revxi1mde30obn8m8e FOREIGN KEY (user_entity_id) REFERENCES security."user" (id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION; ALTER TABLE security.admin_panel_forgot_password ADD CONSTRAINT fkf8sknh2mg2vs454tj94121b60 FOREIGN KEY (user_entity_id) REFERENCES security."user" (id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION; ALTER TABLE security.admin_panel_token ADD CONSTRAINT fk7amfjh24p77cicxici235g4y FOREIGN KEY (user_entity_id) REFERENCES security."user" (id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION; ALTER TABLE security.authorization_bearer_token ADD CONSTRAINT fkavpkact4x06e7l90qxiwwobcj FOREIGN KEY (client_entity_id_for_authorization_bearer_token) REFERENCES security.client (id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE SET NULL; ALTER TABLE security.authorization_bearer_token ADD CONSTRAINT fkokr86vn649wbvp9df6b54iye6 FOREIGN KEY (user_entity_id_for_authorization_bearer_token) REFERENCES security."user" (id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE SET NULL; ALTER TABLE security.authorization_code ADD CONSTRAINT fk6b7kawphr4igiq2c77bmfuntp FOREIGN KEY (authorization_code_token_id) REFERENCES security."user" (id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE SET NULL; ALTER TABLE security.authorization_code ADD CONSTRAINT fkd63u6tnbl3vslsyss5lakl1kk FOREIGN KEY (user_entity_id) REFERENCES security."user" (id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION; ALTER TABLE security.authorization_code ADD CONSTRAINT fkk5igqnpcpjmjl9w9vf5isxn7e FOREIGN KEY (client_entity_id) REFERENCES security.client (id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION; ALTER TABLE security.client ADD CONSTRAINT fkq2w8ys67uqllosbb4byorf2oe FOREIGN KEY (client_for_user_id) REFERENCES security."user" (id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE SET NULL; ALTER TABLE security.client_authentication_expired_token_id ADD CONSTRAINT fkh9wwh5ilburplqyh04ibipxqi FOREIGN KEY (client_entity_id) REFERENCES security.client (id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION; ALTER TABLE security.client_keys ADD CONSTRAINT fkqtaibad6lqu3b5sw11qumwouh FOREIGN KEY (client_keys_id) REFERENCES security.client (id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE SET NULL; ALTER TABLE security.client_num_auth ADD CONSTRAINT fkbwt0ov0pn8r984c5tmk0rn684 FOREIGN KEY (client_entity_id) REFERENCES security.client (id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION; ALTER TABLE security.token_for_login_form ADD CONSTRAINT fkmg8jtl4i4a3bsc2r0h2ee6089 FOREIGN KEY (client_entity_id) REFERENCES security.client (id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION; ALTER TABLE security."user" ADD CONSTRAINT fkh98qmq3hqffkhv8pw266v2vb4 FOREIGN KEY (user_info_id) REFERENCES description.user_info (id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION; ALTER TABLE security.user_auth_code ADD CONSTRAINT fkd5of9tapkq4ni1s93t3evtm8m FOREIGN KEY (user_entity_id) REFERENCES security."user" (id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION; ALTER TABLE public.client_client_authentication_expired_token_id_entities ADD CONSTRAINT fk3b6c0db00nposwq5p75oihl1o FOREIGN KEY (client_authentication_expired_token_id_entities_id) REFERENCES security.client_authentication_expired_token_id (id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION; ALTER TABLE public.client_client_authentication_expired_token_id_entities ADD CONSTRAINT fk5aebgc6fjk6n99dc12htb8dlg FOREIGN KEY (client_entity_id) REFERENCES security.client (id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION; ALTER TABLE public.client_token_for_login_form_entities ADD CONSTRAINT fk32ddmm78o89c0aups6wq1e56l FOREIGN KEY (client_entity_id) REFERENCES security.client (id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION; ALTER TABLE public.client_token_for_login_form_entities ADD CONSTRAINT fk3wrve7tbun91pxmmm089belui FOREIGN KEY (token_for_login_form_entities_token_for_login_form) REFERENCES security.token_for_login_form (token_for_login_form) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION; ALTER TABLE public.scope_user_entities ADD CONSTRAINT fko70qi78km4qqky5xng9y24gvc FOREIGN KEY (scope_entity_id) REFERENCES security.scope (id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION; ALTER TABLE public.scope_user_entities ADD CONSTRAINT fksjdb9lhqg4spwbqg7yyesxj4t FOREIGN KEY (user_entities_id) REFERENCES security."user" (id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION; ALTER TABLE public.user_scopes_set ADD CONSTRAINT fk6o5rxsshxogwrrh29myavpwr9 FOREIGN KEY (user_entity_id) REFERENCES security."user" (id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION; ALTER TABLE public.user_scopes_set ADD CONSTRAINT fkqv743tpxuxfcvabjcvtlyc3d8 FOREIGN KEY (scopes_set_id) REFERENCES security.scope (id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION;
3) Create and launch a docker container using the commands: docker-compose build docker-compose up 4) Go to the folder where you have the server jar file and license file.
5) Log in to the console and start the authorization server using command java -jar ./oauth2-server-prod-30.jar
6) Open your browser and follow the link http://localhost:9000. You should see a login form. Register your account.
7) Install and open pgAdmin 4 and connect to database oauth2server. You should see 3 roles in table security.scope and the created user in table security."user"
Assign your user the administrator role in table public.scope_user_entities
8) Log in to the admin panel using the password and login of the created user. The server has started successfully.
Friendly OAuth2 Server
prodmicroservice.com
2024