Buscar contenidos

jueves, 21 de febrero de 2019

Pasos para integración con Azure AD, GraphAPI










Home>dev2tenant - App registrations (Preview)>AutenticacionAzureADGraph - Manifest

{
    "id": "cc8f5c11-0494-4af2-b4a9-699f438f1404",
    "acceptMappedClaims": null,
    "accessTokenAcceptedVersion": null,
    "allowPublicClient": null,
    "appId": "0183d6e2-2f4d-48c3-bf68-5876eba118ca",
    "appRoles": [
        {
            "allowedMemberTypes": [
                "User"
            ],
            "description": "Admins can manage roles and perform all task actions.",
            "displayName": "Admin",
            "id": "81e10148-16a8-432a-b86d-ef620c3e48ef",
            "isEnabled": true,
            "lang": null,
            "origin": "Application",
            "value": "Admin"
        },
        {
            "allowedMemberTypes": [
                "User"
            ],
            "description": "Approvers have the ability to change the status of tasks.",
            "displayName": "Approver",
            "id": "fc803414-3c61-4ebc-a5e5-cd1675c14bbb",
            "isEnabled": true,
            "lang": null,
            "origin": "Application",
            "value": "Approver"
        },
        {
            "allowedMemberTypes": [
                "User"
            ],
            "description": "Observers only have the ability to view tasks and their statuses.",
            "displayName": "Observer",
            "id": "fcac0bdb-e45d-4cfc-9733-fbea156da358",
            "isEnabled": true,
            "lang": null,
            "origin": "Application",
            "value": "Observer"
        },
        {
            "allowedMemberTypes": [
                "User"
            ],
            "description": "Writers Have the ability to create tasks.",
            "displayName": "Writer",
            "id": "d1c2ade8-98f8-45fd-aa4a-6d06b947c66f",
            "isEnabled": true,
            "lang": null,
            "origin": "Application",
            "value": "Writer"
        }
    ],
    "oauth2AllowUrlPathMatching": false,
    "createdDateTime": "2019-02-20T20:38:01Z",
    "groupMembershipClaims": "SecurityGroup",
    "identifierUris": [],
    "informationalUrls": {
        "termsOfService": null,
        "support": null,
        "privacy": null,
        "marketing": null
    },
    "keyCredentials": [],
    "knownClientApplications": [],
    "logoUrl": null,
    "logoutUrl": null,
    "name": "AutenticacionAzureADGraph",
    "oauth2AllowIdTokenImplicitFlow": true,
    "oauth2AllowImplicitFlow": true,
    "oauth2Permissions": [],
    "oauth2RequirePostResponse": false,
    "optionalClaims": {
        "idToken": [
            {
                "name": "ctry",
                "source": null,
                "essential": false,
                "additionalProperties": []
            }
        ],
        "accessToken": [
            {
                "name": "ipaddr",
                "source": null,
                "essential": false,
                "additionalProperties": []
            }
        ],
        "saml2Token": [
            {
                "name": "upn",
                "source": null,
                "essential": false,
                "additionalProperties": []
            },
            {
                "name": "extension_ab603c56068041afb2f6832e2a17e237_skypeId",
                "source": "user",
                "essential": false,
                "additionalProperties": []
            }
        ]
    },
    "orgRestrictions": [],
    "parentalControlSettings": {
        "countriesBlockedForMinors": [],
        "legalAgeGroupRule": "Allow"
    },
    "passwordCredentials": [
        {
            "customKeyIdentifier": null,
            "endDate": "2299-12-31T06:00:00Z",
            "keyId": "1c6956c7-34bb-462c-90e4-580d50e29d20",
            "startDate": "2019-02-20T20:40:36.253Z",
            "value": null,
            "createdOn": "2019-02-20T20:42:32.5794059Z",
            "hint": "/|s",
            "displayName": "Password uploaded on Wed Feb 20 2019"
        }
    ],
    "preAuthorizedApplications": [],
    "publisherDomain": "dev2tenant.onmicrosoft.com",
    "replyUrlsWithType": [],
    "requiredResourceAccess": [
        {
            "resourceAppId": "00000003-0000-0000-c000-000000000000",
            "resourceAccess": [
                {
                    "id": "06da0dbc-49e2-44d2-8312-53f166ab848a",
                    "type": "Scope"
                },
                {
                    "id": "5f8c59db-677d-491f-a6b8-5f174b11ec1d",
                    "type": "Scope"
                },
                {
                    "id": "e1fe6dd8-ba31-4d61-89e7-88639da4683d",
                    "type": "Scope"
                },
                {
                    "id": "a154be20-db9c-4678-8ab7-66f6cc099a59",
                    "type": "Scope"
                }
            ]
        }
    ],
    "samlMetadataUrl": null,
    "signInUrl": null,
    "signInAudience": "AzureADMyOrg",
    "tags": [],
    "tokenEncryptionKeyId": null
}






//https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth-ropc using (HttpClient client = new HttpClient()) { var username = "wcubero@dev2tenant.onmicrosoft.com "; var password = "$ABC123xyz"; var clientId = "0183d6e2-2f4d-xxx-xxx-xxxx"; var tenandId = "254e256b-76d7-xxx-xxxx-xxxx"; var postData = new FormUrlEncodedContent(new[] { new KeyValuePair<string, string>("username", username), new KeyValuePair<string, string>("password", password), new KeyValuePair<string, string>("grant_type","password"), new KeyValuePair<string, string>("client_secret","/|s+=xxxxxxxx|@u:##b&QLI-_Ya.B}d({Rk((}"), new KeyValuePair<string, string>("scope", $"openid profile"), new KeyValuePair<string, string>("client_id", clientId), new KeyValuePair<string, string>("response_type","token id_token") }); var response = await client.PostAsync(string.Format("https://login.microsoftonline.com/{0}/oauth2/v2.0/token",tenandId)/*TenantUrl*/, postData); var responseString = await response.Content.ReadAsStringAsync(); if (response.IsSuccessStatusCode) { var token = JsonConvert.DeserializeAnonymousType( responseString, new { access_token = string.Empty, token_type = string.Empty, expires_in = default(int), refresh_token = string.Empty, id_token = string.Empty }); var jwt = new JwtSecurityToken(token.id_token); var identity = new ClaimsIdentity(jwt.Claims, "password", "name", "role") { BootstrapContext = jwt }; int contador = 1; foreach (var item in identity.Claims) { Console.WriteLine(item.ToString()); contador++; } Console.WriteLine("TotalClaims: "+contador); Console.ReadKey(); } }

No hay comentarios:

Publicar un comentario