Skip to content

Commit c5e5a13

Browse files
committed
first commit
0 parents  commit c5e5a13

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+17588
-0
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
misc/
2+
*.log
3+
.DS_Store
4+
config.yml
5+
configs/config.yml
6+
configs/local.yml
7+
dist/

.vscode/settings.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"cSpell.words": [
3+
"Aadhaar",
4+
"aadhaarapi",
5+
"aadhaarcache",
6+
"grpc",
7+
"TOTP"
8+
],
9+
"protoc": {
10+
"options": [
11+
"--proto_path=api/proto",
12+
"--proto_path=third_party/"
13+
]
14+
}
15+
}

Makefile

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
CURRENT_VERSION:=v1
2+
PLATFORM_INFO:=$$(uname)-x$$(getconf LONG_BIT)
3+
PROTO_ENTRY:=aadhaar_service.proto
4+
PROTO_ENTRY_FOLDER:=api/proto/$(CURRENT_VERSION)
5+
FBS_FOLDER:=api/flatc
6+
FBS_BUILDER_FOLDER=pkg/flatbuffservice/api
7+
IGNORE:=api/proto/$(CURRENT_VERSION)/aadhaar_service.proto
8+
LAST_COMMIT:=$$(git rev-list -1 HEAD)
9+
TAG:=$$(git describe)
10+
GO_VERSION:=$$(go version)
11+
GO_OUT:=pkg/api/$(CURRENT_VERSION)
12+
all: proto restgateway swagger releaseb
13+
# chnageloggenerate
14+
15+
run:
16+
go run cmd/server/main.go
17+
chnageloggenerate:
18+
git-chglog -o CHANGELOG.md
19+
20+
proto:
21+
@ if ! which protoc > /dev/null; then \
22+
echo "error: protoc not installed" >&2; \
23+
exit 1; \
24+
fi
25+
@ echo "Compiling protobufs to go definitions..."
26+
@ for file in $(shell ls $(PROTO_ENTRY_FOLDER)/*.proto); do \
27+
echo "proto - $$file"; \
28+
protoc \
29+
--proto_path=$(PROTO_ENTRY_FOLDER) --proto_path=third_party/ \
30+
--go-grpc_out=$(GO_OUT) --go_out=$(GO_OUT) $$file $$i || exit 1 ;\
31+
protoc \
32+
--proto_path=$(PROTO_ENTRY_FOLDER) --proto_path=third_party/ \
33+
--go_out=":$(GO_OUT)" \
34+
--validate_out="lang=go:$(GO_OUT)" \
35+
$$file $$i || exit 1 ;\
36+
done
37+
@ echo "Compiling protobufs to go - success \n"
38+
39+
40+
41+
42+
restgateway:
43+
@ if ! which protoc > /dev/null; then \
44+
echo "error: protoc not installed" >&2; \
45+
exit 1; \
46+
fi
47+
@ echo "Compiling protobufs to restgateway..."
48+
@ protoc \
49+
--proto_path=$(PROTO_ENTRY_FOLDER) \
50+
--proto_path=third_party/ --grpc-gateway_out=logtostderr=true:$(GO_OUT) \
51+
$(PROTO_ENTRY);
52+
@ echo "Compiling protobufs to restgateway - success \n"
53+
54+
55+
swagger:
56+
@ if ! which protoc > /dev/null; then \
57+
echo "error: protoc not installed" >&2; \
58+
exit 1; \
59+
fi
60+
@ echo "Compiling protobufs to swagger definitions..."
61+
@ protoc \
62+
--proto_path=$(PROTO_ENTRY_FOLDER) --proto_path=third_party/ \
63+
--openapiv2_out=logtostderr=true:api/swagger/$(CURRENT_VERSION) $(PROTO_ENTRY)
64+
@ echo "Compiling protobufs to swagger - success \n"
65+
66+
# Create release binary for current Platform
67+
releaseb:
68+
@ echo "Compiling release binary"
69+
@ go build -ldflags "-s -w -X main.gitCommit=$(LAST_COMMIT) -X main.gitTag=$(TAG)" -o dist/server-$(PLATFORM_INFO) cmd/server/main.go;
70+
@ echo "Compiling binary success - output=dist/server-$(PLATFORM_INFO)"
71+
72+
# Create release binary for current Platform
73+
releaseclientb:
74+
@ echo "Compiling client release binary"
75+
@ go build -ldflags "-s -w" -o dist/client-$(PLATFORM_INFO) cmd/client-grpc/main.go;
76+
@ echo "Compiling client binary success - output=dist/client-$(PLATFORM_INFO)"
77+
78+
79+
# Create debug binary for current platform
80+
debugb:
81+
go build -o debug cmd/server/main.go;

Readme.md

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
# Aadhaar Paperless Offline e-KYC APIs
2+
3+
Aadhaar Paperless Offline e-KYC is a secure and shareable document which can be used by any Aadhaar holder for offline verification of identification.(https://resident.uidai.gov.in/offline-kyc)
4+
5+
## Introduction
6+
7+
This server exposing 3 APIs to download a ZIP file containing the Resident's Paperless Offline eKYC from UIDAI website.
8+
9+
- API to fetch captcha from UIDAI - GetCaptcha.
10+
- API to enter aadhaar number and captcha received in GetCaptcha API.
11+
- By calling this API, user will get an OTP to the phone number associated to aadhaar.
12+
- API to enter OTP received and four digit zipCode(share code).
13+
14+
These APIs depend on `https://resident.uidai.gov.in/offline-kyc` website.
15+
By using these APIs client can expose their own interface to user.
16+
17+
### How To Run Server
18+
19+
```sh
20+
go run cmd/server/main.go
21+
```
22+
23+
This server exposing 2 type of API interfaces(gRPC and REST).
24+
Default port for gRPC server is 4444 and REST is 3333. (configs/default.yml).
25+
26+
This can be changed by adding environment specific configs.
27+
28+
Example:
29+
Add `configs/local.yml` and run `env=local go run cmd/server/main.go`
30+
31+
```yml
32+
# sample config
33+
server:
34+
grpcPort: 4444
35+
httpPort: 3333
36+
host: "0.0.0.0"
37+
38+
logger:
39+
outputPath: "stdout"
40+
level: "info"
41+
disableStackTrace: true
42+
43+
accessLogger:
44+
outputPath: "stdout"
45+
level: "error"
46+
disableStackTrace: true
47+
48+
```
49+
50+
### Use as a package
51+
52+
```sh
53+
import "github.com/aaabhilash97/aadhaar_scrapper_apis/pkg/aadhaarapi"
54+
```
55+
56+
# API Details
57+
58+
If client wants to use gRPC interface, client can generate client code from `api/proto` using protobuf compiler.
59+
60+
# REST API Details
61+
62+
## Get Captcha
63+
64+
To fetch captcha and session id from UIDAI.
65+
66+
* ### **gRPC FUNCTION NAME** - GetCaptcha
67+
* ### **METHOD** - `GET`
68+
* ### **URL** - `{{baseUrl}}/api/v1/GetCaptcha`
69+
* ### **RESPONSE**
70+
```json
71+
{
72+
"status": {
73+
"code": <string | response status code>,
74+
"message": <string | message>
75+
},
76+
"data": {
77+
"session_id": <string | session id>,
78+
"captcha_image": <string | base64 encoded image>
79+
}
80+
}
81+
```
82+
83+
## Verify Captcha
84+
85+
Once captcha fetched, need to call this API with aadhaar number(uid_no) and captcha(security_code).
86+
87+
On success user will receive an OTP on phone number associated with aadhaar.
88+
89+
* ### **gRPC FUNCTION NAME** - VerifyCaptcha
90+
* ### **METHOD** - `POST`
91+
* ### **URL** - `{{baseUrl}}/api/v1/VerifyCaptcha`
92+
* ### **REQUEST**
93+
```json
94+
{
95+
"session_id": <string | session id>,
96+
"uid_no": <string | Enter your 12 digit Aadhaar number or 16 digit Virtual ID to begin.>,
97+
"security_code": <string | captcha received by user>
98+
}
99+
```
100+
101+
* ### **RESPONSE**
102+
```json
103+
{
104+
"status": {
105+
"code": <string | response status code>,
106+
"message": <string | message>
107+
}
108+
}
109+
```
110+
111+
## Verify OTP and Fetch aadhaar details
112+
113+
Call this API with OTP received to download zip file from UIDAI and fetch details.
114+
115+
* ### **gRPC FUNCTION NAME** - VerifyOtpAndGetAadhaar
116+
* ### **METHOD** - `POST`
117+
* ### **URL** - `{{baseUrl}}/api/v1/VerifyOtpAndGetAadhaar`
118+
* ### **REQUEST**
119+
```json
120+
{
121+
"session_id": <string | session id>,
122+
"otp": <string | 6 digit OTP or 8 digit TOTP.>,
123+
"zip_code": <string | 4 characters>,
124+
"include_zip_file": <bool | to include zip file in response>,
125+
"include_xml_file": <bool | to include xml file in response>
126+
}
127+
```
128+
129+
* ### **RESPONSE**
130+
```json
131+
{
132+
"status": {
133+
"code": <string | response status code>,
134+
"message": <string | message>
135+
},
136+
"data": {
137+
"details": {
138+
"poi": { // Proof of identity
139+
"dob": <string | Example: 10-09-1991>,
140+
"gender": <string | F or M>,
141+
"mobile_hash": <string>,
142+
"name": <string | Name as in aadhaar>
143+
},
144+
"poa": { // Proof of address
145+
"careof": <string>,
146+
"country":<string>,
147+
"dist": <string>,
148+
"house": <string>,
149+
"landmark":<string>,
150+
"pincode": <string>,
151+
"postoffice":<string>,
152+
"state": <string>,
153+
"street":<string>,
154+
"subdist": <string>,
155+
"vtc": <string>,
156+
},
157+
"photo": <string | Base64 encoded image of face photo>
158+
},
159+
"zip_file": <string | Base64 encoded zip file downloaded from uidai>,
160+
"xml_file": <string | Base64 encoded xml file adhaar Paperless Offline e-KYC>
161+
}
162+
}
163+
```
164+
165+
# Response Status Codes
166+
* ### **2000** - Success
167+
* ### **4000** - Request validation errors
168+
* ### **5000** - Unknown error
169+
* ### **5001** - UIDAI technical issue error
170+
* ### **4002** - Invalid captcha
171+
* ### **4003** - Invalid OTP
172+
* ### **4004** - Invalid aadhaar number
173+
* ### **4005** - Session expired
174+
* ### **4006** - Invalid session id
175+
* ### **4090** - Aadhaar already downloaded error.
176+

api/proto/.chglog/CHANGELOG.tpl.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{{ if .Versions -}}
2+
<a name="unreleased"></a>
3+
## [Unreleased]
4+
5+
{{ if .Unreleased.CommitGroups -}}
6+
{{ range .Unreleased.CommitGroups -}}
7+
### {{ .Title }}
8+
{{ range .Commits -}}
9+
- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
10+
{{ end }}
11+
{{ end -}}
12+
{{ end -}}
13+
{{ end -}}
14+
15+
{{ range .Versions }}
16+
<a name="{{ .Tag.Name }}"></a>
17+
## {{ if .Tag.Previous }}[{{ .Tag.Name }}]{{ else }}{{ .Tag.Name }}{{ end }} - {{ datetime "2006-01-02" .Tag.Date }}
18+
{{ range .CommitGroups -}}
19+
### {{ .Title }}
20+
{{ range .Commits -}}
21+
- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
22+
{{ end }}
23+
{{ end -}}
24+
25+
{{- if .RevertCommits -}}
26+
### Reverts
27+
{{ range .RevertCommits -}}
28+
- {{ .Revert.Header }}
29+
{{ end }}
30+
{{ end -}}
31+
32+
{{- if .MergeCommits -}}
33+
### Merge Requests
34+
{{ range .MergeCommits -}}
35+
- {{ .Header }}
36+
{{ end }}
37+
{{ end -}}
38+
39+
{{- if .NoteGroups -}}
40+
{{ range .NoteGroups -}}
41+
### {{ .Title }}
42+
{{ range .Notes }}
43+
{{ .Body }}
44+
{{ end }}
45+
{{ end -}}
46+
{{ end -}}
47+
{{ end -}}
48+
49+
{{- if .Versions }}
50+
[Unreleased]: {{ .Info.RepositoryURL }}/compare/{{ $latest := index .Versions 0 }}{{ $latest.Tag.Name }}...HEAD
51+
{{ range .Versions -}}
52+
{{ if .Tag.Previous -}}
53+
[{{ .Tag.Name }}]: {{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}
54+
{{ end -}}
55+
{{ end -}}
56+
{{ end -}}

0 commit comments

Comments
 (0)