package
0.6.0
Repository: https://github.com/alwitt/padlock.git
Documentation: pkg.go.dev

# README


title: padlock v0.3.0 language_tabs:

  • shell: Shell
  • http: HTTP
  • javascript: JavaScript
  • ruby: Ruby
  • python: Python
  • php: PHP
  • java: Java
  • go: Go toc_footers: [] includes: [] search: false code_clipboard: true highlight_theme: darkula headingLevel: 2 generator: widdershins v4.0.1

padlock v0.3.0

Scroll down for code samples, example requests and responses. Select a language for code samples from the tabs above or the mobile navigation menu.

External AuthN / AuthZ support service for REST API RBAC

Base URLs:

Management

User Management API liveness check

GET /v1/alive

Will return success to indicate user management REST API module is live

Parameters

NameInTypeRequiredDescription
Padlock-Request-IDheaderstringfalseUser provided request ID to match against logs

Example responses

200 Response

{
  "error": {
    "code": 0,
    "detail": "string",
    "message": "string"
  },
  "request_id": "string",
  "success": true
}

Responses

StatusMeaningDescriptionSchema
200OKsuccessgoutils.RestAPIBaseResponse
400Bad Requesterrorgoutils.RestAPIBaseResponse
404Not Founderrorstring
500Internal Server Errorerrorgoutils.RestAPIBaseResponse
This operation does not require authentication

User Management API readiness check

GET /v1/ready

Will return success if user management REST API module is ready for use

Parameters

NameInTypeRequiredDescription
Padlock-Request-IDheaderstringfalseUser provided request ID to match against logs

Example responses

200 Response

{
  "error": {
    "code": 0,
    "detail": "string",
    "message": "string"
  },
  "request_id": "string",
  "success": true
}

Responses

StatusMeaningDescriptionSchema
200OKsuccessgoutils.RestAPIBaseResponse
400Bad Requesterrorgoutils.RestAPIBaseResponse
404Not Founderrorstring
500Internal Server Errorerrorgoutils.RestAPIBaseResponse
This operation does not require authentication

List All Roles

GET /v1/role

List all roles the system is operating against

Parameters

NameInTypeRequiredDescription
Padlock-Request-IDheaderstringfalseUser provided request ID to match against logs

Example responses

200 Response

{
  "error": {
    "code": 0,
    "detail": "string",
    "message": "string"
  },
  "request_id": "string",
  "roles": {
    "property1": {
      "permissions": [
        "string"
      ]
    },
    "property2": {
      "permissions": [
        "string"
      ]
    }
  },
  "success": true
}

Responses

StatusMeaningDescriptionSchema
200OKsuccessapis.RespListAllRoles
400Bad Requesterrorgoutils.RestAPIBaseResponse
404Not Founderrorstring
500Internal Server Errorerrorgoutils.RestAPIBaseResponse
This operation does not require authentication

Get info on role

GET /v1/role/{roleName}

Query for information regarding one role, along with users assigned this role.

Parameters

NameInTypeRequiredDescription
Padlock-Request-IDheaderstringfalseUser provided request ID to match against logs
roleNamepathstringtrueRole name

Example responses

200 Response

{
  "assigned_users": [
    {
      "created_at": "string",
      "email": "string",
      "first_name": "string",
      "last_name": "string",
      "updated_at": "string",
      "user_id": "string",
      "username": "string"
    }
  ],
  "error": {
    "code": 0,
    "detail": "string",
    "message": "string"
  },
  "request_id": "string",
  "role": {
    "permissions": [
      "string"
    ]
  },
  "success": true
}

Responses

StatusMeaningDescriptionSchema
200OKsuccessapis.RespRoleInfo
400Bad Requesterrorgoutils.RestAPIBaseResponse
404Not Founderrorstring
500Internal Server Errorerrorgoutils.RestAPIBaseResponse
This operation does not require authentication

List all users

GET /v1/user

List all users currently managed by the system

Parameters

NameInTypeRequiredDescription
Padlock-Request-IDheaderstringfalseUser provided request ID to match against logs

Example responses

200 Response

{
  "error": {
    "code": 0,
    "detail": "string",
    "message": "string"
  },
  "request_id": "string",
  "success": true,
  "users": [
    {
      "created_at": "string",
      "email": "string",
      "first_name": "string",
      "last_name": "string",
      "updated_at": "string",
      "user_id": "string",
      "username": "string"
    }
  ]
}

Responses

StatusMeaningDescriptionSchema
200OKsuccessapis.RespListAllUsers
400Bad Requesterrorgoutils.RestAPIBaseResponse
404Not Founderrorstring
500Internal Server Errorerrorgoutils.RestAPIBaseResponse
This operation does not require authentication

Define new user

POST /v1/user

Define a new user, and optionally assign roles to it

Body parameter

{
  "roles": [
    "string"
  ],
  "user": {
    "email": "string",
    "first_name": "string",
    "last_name": "string",
    "user_id": "string",
    "username": "string"
  }
}

Parameters

NameInTypeRequiredDescription
Padlock-Request-IDheaderstringfalseUser provided request ID to match against logs
bodybodyapis.ReqNewUserParamstrueNew user information

Example responses

200 Response

{
  "error": {
    "code": 0,
    "detail": "string",
    "message": "string"
  },
  "request_id": "string",
  "success": true
}

Responses

StatusMeaningDescriptionSchema
200OKsuccessgoutils.RestAPIBaseResponse
400Bad Requesterrorgoutils.RestAPIBaseResponse
404Not Founderrorstring
500Internal Server Errorerrorgoutils.RestAPIBaseResponse
This operation does not require authentication

Delete user

DELETE /v1/user/{userID}

Remove user from the system.

Parameters

NameInTypeRequiredDescription
Padlock-Request-IDheaderstringfalseUser provided request ID to match against logs
userIDpathstringtrueUser ID

Example responses

200 Response

{
  "error": {
    "code": 0,
    "detail": "string",
    "message": "string"
  },
  "request_id": "string",
  "success": true
}

Responses

StatusMeaningDescriptionSchema
200OKsuccessgoutils.RestAPIBaseResponse
400Bad Requesterrorgoutils.RestAPIBaseResponse
404Not Founderrorstring
500Internal Server Errorerrorgoutils.RestAPIBaseResponse
This operation does not require authentication

Get info on user

GET /v1/user/{userID}

Query for information regarding one user.

Parameters

NameInTypeRequiredDescription
Padlock-Request-IDheaderstringfalseUser provided request ID to match against logs
userIDpathstringtrueUser ID

Example responses

200 Response

{
  "error": {
    "code": 0,
    "detail": "string",
    "message": "string"
  },
  "request_id": "string",
  "success": true,
  "user": {
    "associatedPermission": [
      "string"
    ],
    "created_at": "string",
    "email": "string",
    "first_name": "string",
    "last_name": "string",
    "roles": [
      "string"
    ],
    "updated_at": "string",
    "user_id": "string",
    "username": "string"
  }
}

Responses

StatusMeaningDescriptionSchema
200OKsuccessapis.RespUserInfo
400Bad Requesterrorgoutils.RestAPIBaseResponse
404Not Founderrorstring
500Internal Server Errorerrorgoutils.RestAPIBaseResponse
This operation does not require authentication

Update a user's info

PUT /v1/user/{userID}

Update an existing user's information

Body parameter

{
  "email": "string",
  "first_name": "string",
  "last_name": "string",
  "user_id": "string",
  "username": "string"
}

Parameters

NameInTypeRequiredDescription
Padlock-Request-IDheaderstringfalseUser provided request ID to match against logs
userIDpathstringtrueUser ID
bodybodymodels.UserConfigtrueUpdated user information

Example responses

200 Response

{
  "error": {
    "code": 0,
    "detail": "string",
    "message": "string"
  },
  "request_id": "string",
  "success": true
}

Responses

StatusMeaningDescriptionSchema
200OKsuccessgoutils.RestAPIBaseResponse
400Bad Requesterrorgoutils.RestAPIBaseResponse
404Not Founderrorstring
500Internal Server Errorerrorgoutils.RestAPIBaseResponse
This operation does not require authentication

Update a user's roles

PUT /v1/user/{userID}/roles

Change the user's roles to what caller requested

Body parameter

{
  "roles": [
    "string"
  ]
}

Parameters

NameInTypeRequiredDescription
Padlock-Request-IDheaderstringfalseUser provided request ID to match against logs
userIDpathstringtrueUser ID
bodybodyapis.ReqNewUserRolestrueUser's new roles

Example responses

200 Response

{
  "error": {
    "code": 0,
    "detail": "string",
    "message": "string"
  },
  "request_id": "string",
  "success": true
}

Responses

StatusMeaningDescriptionSchema
200OKsuccessgoutils.RestAPIBaseResponse
400Bad Requesterrorgoutils.RestAPIBaseResponse
404Not Founderrorstring
500Internal Server Errorerrorgoutils.RestAPIBaseResponse
This operation does not require authentication

Authorize

Check whether a REST API call is allowed

GET /v1/allow

Check whether a REST API call is allowed. The parameters of the call is passed in

Parameters

NameInTypeRequiredDescription
Padlock-Request-IDheaderstringfalseUser provided request ID to match against logs
X-Forwarded-HostheaderstringtrueHost of the API call to authorize
X-Forwarded-UriheaderstringtrueURI path of the API call to authorize
X-Forwarded-MethodheaderstringtrueHTTP method of the API call to authorize
X-Caller-UserIDheaderstringtrueID of the user making the API call to authorize
X-Caller-UsernameheaderstringfalseUsername of the user making the API call to authorize
X-Caller-FirstnameheaderstringfalseFirst name / given name of the user making the API call to authorize
X-Caller-LastnameheaderstringfalseLast name / surname / family name of the user making the API call to authorize
X-Caller-EmailheaderstringfalseEmail of the user making the API call to authorize

Example responses

200 Response

{
  "error": {
    "code": 0,
    "detail": "string",
    "message": "string"
  },
  "request_id": "string",
  "success": true
}

Responses

StatusMeaningDescriptionSchema
200OKsuccessgoutils.RestAPIBaseResponse
400Bad Requesterrorgoutils.RestAPIBaseResponse
403Forbiddenerrorgoutils.RestAPIBaseResponse
404Not Founderrorstring
500Internal Server Errorerrorgoutils.RestAPIBaseResponse
This operation does not require authentication

Authenticate

Authenticate a user

GET /v1/authenticate

Authticate a user by verifiying the bearer token provided

Parameters

NameInTypeRequiredDescription
Padlock-Request-IDheaderstringfalseUser provided request ID to match against logs
AuthorizationheaderstringtrueUser must provide a bearer token

Example responses

200 Response

{
  "error": {
    "code": 0,
    "detail": "string",
    "message": "string"
  },
  "request_id": "string",
  "success": true
}

Responses

StatusMeaningDescriptionSchema
200OKsuccessgoutils.RestAPIBaseResponse
400Bad Requesterrorgoutils.RestAPIBaseResponse
401Unauthorizederrorstring
403Forbiddenerrorstring
404Not Founderrorstring
500Internal Server Errorerrorgoutils.RestAPIBaseResponse
This operation does not require authentication

Schemas

apis.ReqNewUserParams

{
  "roles": [
    "string"
  ],
  "user": {
    "email": "string",
    "first_name": "string",
    "last_name": "string",
    "user_id": "string",
    "username": "string"
  }
}

Properties

NameTypeRequiredRestrictionsDescription
roles[string]falsenoneRoles list the roles to assign to this user
usermodels.UserConfigtruenoneUser contains the new user parameters

apis.ReqNewUserRoles

{
  "roles": [
    "string"
  ]
}

Properties

NameTypeRequiredRestrictionsDescription
roles[string]falsenoneRoles list the roles to assign to this user

apis.RespListAllRoles

{
  "error": {
    "code": 0,
    "detail": "string",
    "message": "string"
  },
  "request_id": "string",
  "roles": {
    "property1": {
      "permissions": [
        "string"
      ]
    },
    "property2": {
      "permissions": [
        "string"
      ]
    }
  },
  "success": true
}

Properties

NameTypeRequiredRestrictionsDescription
errorgoutils.ErrorDetailfalsenoneError are details in case of errors
request_idstringtruenoneRequestID gives the request ID to match against logs
rolesobjecttruenoneRoles are the roles
» additionalPropertiescommon.UserRoleConfigfalsenonenone
successbooleantruenoneSuccess indicates whether the request was successful

apis.RespListAllUsers

{
  "error": {
    "code": 0,
    "detail": "string",
    "message": "string"
  },
  "request_id": "string",
  "success": true,
  "users": [
    {
      "created_at": "string",
      "email": "string",
      "first_name": "string",
      "last_name": "string",
      "updated_at": "string",
      "user_id": "string",
      "username": "string"
    }
  ]
}

Properties

NameTypeRequiredRestrictionsDescription
errorgoutils.ErrorDetailfalsenoneError are details in case of errors
request_idstringtruenoneRequestID gives the request ID to match against logs
successbooleantruenoneSuccess indicates whether the request was successful
users[models.UserInfo]truenoneUsers are the users in system

apis.RespRoleInfo

{
  "assigned_users": [
    {
      "created_at": "string",
      "email": "string",
      "first_name": "string",
      "last_name": "string",
      "updated_at": "string",
      "user_id": "string",
      "username": "string"
    }
  ],
  "error": {
    "code": 0,
    "detail": "string",
    "message": "string"
  },
  "request_id": "string",
  "role": {
    "permissions": [
      "string"
    ]
  },
  "success": true
}

Properties

NameTypeRequiredRestrictionsDescription
assigned_users[models.UserInfo]falsenoneAssignedUsers is the list of users being assigned this role
errorgoutils.ErrorDetailfalsenoneError are details in case of errors
request_idstringtruenoneRequestID gives the request ID to match against logs
rolecommon.UserRoleConfigtruenoneRole is info on this role
successbooleantruenoneSuccess indicates whether the request was successful

apis.RespUserInfo

{
  "error": {
    "code": 0,
    "detail": "string",
    "message": "string"
  },
  "request_id": "string",
  "success": true,
  "user": {
    "associatedPermission": [
      "string"
    ],
    "created_at": "string",
    "email": "string",
    "first_name": "string",
    "last_name": "string",
    "roles": [
      "string"
    ],
    "updated_at": "string",
    "user_id": "string",
    "username": "string"
  }
}

Properties

NameTypeRequiredRestrictionsDescription
errorgoutils.ErrorDetailfalsenoneError are details in case of errors
request_idstringtruenoneRequestID gives the request ID to match against logs
successbooleantruenoneSuccess indicates whether the request was successful
userusers.UserDetailsWithPermissiontruenoneUser is info on this user

common.UserRoleConfig

{
  "permissions": [
    "string"
  ]
}

Properties

NameTypeRequiredRestrictionsDescription
permissions[string]truenoneAssignedPermissions is the list of permissions assigned to a role

goutils.ErrorDetail

{
  "code": 0,
  "detail": "string",
  "message": "string"
}

Properties

NameTypeRequiredRestrictionsDescription
codeintegertruenoneCode is the response code
detailstringfalsenoneDetail is an optional descriptive message providing additional details on the error
messagestringfalsenoneMsg is an optional descriptive message

goutils.RestAPIBaseResponse

{
  "error": {
    "code": 0,
    "detail": "string",
    "message": "string"
  },
  "request_id": "string",
  "success": true
}

Properties

NameTypeRequiredRestrictionsDescription
errorgoutils.ErrorDetailfalsenoneError are details in case of errors
request_idstringtruenoneRequestID gives the request ID to match against logs
successbooleantruenoneSuccess indicates whether the request was successful

models.UserConfig

{
  "email": "string",
  "first_name": "string",
  "last_name": "string",
  "user_id": "string",
  "username": "string"
}

Properties

NameTypeRequiredRestrictionsDescription
emailstringfalsenoneEmail is the user's email
first_namestringfalsenoneFirstName is the user's first name / given name
last_namestringfalsenoneLastName is the user's last name / surname / family name
user_idstringtruenoneUserID is the user's ID
usernamestringfalsenoneUserName is the username

models.UserInfo

{
  "created_at": "string",
  "email": "string",
  "first_name": "string",
  "last_name": "string",
  "updated_at": "string",
  "user_id": "string",
  "username": "string"
}

Properties

NameTypeRequiredRestrictionsDescription
created_atstringfalsenoneCreatedAt is when the user entry is created
emailstringfalsenoneEmail is the user's email
first_namestringfalsenoneFirstName is the user's first name / given name
last_namestringfalsenoneLastName is the user's last name / surname / family name
updated_atstringfalsenoneUpdatedAt is when the user entry was last updated
user_idstringtruenoneUserID is the user's ID
usernamestringfalsenoneUserName is the username

users.UserDetailsWithPermission

{
  "associatedPermission": [
    "string"
  ],
  "created_at": "string",
  "email": "string",
  "first_name": "string",
  "last_name": "string",
  "roles": [
    "string"
  ],
  "updated_at": "string",
  "user_id": "string",
  "username": "string"
}

Properties

NameTypeRequiredRestrictionsDescription
associatedPermission[string]falsenoneAssociatedPermission list of permissions the user has based on the roles associated with
the user
created_atstringfalsenoneCreatedAt is when the user entry is created
emailstringfalsenoneEmail is the user's email
first_namestringfalsenoneFirstName is the user's first name / given name
last_namestringfalsenoneLastName is the user's last name / surname / family name
roles[string]falsenoneRoles are the roles associated with the user
updated_atstringfalsenoneUpdatedAt is when the user entry was last updated
user_idstringtruenoneUserID is the user's ID
usernamestringfalsenoneUserName is the username