gate-sso / gate

Gate is MFA Enabled SSO Platform that supports SAML, OAuth, Linux shell login and CAS
https://gate-sso.github.io
MIT License
203 stars 53 forks source link

Calls to /nss/host are not idempotent #118

Closed vjdhama closed 6 years ago

vjdhama commented 6 years ago

API calls to register new host are not idempotent. Example:

For payload

{
    "name": "server01",
    "token": "dd3a5w2",
    "group_name": "admin"
}

Response to first call is:

{
    "success": true,
    "access_key": "mo5bm2sc",
    "host": "svr01",
    "groups": [
        "admin",
        "server01_host_group",
    ]
}

and response to second call is:

{
    "success": true,
    "access_key": "sa35v20a",
    "host": "svr01",
    "groups": [
        "admin",
        "admin",
        "server01_host_group",
        "server01_host_group",
    ]
}
ajeygore commented 6 years ago

Fixed with #1a0da5d We weren't creating group twice, but we were adding group twice, now we check if the group exist in host groups then don't add it again.