LiveIdentity 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ecd029a77435438d0ac1dc51726532316a09891c
4
+ data.tar.gz: f305c2c6fa46c66ba3bc7e26042a3d986d344a71
5
+ SHA512:
6
+ metadata.gz: 71890b9398e59af0b8ab21555a0c1b6f927509a14aaf6c0f7441a0e15ce4ab56440c93789d9b71d575c1f3dfd14b08d7a770c8e26ce1538d75b19e3e9ff0ff1e
7
+ data.tar.gz: a47a8e61a5801d5c2ad84c7ccff47c67790f647e6a319d7274736501200e2be2fcba7ebd77e4c6ee731a7d69ded9148424f395a3e8c36066c45716c96e994905
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.1
4
+ - 2.0.0
5
+ - ruby-head
6
+ matrix:
7
+ allow_failures:
8
+ - rvm: ruby-head
@@ -0,0 +1 @@
1
+ --markup markdown
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in LiveIdentity.gemspec
4
+ gemspec
@@ -0,0 +1,44 @@
1
+ # LiveIdentity
2
+
3
+ Library utilizing IDCRL (Identity Client Runtime Library) for Microsoft Windows Live ID authentication.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'LiveIdentity'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install LiveIdentity
18
+
19
+ ## Unlicense
20
+
21
+ ![Copyright-Free](http://unlicense.org/pd-icon.png)
22
+
23
+ All text, documentation, code and files in this repository are in public domain (including this text, README).
24
+ It means you can copy, modify, distribute and include in your own work/code, even for commercial purposes, all without asking permission.
25
+
26
+ [About Unlicense](http://unlicense.org/)
27
+
28
+ ## Contributing
29
+
30
+ Feel free to improve as you see.
31
+
32
+ 1. Fork it ( https://github.com/davispuh/LiveIdentity/fork )
33
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
34
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
35
+ 4. Push to the branch (`git push origin my-new-feature`)
36
+ 5. Create a new Pull Request
37
+
38
+
39
+ **Warning**: By sending pull request to this repository you dedicate any and all copyright interest in pull request (code files and all other) to the public domain. (files will be in public domain even if pull request doesn't get merged)
40
+
41
+ Also before sending pull request you acknowledge that you own all copyrights or have authorization to dedicate them to public domain.
42
+
43
+ If you don't want to dedicate code to public domain or if you're not allowed to (eg. you don't own required copyrights) then DON'T send pull request.
44
+
@@ -0,0 +1,13 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'yard'
4
+
5
+ desc 'Default: run specs.'
6
+ task :default => :spec
7
+
8
+ desc 'Run specs'
9
+ RSpec::Core::RakeTask.new(:spec) do |t|
10
+ end
11
+
12
+ YARD::Rake::YardocTask.new(:doc) do |t|
13
+ end
@@ -0,0 +1,24 @@
1
+ This is free and unencumbered software released into the public domain.
2
+
3
+ Anyone is free to copy, modify, publish, use, compile, sell, or
4
+ distribute this software, either in source code form or as a compiled
5
+ binary, for any purpose, commercial or non-commercial, and by any
6
+ means.
7
+
8
+ In jurisdictions that recognize copyright laws, the author or authors
9
+ of this software dedicate any and all copyright interest in the
10
+ software to the public domain. We make this dedication for the benefit
11
+ of the public at large and to the detriment of our heirs and
12
+ successors. We intend this dedication to be an overt act of
13
+ relinquishment in perpetuity of all present and future rights to this
14
+ software under copyright law.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+ For more information, please refer to <http://unlicense.org/>
@@ -0,0 +1,170 @@
1
+ require 'win_common'
2
+
3
+ require_relative 'live_identity/version'
4
+ require_relative 'live_identity/idcrl'
5
+
6
+ def getStringLength(data)
7
+ length = 0
8
+ count = 0
9
+ offset = 0
10
+ previous = nil
11
+ while count < 2
12
+ data.get_bytes(offset, 100).each_byte do |byte|
13
+ length = length + 1
14
+ count = count + 1 if byte.zero? and previous.zero?
15
+ previous = byte
16
+ return length - 2 if count >= 2
17
+ end
18
+ offset += 100
19
+ break if offset >= 10000
20
+ end
21
+ length
22
+ end
23
+
24
+ class LiveIdentity
25
+ class LiveIdentityError < WinCommon::Errors::HRESULTError; end
26
+
27
+ def self.IsError?(hr)
28
+ WinCommon::Errors::HRESULT::IsError?(hr)
29
+ end
30
+
31
+ def initialize(guid, version, flags, options)
32
+ guidClientApplication = IDCRL::GUID.new
33
+ guidClientApplication.from_str(guid)
34
+ lPPCRLVersion = version
35
+ dwFlags = flags
36
+ dwOptions = options.count
37
+ pOptions = nil
38
+ if dwOptions > 0
39
+ pOptions = FFI::MemoryPointer.new(IDCRL::IDCRL_OPTION, dwOptions)
40
+ i = 0
41
+ options.each do |id, value|
42
+ option = IDCRL::IDCRL_OPTION.new(pOptions + i * IDCRL::IDCRL_OPTION.size)
43
+ option[:dwId] = id
44
+ option[:pValue] = FFI::MemoryPointer.new(:pointer)
45
+ if value.is_a?(String)
46
+ data = [value.encode('UTF-16LE')].pack('a*xx')
47
+ option[:pValue].write_string(data)
48
+ option[:cbValue] = data.bytesize
49
+ else
50
+ # TODO
51
+ end
52
+ i += 1
53
+ end
54
+ end
55
+
56
+ hr = IDCRL.InitializeEx(guidClientApplication, lPPCRLVersion, dwFlags, pOptions, dwOptions)
57
+ raise LiveIdentityError.new(hr) if LiveIdentity::IsError?(hr)
58
+ ObjectSpace.define_finalizer( self, self.class.finalize() )
59
+ end
60
+
61
+ def self.finalize()
62
+ Proc.new { IDCRL.Uninitialize() }
63
+ end
64
+
65
+ def GetIdentity(memberName, flags)
66
+ Identity.new(memberName, flags)
67
+ end
68
+
69
+ class Identity
70
+ attr_reader :hIdentity
71
+ def initialize(memberName, flags)
72
+ @hIdentity = nil
73
+ wszMemberName = [memberName.encode('UTF-16LE')].pack('a*xx')
74
+ dwflags = flags
75
+
76
+ pihIdentity = FFI::MemoryPointer.new(:pointer)
77
+ hr = IDCRL.CreateIdentityHandle(wszMemberName, dwflags, pihIdentity)
78
+ raise LiveIdentityError.new(hr) if LiveIdentity::IsError?(hr)
79
+ @hIdentity = pihIdentity.read_ulong
80
+ ObjectSpace.define_finalizer( self, self.class.finalize(@hIdentity) )
81
+ end
82
+
83
+ def self.finalize(hIdentity)
84
+ Proc.new do
85
+ hr = IDCRL.CloseIdentityHandle(hIdentity)
86
+ raise LiveIdentityError.new(hr) if LiveIdentity::IsError?(hr)
87
+ end
88
+ end
89
+
90
+ def SetProperty(property, value)
91
+ ipProperty = property
92
+ wszPropertyValue = [value.encode('UTF-16LE')].pack('a*xx')
93
+ hr = IDCRL.SetIdentityProperty(@hIdentity, ipProperty, wszPropertyValue)
94
+ raise LiveIdentityError.new(hr) if LiveIdentity::IsError?(hr)
95
+ end
96
+
97
+ def GetPropertyByName(name)
98
+ wszPropertyName = [name.encode('UTF-16LE')].pack('a*xx')
99
+ pwszPropertyValue = FFI::MemoryPointer.new(:pointer)
100
+ hr = IDCRL.GetIdentityPropertyByName(@hIdentity, wszPropertyName, pwszPropertyValue)
101
+ raise LiveIdentityError.new(hr) if LiveIdentity::IsError?(hr)
102
+ pwszPropertyValue = pwszPropertyValue.read_pointer.read_bytes(getStringLength(pwszPropertyValue.read_pointer))
103
+ pwszPropertyValue.force_encoding('UTF-16LE').encode('UTF-8')
104
+ end
105
+
106
+ def SetCredential(type, value)
107
+ wszCredType = [type.encode('UTF-16LE')].pack('a*xx')
108
+ wszCredValue = [value.encode('UTF-16LE')].pack('a*xx')
109
+ hr = IDCRL.SetCredential(@hIdentity, wszCredType, wszCredValue)
110
+ raise LiveIdentityError.new(hr) if LiveIdentity::IsError?(hr)
111
+ end
112
+
113
+ def AuthToService(target, policy, flags)
114
+ Service.new(self, target, policy, flags)
115
+ end
116
+
117
+ class ExtendedError
118
+ attr_reader :Category
119
+ attr_reader :Error
120
+ attr_reader :ErrorBlob
121
+ def initialize(identity)
122
+ @Category = nil
123
+ @Error = nil
124
+ @ErrorBlob = nil
125
+
126
+ hIdentity = identity.hIdentity
127
+ pdwCategory = FFI::MemoryPointer.new(:pointer)
128
+ pdwError = FFI::MemoryPointer.new(:pointer)
129
+ pszErrorBlob = FFI::MemoryPointer.new(:pointer)
130
+
131
+ hr = IDCRL.GetExtendedError(hIdentity, nil, pdwCategory, pdwError, pszErrorBlob)
132
+ raise LiveIdentityError.new(hr) if LiveIdentity::IsError?(hr)
133
+ end
134
+ end
135
+
136
+ def GetExtendedError
137
+ ExtendedError.new
138
+ end
139
+
140
+ class Service
141
+ attr_reader :Token
142
+ attr_reader :ResultFlags
143
+ attr_reader :SessionKey
144
+ def initialize(identity, target, policy, flags, sessionKey = false)
145
+ @Token = nil
146
+ @ResultFlags = nil
147
+ @SessionKey = nil
148
+
149
+ hIdentity = identity.hIdentity
150
+ szServiceTarget = [target.to_s.encode('UTF-16LE')].pack('a*xx')
151
+ szServicePolicy = [policy.to_s.encode('UTF-16LE')].pack('a*xx')
152
+ dwTokenRequestFlags = flags
153
+
154
+ szToken = FFI::MemoryPointer.new(:pointer)
155
+ pdwResultFlags = FFI::MemoryPointer.new(:pointer)
156
+ ppbSessionKey = nil
157
+ pcbSessionKeyLength = nil
158
+ if sessionKey
159
+ ppbSessionKey = FFI::MemoryPointer.new(:pointer)
160
+ pcbSessionKeyLength = FFI::MemoryPointer.new(:pointer)
161
+ end
162
+
163
+ hr = IDCRL.AuthIdentityToService(hIdentity, szServiceTarget, szServicePolicy, dwTokenRequestFlags, szToken, pdwResultFlags, ppbSessionKey, pcbSessionKeyLength)
164
+ raise LiveIdentityError.new(hr) if LiveIdentity::IsError?(hr)
165
+ szToken = szToken.read_pointer.read_bytes(getStringLength(szToken.read_pointer))
166
+ @Token = szToken.force_encoding('UTF-16LE').encode('UTF-8')
167
+ end
168
+ end
169
+ end
170
+ end
@@ -0,0 +1,121 @@
1
+ require 'ffi'
2
+ require 'win_common/typedefs'
3
+ require 'win_common/structs'
4
+
5
+ require_relative 'idcrl/constants'
6
+ require_relative 'idcrl/enums'
7
+ require_relative 'idcrl/hresult'
8
+
9
+ module WinCommon::Errors::HRESULT
10
+ include LiveIdentity::IDCRL::HRESULT
11
+ end
12
+
13
+ class LiveIdentity
14
+ include IDCRL::Constants
15
+ module IDCRL
16
+ extend FFI::Library
17
+ # http://msdn.microsoft.com/en-us/library/hh472108.aspx
18
+ ffi_lib 'msidcrl40'
19
+ ffi_convention :stdcall
20
+
21
+ include WinCommon::Structs
22
+ include Enums
23
+
24
+ require_relative 'idcrl/structs'
25
+ include Structs
26
+
27
+ typedef :pointer, :PassportIdentityHandlePointer
28
+ typedef :size_t, :PassportIdentityHandle
29
+ typedef :pointer, :PassportEnumIdentitiesHandlePointer
30
+ typedef :size_t, :PassportEnumIdentitiesHandle
31
+ typedef :pointer, :PIDCRL_OPTION
32
+
33
+ callback :cbIdentityChangedCallback, [:PassportEnumIdentitiesHandle, :pointer, :char], :uint
34
+
35
+ attach_function :Initialize, [ ], :HRESULT # TODO
36
+ attach_function :Uninitialize, [], :HRESULT
37
+ attach_function :PassportFreeMemory, [ :pointer ], :HRESULT
38
+ attach_function :CreateIdentityHandle, [ :LPCWSTR, IDENTITY_FLAG, :PassportIdentityHandlePointer ], :HRESULT
39
+ attach_function :SetCredential, [ :PassportIdentityHandle, :LPCWSTR, :LPCWSTR ], :HRESULT
40
+ attach_function :GetIdentityProperty, [ ], :HRESULT # TODO
41
+ attach_function :SetIdentityProperty, [ :PassportIdentityHandle, :uint, :LPCWSTR ], :HRESULT
42
+ attach_function :CloseIdentityHandle, [ :PassportIdentityHandle ], :HRESULT
43
+ attach_function :AuthIdentityToService, [ :PassportIdentityHandle, :LPCWSTR, :LPCWSTR, SERVICETOKENFLAGS, :PLPWSTR, :PDWORD, :PPBYTE, :PDWORD ], :HRESULT
44
+ attach_function :PersistCredential, [ ], :HRESULT # TODO
45
+ attach_function :RemovePersistedCredential, [ ], :HRESULT # TODO
46
+ attach_function :EnumIdentitiesWithCachedCredentials, [ :LPCWSTR, :PassportEnumIdentitiesHandlePointer ], :HRESULT
47
+ attach_function :NextIdentity, [ :PassportEnumIdentitiesHandle, :PLPWSTR ], :HRESULT
48
+ attach_function :CloseEnumIdentitiesHandle, [ :PassportEnumIdentitiesHandle ], :HRESULT
49
+ attach_function :GetAuthState, [ ], :HRESULT # TODO
50
+ attach_function :LogonIdentity, [ ], :HRESULT # TODO
51
+ attach_function :HasPersistedCredential, [ ], :HRESULT # TODO
52
+ attach_function :SetIdentityCallback, [ :PassportEnumIdentitiesHandle, :cbIdentityChangedCallback, :pointer ], :HRESULT
53
+ attach_function :InitializeEx, [ :REFGUID, :LONG, UPDATE_FLAG, :PIDCRL_OPTION, :DWORD ], :HRESULT
54
+ attach_function :GetWebAuthUrl, [ ], :HRESULT # TODO
55
+ attach_function :LogonIdentityEx, [ ], :HRESULT # TODO
56
+ attach_function :AuthIdentityToServiceEx, [ ], :HRESULT # TODO
57
+ attach_function :GetAuthStateEx, [ ], :HRESULT # TODO
58
+ attach_function :GetCertificate, [ ], :HRESULT # TODO
59
+ attach_function :CancelPendingRequest, [ ], :HRESULT # TODO
60
+ attach_function :VerifyCertificate, [ ], :HRESULT # TODO
61
+ attach_function :GetIdentityPropertyByName, [ :PassportIdentityHandle, :LPWSTR, :PLPWSTR ], :HRESULT
62
+ attach_function :SetExtendedProperty, [ ], :HRESULT # TODO
63
+ attach_function :GetExtendedProperty, [ ], :HRESULT # TODO
64
+ attach_function :GetServiceConfig, [ ], :HRESULT # TODO
65
+ attach_function :SetIdcrlOptions, [ ], :HRESULT # TODO
66
+ attach_function :GetWebAuthUrlEx, [ ], :HRESULT # TODO
67
+ attach_function :EncryptWithSessionKey, [ ], :HRESULT # TODO
68
+ attach_function :DecryptWithSessionKey, [ ], :HRESULT # TODO
69
+ attach_function :SetUserExtendedProperty, [ ], :HRESULT # TODO
70
+ attach_function :GetUserExtendedProperty, [ ], :HRESULT # TODO
71
+ attach_function :SetChangeNotificationCallback, [ ], :HRESULT # TODO
72
+ attach_function :RemoveChangeNotificationCallback, [ ], :HRESULT # TODO
73
+ attach_function :GetExtendedError, [ :PassportIdentityHandle, :LPVOID, :PDWORD, :PDWORD, :LPWSTR ], :HRESULT
74
+ attach_function :InitializeApp, [ ], :HRESULT # TODO
75
+ attach_function :EnumerateCertificates, [ ], :HRESULT # TODO
76
+ attach_function :GenerateCertToken, [ ], :HRESULT # TODO
77
+ attach_function :GetDeviceId, [ ], :HRESULT # TODO
78
+ attach_function :SetDeviceConsent, [ ], :HRESULT # TODO
79
+ attach_function :GenerateDeviceToken, [ ], :HRESULT # TODO
80
+ attach_function :CreateLinkedIdentityHandle, [ ], :HRESULT # TODO
81
+ attach_function :IsDeviceIDAdmin, [ ], :HRESULT # TODO
82
+ attach_function :EnumerateDeviceID, [ ], :HRESULT # TODO
83
+ attach_function :GetAssertion, [ ], :HRESULT # TODO
84
+ attach_function :VerifyAssertion, [ ], :HRESULT # TODO
85
+ attach_function :OpenAuthenticatedBrowser, [ ], :HRESULT # TODO
86
+ attach_function :LogonIdentityExWithUI, [ ], :HRESULT # TODO
87
+ attach_function :GetResponseForHttpChallenge, [ ], :HRESULT # TODO
88
+ attach_function :GetDeviceShortLivedToken, [ ], :HRESULT # TODO
89
+ attach_function :GetHIPChallenge, [ ], :HRESULT # TODO
90
+ attach_function :SetHIPSolution, [ ], :HRESULT # TODO
91
+ attach_function :SetDefaultUserForTarget, [ ], :HRESULT # TODO
92
+ attach_function :GetDefaultUserForTarget, [ ], :HRESULT # TODO
93
+ attach_function :UICollectCredential, [ ], :HRESULT # TODO
94
+ attach_function :AssociateDeviceToUser, [ ], :HRESULT # TODO
95
+ attach_function :DisassociateDeviceFromUser, [ ], :HRESULT # TODO
96
+ attach_function :EnumerateUserAssociatedDevices, [ ], :HRESULT # TODO
97
+ attach_function :UpdateUserAssociatedDeviceProperties, [ ], :HRESULT # TODO
98
+ attach_function :UIShowWaitDialog, [ ], :HRESULT # TODO
99
+ attach_function :UIEndWaitDialog, [ ], :HRESULT # TODO
100
+ attach_function :InitializeIDCRLTraceBuffer, [ ], :HRESULT # TODO
101
+ attach_function :FlushIDCRLTraceBuffer, [ ], :HRESULT # TODO
102
+ attach_function :IsMappedError, [ ], :HRESULT # TODO
103
+ attach_function :GetAuthenticationStatus, [ ], :HRESULT # TODO
104
+ attach_function :GetConfigDWORDValue, [ ], :HRESULT # TODO
105
+ attach_function :ProvisionDeviceId, [ ], :HRESULT # TODO
106
+ attach_function :GetDeviceIdEx, [ ], :HRESULT # TODO
107
+ attach_function :RenewDeviceId, [ ], :HRESULT # TODO
108
+ attach_function :DeProvisionDeviceId, [ ], :HRESULT # TODO
109
+ attach_function :UnPackErrorBlob, [ ], :HRESULT # TODO
110
+ attach_function :GetDefaultNoUISSOUser, [ ], :HRESULT # TODO
111
+ attach_function :LogonIdentityExSSO, [ ], :HRESULT # TODO
112
+ attach_function :StartTracing, [ ], :HRESULT # TODO
113
+ attach_function :StopTracing, [ ], :HRESULT # TODO
114
+ attach_function :GetRealmInfo, [ ], :HRESULT # TODO
115
+ attach_function :CreateIdentityHandleEx, [ ], :HRESULT # TODO
116
+ attach_function :AddUserToSsoGroup, [ ], :HRESULT # TODO
117
+ attach_function :GetUsersFromSsoGroup, [ ], :HRESULT # TODO
118
+ attach_function :RemoveUserFromSsoGroup, [ ], :HRESULT # TODO
119
+ attach_function :SendOneTimeCode, [ ], :HRESULT # TODO
120
+ end
121
+ end
@@ -0,0 +1,15 @@
1
+ class LiveIdentity
2
+ module IDCRL
3
+ module Constants
4
+ MaxLiveIDLength = 113
5
+ MaxLivePasswordLength = 31
6
+
7
+ PPCRL_CREDTYPE_MEMBERNAMEONLY = 'ps:active'
8
+ PPCRL_CREDTYPE_PASSWORD = 'ps:password'
9
+ PPCRL_CREDTYPE_ACTIVE = 'ps:membernameonly'
10
+ PPCRL_PROPERTY_FEDERATIONBRANDNAME = 'IsDomainUser'
11
+ PPCRL_CREDPROPERTY_ISDOMAINUSER = 'FederationBrandName'
12
+
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,129 @@
1
+ class LiveIdentity
2
+ module IDCRL
3
+ module Enums
4
+ def self.included(base)
5
+
6
+ base.const_set(:UPDATE_FLAG, base.enum(
7
+ :DEFAULT_UPDATE_POLICY, 0x00000000,
8
+ :UPDATE_DEFAULT, 0x00000000,
9
+ :OFFLINE_MODE_ALLOWED, 0x00000001,
10
+ :NO_UI, 0x00000002,
11
+ :SKIP_CONNECTION_CHECK, 0x00000004,
12
+ :IDCRL_RESERVED_1, 0x00000008,
13
+ :SET_INITIALIZATION_COOKIES, 0x00000010,
14
+ :UPDATE_FLAG_ALL_BIT, 0x0000001F))
15
+
16
+ base.const_set(:WLIDUI_FLAG, base.enum(
17
+ :WLIDUI_DEFAULT, 0x0000,
18
+ :WLIDUI_DISABLE_REMEBERME, 0x0001,
19
+ :WLIDUI_DISABLE_SAVEPASSWORD, 0x0002,
20
+ :WLIDUI_DISABLE_DIFFERENTUSER, 0x0004,
21
+ :WLIDUI_DISABLE_EID, 0x0020,
22
+ :WLIDUI_DISABLE_SIGNUPLINK, 0x0040,
23
+ :WLIDUI_DISABLE_SAVEDUSERS, 0x0080,
24
+ :WLIDUI_FORCE_SAVEPASSWORD, 0x0100,
25
+ :WLIDUI_FORCE_SMARTCARD, 0x0200,
26
+ :WLIDUI_ALL_BIT, 0x03FF))
27
+
28
+ base.const_set(:SERVICETOKENFLAGS, base.enum(
29
+ :SERVICE_TOKEN_TYPE_LEGACY_PASSPORT, 0x00000001,
30
+ :SERVICE_TOKEN_TYPE_WEBSSO, 0x00000002,
31
+ :SERVICE_TOKEN_TYPE_SAML, 0x00000002,
32
+ :SERVICE_TOKEN_TYPE_COMPACT_WEBSSO, 0x00000004,
33
+ :SERVICE_TOKEN_TYPE_X509V3, 0x00000008,
34
+ :SERVICE_TOKEN_CERT_IN_MEMORY_PRIVATE_KEY, 0x00000010,
35
+ :SERVICE_TOKEN_FROM_CACHE, 0x00010000))
36
+
37
+ base.const_set(:IDCRL_OPTION_ID, base.enum(
38
+ :IDCRL_OPTION_PROXY, 0x00000001,
39
+ :IDCRL_OPTION_CONNECT_TIMEOUT, 0x00000002,
40
+ :IDCRL_OPTION_SEND_TIMEOUT, 0x00000004,
41
+ :IDCRL_OPTION_RECEIVE_TIMEOUT, 0x00000008,
42
+ :IDCRL_OPTION_PROXY_PASSWORD, 0x00000010,
43
+ :IDCRL_OPTION_PROXY_USERNAME, 0x00000020,
44
+ :IDCRL_OPTION_ENVIRONMENT, 0x00000040,
45
+ :IDCRL_OPTION_ALL_BIT, 0x0000007F,
46
+ :IDCRL_OPTION_MSC_TIMEOUT, 0x00000080))
47
+
48
+ base.const_set(:IDCRL_DEVICE_CONSENT_OPTIONS, base.enum(
49
+ :IDCRL_DEVICE_ID_CONSENT_MIN, 0,
50
+ :IDCRL_DEVICE_ID_CONSENT_GRANT, 1,
51
+ :IDCRL_DEVICE_ID_CONSENT_REVOKE, 2,
52
+ :IDCRL_DEVICE_ID_CONSENT_REMOVE, 3,
53
+ :IDCRL_DEVICE_ID_CONSENT_MAX, 4))
54
+
55
+ base.const_set(:IDCRL_DEVICE_ID_OPTIONS, base.enum(
56
+ :IDCRL_DEVICE_ID_PHYSICAL, 0x0008,
57
+ :IDCRL_DEVICE_ID_FROMCACHE, 0x0010,
58
+ :IDCRL_DEVICE_ID_ACCESSCHECK, 0x0020,
59
+ :IDCRL_DEVICE_ID_NO_SIGNUP, 0x0100,
60
+ :IDCRL_DEVICE_ID_RENEW_CERT, 0x0200))
61
+
62
+ base.const_set(:LOGON_FLAG, base.enum(
63
+ :LOGONIDENTITY_DEFAULT, 0x0000,
64
+ :LOGONIDENTITY_ALLOW_PERSISTENT_COOKIES, 0x0008,
65
+ :LOGONIDENTITY_USE_EID_AUTH, 0x0010,
66
+ :LOGONIDENTITY_USE_LINKED_ACCOUNTS, 0x0020,
67
+ :LOGONIDENTITY_FEDERATED, 0x0040,
68
+ :LOGONIDENTITY_WLID, 0x0080,
69
+ :LOGONIDENTITY_AUTO_PARTNER_REDIRECT, 0x0100,
70
+ :LOGONIDENTITY_IGNORE_CACHED_TOKENS, 0x0200,
71
+ :LOGONIDENTITY_RESERVED_1, 0x0400,
72
+ :LOGONIDENTITY_ALL_BIT, 0x07FF))
73
+
74
+ base.const_set(:IDCRL_ERROR_CATEGORY, base.enum(
75
+ :IDCRL_REQUEST_BUILD_ERROR, 0x00000001,
76
+ :IDCRL_REQUEST_SEND_ERROR, 0x00000002,
77
+ :IDCRL_RESPONSE_RECEIVE_ERROR, 0x00000003,
78
+ :IDCRL_RESPONSE_READ_ERROR, 0x00000004,
79
+ :IDCRL_REPSONSE_PARSE_ERROR, 0x00000005,
80
+ :IDCRL_RESPONSE_SIG_DECRYPT_ERROR, 0x00000006,
81
+ :IDCRL_RESPONSE_PARSE_HEADER_ERROR, 0x00000007,
82
+ :IDCRL_RESPONSE_PARSE_TOKEN_ERROR, 0x00000008,
83
+ :IDCRL_RESPONSE_PUTCERT_ERROR, 0x00000009))
84
+
85
+ base.const_set(:PASSPORTIDENTITYPROPERTY, base.enum(
86
+ :IDENTITY_MEMBER_NAME, 1,
87
+ :IDENTITY_PUIDSTR, 2))
88
+
89
+ base.const_set(:SSO_FLAG, base.enum(
90
+ :SSO_DEFAULT, 0x00,
91
+ :SSO_NO_UI, 0x01,
92
+ :SSO_NO_AUTO_SIGNIN, 0x02,
93
+ :SSO_NO_HANDLE_ERROR, 0x04,
94
+ :SSO_ALL_BIT, 0x0F))
95
+
96
+ base.const_set(:IDCRL_SETOPTIONS_FLAG, base.enum(
97
+ :IDCRL_SETOPTIONS_SET, 0x00,
98
+ :IDCRL_SETOPTIONS_DEFAULT, 0x00,
99
+ :IDCRL_SETOPTIONS_RESET, 0x01))
100
+
101
+ base.const_set(:IDCRL_USER_DEVICE_ASSOCIATION_TYPE, base.enum(
102
+ :IDCRL_USER_DEVICE_SYSTEM, 0,
103
+ :IDCRL_USER_DEVICE_APP, 1))
104
+
105
+ base.const_set(:CERTREQUESTFLAGS, base.enum(
106
+ # CERT_FROM_CACHE = 0xUknown
107
+ ))
108
+
109
+ base.const_set(:IDENTITY_FLAG, base.enum(
110
+ :IDENTITY_SHARE_ALL, 0x000000FF,
111
+ :IDENTITY_LOAD_FROM_PERSISTED_STORE, 0x00000100,
112
+ :IDENTITY_AUTHSTATE_ENCRYPTED, 0x00000200,
113
+ :IDENTITY_FAST_CLOSE, 0x00000400,
114
+ :IDENTITY_DEVICEID_LOGICAL, 0x00001000,
115
+ :IDENTITY_ALL_BIT, 0x00001FFF))
116
+
117
+ base.const_set(:IDCRL_WEBAUTHOPTION, base.enum(
118
+ :IDCRL_WEBAUTH_NONE, 0,
119
+ :IDCRL_WEBAUTH_REAUTH, 1,
120
+ :IDCRL_WEBAUTH_PERSISTENT, 2))
121
+
122
+ base.const_set(:SERVICETOKEN_REQUEST_FLAGS, base.enum(
123
+ :SERVICE_TOKEN_REQUEST_TYPE_NONE, 0x00,
124
+ :SERVICE_TOKEN_REQUEST_TYPE_X509V3, 0x08))
125
+
126
+ end
127
+ end
128
+ end
129
+ end
@@ -0,0 +1,58 @@
1
+ class LiveIdentity
2
+ module IDCRL
3
+ module HRESULT
4
+ # SUCCESS
5
+ PPCRL_S_ALREADY_INITIALIZED = 0x00048044
6
+ PPCRL_S_STILL_INUSE = 0x00048045
7
+ PPCRL_S_NO_MORE_IDENTITIES = 0x00048860
8
+ PPCRL_S_TOKEN_TYPE_DOES_NOT_SUPPORT_SESSION_KEY = 0x00048861
9
+ PPCRL_S_NO_SUCH_CREDENTIAL = 0x00048862
10
+ PPCRL_REQUEST_S_IO_PENDING = 0x00048847
11
+ # ERRORS
12
+ PP_E_CRL_NOT_INITIALIZED = 0x80048008
13
+ PPCRL_NO_SESSION_KEY = 0x8004800E
14
+ PPCRL_HRESULT_BASE = 0x80048800
15
+ PPCRL_AUTHSTATE_E_UNAUTHENTICATED = 0x80048800
16
+ PPCRL_AUTHSTATE_E_EXPIRED = 0x80048801
17
+ PPCRL_AUTHREQUIRED_E_PASSWORD = 0x80048810
18
+ PPCRL_AUTHREQUIRED_E_UNKNOWN = 0x80048814
19
+ PPCRL_REQUEST_E_AUTH_SERVER_ERROR = 0x80048820
20
+ PPCRL_REQUEST_E_BAD_MEMBER_NAME_OR_PASSWORD = 0x80048821
21
+ PPCRL_REQUEST_E_PASSWORD_LOCKED_OUT = 0x80048823
22
+ PPCRL_REQUEST_E_PASSWORD_LOCKED_OUT_BAD_PASSWORD_OR_HIP = 0x80048824
23
+ PPCRL_REQUEST_E_TOU_CONSENT_REQUIRED = 0x80048825
24
+ PPCRL_REQUEST_E_FORCE_RENAME_REQUIRED = 0x80048826
25
+ PPCRL_REQUEST_E_FORCE_CHANGE_PASSWORD_REQUIRED = 0x80048827
26
+ PPCRL_REQUEST_E_PARTNER_NOT_FOUND = 0x8004882A
27
+ PPCRL_REQUEST_E_INVALID_POLICY = 0x8004882C
28
+ PPCRL_REQUEST_E_INVALID_MEMBER_NAME = 0x8004882D
29
+ PPCRL_REQUEST_E_MISSING_PRIMARY_CREDENTIAL = 0x8004882E
30
+ PPCRL_REQUEST_E_PENDING_NETWORK_REQUEST = 0x8004882F
31
+ PPCRL_REQUEST_E_PASSWORD_EXPIRED = 0x80048831
32
+ PPCRL_E_INITIALIZED_DIFF_ENVIRONMENT = 0x80048046
33
+ PPCRL_REQUEST_E_NO_NETWORK = 0x80048848
34
+ PPCRL_REQUESTPARAMS_MISSING = 0x80048852
35
+ PPCRL_E_IDENTITY_NOT_AUTHENTICATED = 0x80048861
36
+ PPCRL_E_UNABLE_TO_RETRIEVE_SERVICE_TOKEN = 0x80048862
37
+ PPCRL_E_AUTH_SERVICE_UNAVAILABLE = 0x80048869
38
+ PPCRL_E_INVALID_AUTH_SERVICE_RESPONSE = 0x8004886A
39
+ PPCRL_E_INVALIDFLAGS = 0x8004886F
40
+ PPCRL_E_BUSY = 0x80048882
41
+ PPCRL_E_NO_UI = 0x8004889C
42
+ PPCRL_E_REALM_LOOKUP = 0x80048895
43
+ PPCRL_E_NOT_UI_ERROR = 0x8004889F
44
+ PPCRL_REQUEST_E_PARTNER_INVALID_REQUEST = 0x800488D6
45
+ PPCRL_REQUEST_E_PARTNER_REQUEST_FAILED = 0x800488D7
46
+ PPCRL_REQUEST_E_PARTNER_INVALID_SECURITY_TOKEN = 0x800488D8
47
+ PPCRL_REQUEST_E_PARTNER_AUTHENTICATION_BAD_ELEMENTS = 0x800488D9
48
+ PPCRL_REQUEST_E_PARTNER_BAD_REQUEST = 0x800488DA
49
+ PPCRL_REQUEST_E_PARTNER_EXPIRED_DATA = 0x800488DB
50
+ PPCRL_REQUEST_E_PARTNER_INVALID_TIME_RANGE = 0x800488DC
51
+ PPCRL_REQUEST_E_PARTNER_INVALID_SCOPE = 0x800488DD
52
+ PPCRL_REQUEST_E_PARTNER_RENEW_NEEDED = 0x800488DE
53
+ PPCRL_REQUEST_E_PARTNER_UNABLE_TO_RENEW = 0x800488DF
54
+ PPCRL_REQUEST_E_CANCELLED = 0x800488E2
55
+ PPCRL_REQUEST_E_FORCE_SIGNIN = 0x800488E5
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,86 @@
1
+ class LiveIdentity
2
+ module IDCRL
3
+ module Structs
4
+ class IDCRL_OPTION < FFI::Struct
5
+ layout({
6
+ :dwId => IDCRL_OPTION_ID,
7
+ :pValue => :PBYTE,
8
+ :cbValue => :size_t
9
+ })
10
+ end
11
+
12
+ class IDCRL_OPTIONS < FFI::Struct
13
+ layout({
14
+ :dwCount => :DWORD,
15
+ :arrOptions => :pointer # *IDCRL_OPTION[]
16
+ })
17
+ end
18
+
19
+ class IDCRL_STATUS_V1 < FFI::Struct
20
+ layout({
21
+ :hrAuthState => :HRESULT,
22
+ :hrAuthRequired => :HRESULT,
23
+ :hrRequestStatus => :HRESULT,
24
+ :hrUIError => :HRESULT,
25
+ :wszWebFlowUrl => :LPWSTR,
26
+ })
27
+ end
28
+
29
+ class PASSPORT_NAME_VALUE_PAIR < FFI::Struct
30
+ layout({
31
+ :szName => :LPWSTR,
32
+ :szValue => :LPWSTR,
33
+ })
34
+ end
35
+
36
+ class IDCRL::UIParam < FFI::Struct
37
+ layout({
38
+ :dwFlags => :DWORD,
39
+ :hwndParent => :HANDLE,
40
+ :wszCobrandingText => :LPWSTR,
41
+ :wszAppName => :LPWSTR,
42
+ :wszSignupText => :LPWSTR,
43
+ :wszSignupText => :LPWSTR,
44
+ :wszCobrandingLogoPath => :LPWSTR,
45
+ :wszHeaderBgImage => :LPWSTR,
46
+ :dwBgColor => :DWORD,
47
+ :dwURLColor => :DWORD,
48
+ :dwTileBgColor => :DWORD,
49
+ :dwTileBdColor => :DWORD,
50
+ :dwFieldBdColor => :DWORD,
51
+ :dwCheckboxLbColor => :DWORD,
52
+ :dwBtTxtColor => :DWORD,
53
+ :dwTileLbColor => :DWORD,
54
+ :lWinLeft => :LONG,
55
+ :lWinTop => :LONG,
56
+ :wszSignupUrl => :LPWSTR
57
+ })
58
+ end
59
+
60
+ class RSTParams < FFI::Struct
61
+ layout({
62
+ :cbSize => :DWORD,
63
+ :wzServiceTarget => :LPCWSTR,
64
+ :wzServicePolicy => :LPCWSTR,
65
+ :dwTokenFlags => :DWORD,
66
+ :dwTokenParam => :DWORD
67
+ })
68
+ end
69
+
70
+ class PASSPORTCREDCUSTOMUI < FFI::Struct
71
+ layout({
72
+ :cElements => :LONG,
73
+ :customValues => :LPWSTR
74
+ })
75
+ end
76
+
77
+ class MultiRSTParams < FFI::Struct
78
+ layout({
79
+ :dwRSTParamsCount => :DWORD,
80
+ :pRSTParams => :pointer, # *RSTParams[]
81
+ :dwMultiRSTParamsFlags => :DWORD
82
+ })
83
+ end
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,3 @@
1
+ class LiveIdentity
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'live_identity/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'LiveIdentity'
8
+ spec.version = LiveIdentity::VERSION
9
+ spec.authors = ['Dāvis']
10
+ spec.email = ['davispuh@gmail.com']
11
+ spec.summary = 'Wrapper around IDCRL (Identity Client Runtime Library).'
12
+ spec.description = 'Library utilizing IDCRL for Microsoft Windows Live ID authentication.'
13
+ spec.homepage = 'https://github.com/davispuh/LiveIdentity'
14
+ spec.license = 'UNLICENSE'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_runtime_dependency 'WinCommon'
22
+ spec.add_runtime_dependency 'ffi'
23
+
24
+ spec.add_development_dependency 'bundler', '~> 1.6'
25
+ spec.add_development_dependency 'rake'
26
+ end
@@ -0,0 +1,5 @@
1
+ # encoding: UTF-8
2
+ require 'spec_helper'
3
+
4
+ describe LiveIdentity do
5
+ end
@@ -0,0 +1,5 @@
1
+ # encoding: UTF-8
2
+ require 'simplecov'
3
+
4
+ SimpleCov.start
5
+ require_relative '../lib/live_identity'
metadata ADDED
@@ -0,0 +1,120 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: LiveIdentity
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Dāvis
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: WinCommon
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: ffi
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.6'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.6'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Library utilizing IDCRL for Microsoft Windows Live ID authentication.
70
+ email:
71
+ - davispuh@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".travis.yml"
78
+ - ".yardopts"
79
+ - Gemfile
80
+ - README.md
81
+ - Rakefile
82
+ - UNLICENSE
83
+ - lib/live_identity.rb
84
+ - lib/live_identity/idcrl.rb
85
+ - lib/live_identity/idcrl/constants.rb
86
+ - lib/live_identity/idcrl/enums.rb
87
+ - lib/live_identity/idcrl/hresult.rb
88
+ - lib/live_identity/idcrl/structs.rb
89
+ - lib/live_identity/version.rb
90
+ - live_identity.gemspec
91
+ - spec/live_identity_spec.rb
92
+ - spec/spec_helper.rb
93
+ homepage: https://github.com/davispuh/LiveIdentity
94
+ licenses:
95
+ - UNLICENSE
96
+ metadata: {}
97
+ post_install_message:
98
+ rdoc_options: []
99
+ require_paths:
100
+ - lib
101
+ required_ruby_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ requirements: []
112
+ rubyforge_project:
113
+ rubygems_version: 2.2.2
114
+ signing_key:
115
+ specification_version: 4
116
+ summary: Wrapper around IDCRL (Identity Client Runtime Library).
117
+ test_files:
118
+ - spec/live_identity_spec.rb
119
+ - spec/spec_helper.rb
120
+ has_rdoc: