You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

ciu-parser

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ciu-parser

A library to parse credential-in-url and convert them to database connection urls

1.0.0
Source
nugetNuGet
Version published
Maintainers
1
Created
Source

dotnet-credentials-in-url-parser

This package replaces both PostgresConnString.NET and mongo-url-parser as they are very basic packages.

It aims to grant general .NET support for parsing and converting urls in the form "scheme://user:password@host:port/database?connectionparameters" also known as Credential-In-Url and converting it to formats easily used by the database service providers for .NET.

Installation

You can install the package from nuget

Install-Package ciu-parser

or

dotnet add package ciu-parser

or for paket

paket add ciu-parser

Usage

Parsing Urls

To parse a url

using CredentialsInUrlParser;
...
var details = CIU.Parse("postgres://someuser:somepassword@somehost:381/somedatabase");

The resulting details contains a subset of the following properties:

  • Scheme - Database server scheme
  • HostName - Database server hostname
  • Port - port on which to connect
  • UserName - User with which to authenticate to the server
  • Password - Corresponding password
  • DatabasePath - Database name within the server
  • AdditionalQueryParameters - Additional database parameters provided as query options

Exports

Currently, this library allows for generating an Npgsql compatible connection strings. With the following parameters

  • pooling: type: boolean, default: true
  • trustServerCertificate: type: boolean, default: true
  • sslMode: type: enum, default: Prefer
using CredentialsInUrlParser;
...
var details = CIU.Parse("postgres://someuser:somepassword@somehost:381/somedatabase");
var connString = details.ToNpgsqlSConnectionString(); //User ID=someuser;Password=somepassword;Server=somehost;Port=381;Database=somedatabase;Pooling=true;SSL Mode=Prefer;Trust Server Certificate=true

This library also allows for generating a MongoDB compatible connection string and database name.

using CredentialsInUrlParser;
...
var details = CIU.Parse("mongodb://user:password@host:port/database-name?otheroptions");
var (dbUrl, dbName)  = details.ToMongoConnectionSplit(); 
// dbUrl: mongodb://user:password@host:port?otheroptions
// dbName: database-name

Contributing

Feel free to make requests and to open P=pull requests with fixes and updates.

Keywords

postgres

FAQs

Package last updated on 20 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts