{"action":"created","comment":{"url":"https://api.github.com/repos/BristechSRM/auth/pulls/comments/60606266","id":60606266,"diff_hunk":"@@ -0,0 +1,82 @@\n+﻿namespace Services\n+\n+open IdentityServer3.Core\n+open IdentityServer3.Core.Models\n+open IdentityServer3.Core.Extensions\n+open IdentityServer3.Core.Services\n+open System\n+open System.Threading.Tasks\n+open System.Security.Claims\n+open Serilog\n+\n+open Entities\n+open UserRepository\n+\n+type AuthUserService() = \n+\n+    let getClaimsFromUser (user : AuthUserEntity)= \n+        [ new Claim(Constants.ClaimTypes.Subject, user.Id.ToString())\n+          new Claim(Constants.ClaimTypes.PreferredUserName, user.Email)\n+          new Claim(Constants.ClaimTypes.Email, user.Email)\n+          new Claim(Constants.ClaimTypes.GivenName, user.Firstname)\n+          new Claim(Constants.ClaimTypes.FamilyName, user.Surname) ]\n+\n+    interface IUserService with        \n+        member __.GetProfileDataAsync(context) = \n+            async { \n+                let subject = context.Subject\n+                let requestedClaimTypes = context.RequestedClaimTypes\n+                let success, subjectId = Guid.TryParse <| subject.GetSubjectId()\n+                if success then \n+                    let! userEntity = getUserAsync subjectId\n+                    match userEntity with\n+                    | Some user -> \n+                        context.IssuedClaims <- user\n+                                                |> getClaimsFromUser\n+                                                |> List.filter (fun x -> Seq.contains x.Type requestedClaimTypes)\n+                                                |> List.toSeq\n+                        return ()\n+                    | None -> raise <| ArgumentException \"Invalid subject identifier: No matching user.\"\n+                else raise <| ArgumentException \"Subject identifier was not a valid Guid\"\n+            }\n+            |> Async.StartAsUnitTask\n+\n+        member __.IsActiveAsync(context) = \n+            async {\n+                let subject = context.Subject\n+                let success, subjectId = Guid.TryParse <| subject.GetSubjectId()\n+                if success then \n+                    let! userEntity = getUserAsync subjectId                    \n+                    match userEntity with\n+                    | Some _ -> context.IsActive <- true\n+                    | None -> context.IsActive <- false\n+                else context.IsActive <- false\n+            }\n+            |> Async.StartAsUnitTask\n+\n+        member this.AuthenticateLocalAsync(context) = ","path":"Source/Auth.Web/AuthUserService.fs","position":57,"original_position":57,"commit_id":"8b526588bbf93f58069d3bc82e5746d0f3a37ef2","original_commit_id":"8b526588bbf93f58069d3bc82e5746d0f3a37ef2","user":{"login":"csscottlogic","id":6029627,"avatar_url":"https://avatars.githubusercontent.com/u/6029627?v=3","gravatar_id":"","url":"https://api.github.com/users/csscottlogic","html_url":"https://github.com/csscottlogic","followers_url":"https://api.github.com/users/csscottlogic/followers","following_url":"https://api.github.com/users/csscottlogic/following{/other_user}","gists_url":"https://api.github.com/users/csscottlogic/gists{/gist_id}","starred_url":"https://api.github.com/users/csscottlogic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/csscottlogic/subscriptions","organizations_url":"https://api.github.com/users/csscottlogic/orgs","repos_url":"https://api.github.com/users/csscottlogic/repos","events_url":"https://api.github.com/users/csscottlogic/events{/privacy}","received_events_url":"https://api.github.com/users/csscottlogic/received_events","type":"User","site_admin":false},"body":"Is there a reason to switch from __ to this?","created_at":"2016-04-21T15:51:42Z","updated_at":"2016-04-21T15:51:42Z","html_url":"https://github.com/BristechSRM/auth/pull/4#discussion_r60606266","pull_request_url":"https://api.github.com/repos/BristechSRM/auth/pulls/4","_links":{"self":{"href":"https://api.github.com/repos/BristechSRM/auth/pulls/comments/60606266"},"html":{"href":"https://github.com/BristechSRM/auth/pull/4#discussion_r60606266"},"pull_request":{"href":"https://api.github.com/repos/BristechSRM/auth/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/BristechSRM/auth/pulls/4","id":67372893,"html_url":"https://github.com/BristechSRM/auth/pull/4","diff_url":"https://github.com/BristechSRM/auth/pull/4.diff","patch_url":"https://github.com/BristechSRM/auth/pull/4.patch","issue_url":"https://api.github.com/repos/BristechSRM/auth/issues/4","number":4,"state":"open","locked":false,"title":"Basic local user authentication","user":{"login":"jebbinSCL","id":11422633,"avatar_url":"https://avatars.githubusercontent.com/u/11422633?v=3","gravatar_id":"","url":"https://api.github.com/users/jebbinSCL","html_url":"https://github.com/jebbinSCL","followers_url":"https://api.github.com/users/jebbinSCL/followers","following_url":"https://api.github.com/users/jebbinSCL/following{/other_user}","gists_url":"https://api.github.com/users/jebbinSCL/gists{/gist_id}","starred_url":"https://api.github.com/users/jebbinSCL/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jebbinSCL/subscriptions","organizations_url":"https://api.github.com/users/jebbinSCL/orgs","repos_url":"https://api.github.com/users/jebbinSCL/repos","events_url":"https://api.github.com/users/jebbinSCL/events{/privacy}","received_events_url":"https://api.github.com/users/jebbinSCL/received_events","type":"User","site_admin":false},"body":"Super basic setup and configuration to get a simple login page up.\r\nSome code will be thrown away once we have Paul's OpenId code. ","created_at":"2016-04-21T15:21:27Z","updated_at":"2016-04-21T15:51:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c610f85f62a1f5306e057c72897ca3cc82972261","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/BristechSRM/auth/pulls/4/commits","review_comments_url":"https://api.github.com/repos/BristechSRM/auth/pulls/4/comments","review_comment_url":"https://api.github.com/repos/BristechSRM/auth/pulls/comments{/number}","comments_url":"https://api.github.com/repos/BristechSRM/auth/issues/4/comments","statuses_url":"https://api.github.com/repos/BristechSRM/auth/statuses/8b526588bbf93f58069d3bc82e5746d0f3a37ef2","head":{"label":"BristechSRM:BasicLocalUserAuthentication","ref":"BasicLocalUserAuthentication","sha":"8b526588bbf93f58069d3bc82e5746d0f3a37ef2","user":{"login":"BristechSRM","id":17645943,"avatar_url":"https://avatars.githubusercontent.com/u/17645943?v=3","gravatar_id":"","url":"https://api.github.com/users/BristechSRM","html_url":"https://github.com/BristechSRM","followers_url":"https://api.github.com/users/BristechSRM/followers","following_url":"https://api.github.com/users/BristechSRM/following{/other_user}","gists_url":"https://api.github.com/users/BristechSRM/gists{/gist_id}","starred_url":"https://api.github.com/users/BristechSRM/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BristechSRM/subscriptions","organizations_url":"https://api.github.com/users/BristechSRM/orgs","repos_url":"https://api.github.com/users/BristechSRM/repos","events_url":"https://api.github.com/users/BristechSRM/events{/privacy}","received_events_url":"https://api.github.com/users/BristechSRM/received_events","type":"Organization","site_admin":false},"repo":{"id":56514365,"name":"auth","full_name":"BristechSRM/auth","owner":{"login":"BristechSRM","id":17645943,"avatar_url":"https://avatars.githubusercontent.com/u/17645943?v=3","gravatar_id":"","url":"https://api.github.com/users/BristechSRM","html_url":"https://github.com/BristechSRM","followers_url":"https://api.github.com/users/BristechSRM/followers","following_url":"https://api.github.com/users/BristechSRM/following{/other_user}","gists_url":"https://api.github.com/users/BristechSRM/gists{/gist_id}","starred_url":"https://api.github.com/users/BristechSRM/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BristechSRM/subscriptions","organizations_url":"https://api.github.com/users/BristechSRM/orgs","repos_url":"https://api.github.com/users/BristechSRM/repos","events_url":"https://api.github.com/users/BristechSRM/events{/privacy}","received_events_url":"https://api.github.com/users/BristechSRM/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/BristechSRM/auth","description":"","fork":false,"url":"https://api.github.com/repos/BristechSRM/auth","forks_url":"https://api.github.com/repos/BristechSRM/auth/forks","keys_url":"https://api.github.com/repos/BristechSRM/auth/keys{/key_id}","collaborators_url":"https://api.github.com/repos/BristechSRM/auth/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/BristechSRM/auth/teams","hooks_url":"https://api.github.com/repos/BristechSRM/auth/hooks","issue_events_url":"https://api.github.com/repos/BristechSRM/auth/issues/events{/number}","events_url":"https://api.github.com/repos/BristechSRM/auth/events","assignees_url":"https://api.github.com/repos/BristechSRM/auth/assignees{/user}","branches_url":"https://api.github.com/repos/BristechSRM/auth/branches{/branch}","tags_url":"https://api.github.com/repos/BristechSRM/auth/tags","blobs_url":"https://api.github.com/repos/BristechSRM/auth/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/BristechSRM/auth/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/BristechSRM/auth/git/refs{/sha}","trees_url":"https://api.github.com/repos/BristechSRM/auth/git/trees{/sha}","statuses_url":"https://api.github.com/repos/BristechSRM/auth/statuses/{sha}","languages_url":"https://api.github.com/repos/BristechSRM/auth/languages","stargazers_url":"https://api.github.com/repos/BristechSRM/auth/stargazers","contributors_url":"https://api.github.com/repos/BristechSRM/auth/contributors","subscribers_url":"https://api.github.com/repos/BristechSRM/auth/subscribers","subscription_url":"https://api.github.com/repos/BristechSRM/auth/subscription","commits_url":"https://api.github.com/repos/BristechSRM/auth/commits{/sha}","git_commits_url":"https://api.github.com/repos/BristechSRM/auth/git/commits{/sha}","comments_url":"https://api.github.com/repos/BristechSRM/auth/comments{/number}","issue_comment_url":"https://api.github.com/repos/BristechSRM/auth/issues/comments{/number}","contents_url":"https://api.github.com/repos/BristechSRM/auth/contents/{+path}","compare_url":"https://api.github.com/repos/BristechSRM/auth/compare/{base}...{head}","merges_url":"https://api.github.com/repos/BristechSRM/auth/merges","archive_url":"https://api.github.com/repos/BristechSRM/auth/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/BristechSRM/auth/downloads","issues_url":"https://api.github.com/repos/BristechSRM/auth/issues{/number}","pulls_url":"https://api.github.com/repos/BristechSRM/auth/pulls{/number}","milestones_url":"https://api.github.com/repos/BristechSRM/auth/milestones{/number}","notifications_url":"https://api.github.com/repos/BristechSRM/auth/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/BristechSRM/auth/labels{/name}","releases_url":"https://api.github.com/repos/BristechSRM/auth/releases{/id}","deployments_url":"https://api.github.com/repos/BristechSRM/auth/deployments","created_at":"2016-04-18T14:23:56Z","updated_at":"2016-04-20T11:24:45Z","pushed_at":"2016-04-21T15:42:25Z","git_url":"git://github.com/BristechSRM/auth.git","ssh_url":"git@github.com:BristechSRM/auth.git","clone_url":"https://github.com/BristechSRM/auth.git","svn_url":"https://github.com/BristechSRM/auth","homepage":null,"size":22,"stargazers_count":0,"watchers_count":0,"language":"F#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"BristechSRM:master","ref":"master","sha":"d1aaaa2e73df0a96348e9157f1033985dfd4e634","user":{"login":"BristechSRM","id":17645943,"avatar_url":"https://avatars.githubusercontent.com/u/17645943?v=3","gravatar_id":"","url":"https://api.github.com/users/BristechSRM","html_url":"https://github.com/BristechSRM","followers_url":"https://api.github.com/users/BristechSRM/followers","following_url":"https://api.github.com/users/BristechSRM/following{/other_user}","gists_url":"https://api.github.com/users/BristechSRM/gists{/gist_id}","starred_url":"https://api.github.com/users/BristechSRM/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BristechSRM/subscriptions","organizations_url":"https://api.github.com/users/BristechSRM/orgs","repos_url":"https://api.github.com/users/BristechSRM/repos","events_url":"https://api.github.com/users/BristechSRM/events{/privacy}","received_events_url":"https://api.github.com/users/BristechSRM/received_events","type":"Organization","site_admin":false},"repo":{"id":56514365,"name":"auth","full_name":"BristechSRM/auth","owner":{"login":"BristechSRM","id":17645943,"avatar_url":"https://avatars.githubusercontent.com/u/17645943?v=3","gravatar_id":"","url":"https://api.github.com/users/BristechSRM","html_url":"https://github.com/BristechSRM","followers_url":"https://api.github.com/users/BristechSRM/followers","following_url":"https://api.github.com/users/BristechSRM/following{/other_user}","gists_url":"https://api.github.com/users/BristechSRM/gists{/gist_id}","starred_url":"https://api.github.com/users/BristechSRM/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BristechSRM/subscriptions","organizations_url":"https://api.github.com/users/BristechSRM/orgs","repos_url":"https://api.github.com/users/BristechSRM/repos","events_url":"https://api.github.com/users/BristechSRM/events{/privacy}","received_events_url":"https://api.github.com/users/BristechSRM/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/BristechSRM/auth","description":"","fork":false,"url":"https://api.github.com/repos/BristechSRM/auth","forks_url":"https://api.github.com/repos/BristechSRM/auth/forks","keys_url":"https://api.github.com/repos/BristechSRM/auth/keys{/key_id}","collaborators_url":"https://api.github.com/repos/BristechSRM/auth/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/BristechSRM/auth/teams","hooks_url":"https://api.github.com/repos/BristechSRM/auth/hooks","issue_events_url":"https://api.github.com/repos/BristechSRM/auth/issues/events{/number}","events_url":"https://api.github.com/repos/BristechSRM/auth/events","assignees_url":"https://api.github.com/repos/BristechSRM/auth/assignees{/user}","branches_url":"https://api.github.com/repos/BristechSRM/auth/branches{/branch}","tags_url":"https://api.github.com/repos/BristechSRM/auth/tags","blobs_url":"https://api.github.com/repos/BristechSRM/auth/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/BristechSRM/auth/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/BristechSRM/auth/git/refs{/sha}","trees_url":"https://api.github.com/repos/BristechSRM/auth/git/trees{/sha}","statuses_url":"https://api.github.com/repos/BristechSRM/auth/statuses/{sha}","languages_url":"https://api.github.com/repos/BristechSRM/auth/languages","stargazers_url":"https://api.github.com/repos/BristechSRM/auth/stargazers","contributors_url":"https://api.github.com/repos/BristechSRM/auth/contributors","subscribers_url":"https://api.github.com/repos/BristechSRM/auth/subscribers","subscription_url":"https://api.github.com/repos/BristechSRM/auth/subscription","commits_url":"https://api.github.com/repos/BristechSRM/auth/commits{/sha}","git_commits_url":"https://api.github.com/repos/BristechSRM/auth/git/commits{/sha}","comments_url":"https://api.github.com/repos/BristechSRM/auth/comments{/number}","issue_comment_url":"https://api.github.com/repos/BristechSRM/auth/issues/comments{/number}","contents_url":"https://api.github.com/repos/BristechSRM/auth/contents/{+path}","compare_url":"https://api.github.com/repos/BristechSRM/auth/compare/{base}...{head}","merges_url":"https://api.github.com/repos/BristechSRM/auth/merges","archive_url":"https://api.github.com/repos/BristechSRM/auth/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/BristechSRM/auth/downloads","issues_url":"https://api.github.com/repos/BristechSRM/auth/issues{/number}","pulls_url":"https://api.github.com/repos/BristechSRM/auth/pulls{/number}","milestones_url":"https://api.github.com/repos/BristechSRM/auth/milestones{/number}","notifications_url":"https://api.github.com/repos/BristechSRM/auth/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/BristechSRM/auth/labels{/name}","releases_url":"https://api.github.com/repos/BristechSRM/auth/releases{/id}","deployments_url":"https://api.github.com/repos/BristechSRM/auth/deployments","created_at":"2016-04-18T14:23:56Z","updated_at":"2016-04-20T11:24:45Z","pushed_at":"2016-04-21T15:42:25Z","git_url":"git://github.com/BristechSRM/auth.git","ssh_url":"git@github.com:BristechSRM/auth.git","clone_url":"https://github.com/BristechSRM/auth.git","svn_url":"https://github.com/BristechSRM/auth","homepage":null,"size":22,"stargazers_count":0,"watchers_count":0,"language":"F#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/BristechSRM/auth/pulls/4"},"html":{"href":"https://github.com/BristechSRM/auth/pull/4"},"issue":{"href":"https://api.github.com/repos/BristechSRM/auth/issues/4"},"comments":{"href":"https://api.github.com/repos/BristechSRM/auth/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/BristechSRM/auth/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/BristechSRM/auth/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/BristechSRM/auth/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/BristechSRM/auth/statuses/8b526588bbf93f58069d3bc82e5746d0f3a37ef2"}}}}