Skip to content

Instantly share code, notes, and snippets.

@menakaj
menakaj / CertificateGenerator.java
Created February 14, 2023 12:21
SSL Certificate generator
package org.example;
import org.bouncycastle.asn1.x500.X500Name;
import org.bouncycastle.cert.jcajce.JcaX509CertificateConverter;
import org.bouncycastle.cert.jcajce.JcaX509v3CertificateBuilder;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.operator.ContentSigner;
import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder;
import org.bouncycastle.util.io.pem.PemObject;
import org.bouncycastle.util.io.pem.PemWriter;
{
"sub": "admin",
"iss": "https://localhost:9095/apikey",
"iat": 1595152875,
"jti": "22362268-e74a-44de-ac9c-2c3ae71653b9",
"keytype": "PRODUCTION",
"allowedAPIs": [
{
"name": "PizzaShackAPI",
"version": "1.0.0"
@menakaj
menakaj / tokenconfig.toml
Created July 19, 2020 10:06
TokenConfig
# The API Key authentication settings.
[apikey.tokenConfigs]
issuer="https://localhost:9095/apikey"
audience="http://org.wso2.apimgt/gateway"
certificateAlias="ballerina"
# Validate the Allowed APIs.
validateAllowedAPIs=true
[apikey.issuer]
[apikey.issuer.tokenConfig]
@menakaj
menakaj / petstore.yaml
Created July 19, 2020 08:43
Change API Key header name.
securityDefinitions:
petstore_auth:
...
api_key:
type: "apiKey"
name: "petstore_key" # Change the header name
in: "header"
@menakaj
menakaj / applyingApiKey.yaml
Created July 19, 2020 08:03
ApplyingAPIKey
# Resource Level
paths:
"/*":
get:
responses:
'200':
description: OK
x-wso2-application-security:
security-types:
- apiKey
@menakaj
menakaj / securityScheme.yaml
Last active July 19, 2020 08:17
Security Scheme Configuration
...
components:
securitySchemes:
apiKey:
type: apiKey
in: header # Can be header or query
name: X-API-KEY # Can be any name
...
@menakaj
menakaj / api_key_issuer.toml
Created July 19, 2020 05:02
API Key Issuer Config
# API Key Security Token Service(STS) configurations
[apikey.issuer]
# API Key STS token configurations
[apikey.issuer.tokenConfig]
enabled=true
keyStorePath="${mgw-runtime.home}/runtime/bre/security/ballerinaKeystore.p12"
keyStorePassword="ballerina"
issuer="https://localhost:9095/apikey"
certificateAlias="ballerina"
# validity time in seconds for the API Key. -1 is to indicate unlimited time
<payloadFactory media-type="xml">
<format>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<root xmlns="">
<grant_type>client_credentials</grant_type>
<scope>demo_scope</scope>
</root>
</soapenv:Body>
</soapenv:Envelope>
#swagger-editor {
font-size: 1.3em;
}
.container {
height: 100%;
max-width: 880px;
margin-left: auto;
margin-right: auto;
}
logContent() {
const content = window.localStorage.getItem('swagger-editor-content');
console.log(content);
}